本文整理汇总了Java中net.minecraft.block.BlockDispenser类的典型用法代码示例。如果您正苦于以下问题:Java BlockDispenser类的具体用法?Java BlockDispenser怎么用?Java BlockDispenser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockDispenser类属于net.minecraft.block包,在下文中一共展示了BlockDispenser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDispenser
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
protected boolean createDispenser(World p_189419_1_, StructureBoundingBox p_189419_2_, Random p_189419_3_, int p_189419_4_, int p_189419_5_, int p_189419_6_, EnumFacing p_189419_7_, ResourceLocation p_189419_8_)
{
BlockPos blockpos = new BlockPos(this.getXWithOffset(p_189419_4_, p_189419_6_), this.getYWithOffset(p_189419_5_), this.getZWithOffset(p_189419_4_, p_189419_6_));
if (p_189419_2_.isVecInside(blockpos) && p_189419_1_.getBlockState(blockpos).getBlock() != Blocks.DISPENSER)
{
this.setBlockState(p_189419_1_, Blocks.DISPENSER.getDefaultState().withProperty(BlockDispenser.FACING, p_189419_7_), p_189419_4_, p_189419_5_, p_189419_6_, p_189419_2_);
TileEntity tileentity = p_189419_1_.getTileEntity(blockpos);
if (tileentity instanceof TileEntityDispenser)
{
((TileEntityDispenser)tileentity).setLootTable(p_189419_8_, p_189419_3_.nextLong());
}
return true;
}
else
{
return false;
}
}
示例2: dispenseArmor
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));
if (list.isEmpty())
{
return ItemStack.field_190927_a;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
ItemStack itemstack = stack.splitStack(1);
entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);
if (entitylivingbase instanceof EntityLiving)
{
((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
}
return stack;
}
}
示例3: fillContainer
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
/**
* Picks up fluid in front of a Dispenser and fills a container with it.
*/
private ItemStack fillContainer(IBlockSource source, ItemStack stack)
{
World world = source.getWorld();
EnumFacing dispenserFacing = source.getBlockState().getValue(BlockDispenser.FACING);
BlockPos blockpos = source.getBlockPos().offset(dispenserFacing);
ItemStack result = FluidUtil.tryPickUpFluid(stack, null, world, blockpos, dispenserFacing.getOpposite());
if (result == null)
{
return super.dispenseStack(source, stack);
}
if (--stack.stackSize == 0)
{
stack.deserializeNBT(result.serializeNBT());
}
else if (((TileEntityDispenser)source.getBlockTileEntity()).addItemStack(result) < 0)
{
this.dispenseBehavior.dispense(source, result);
}
return stack;
}
示例4: dispenseArmor
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));
if (list.isEmpty())
{
return null;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
ItemStack itemstack = stack.copy();
itemstack.stackSize = 1;
entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);
if (entitylivingbase instanceof EntityLiving)
{
((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
}
--stack.stackSize;
return stack;
}
}
示例5: PreInit
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
@EventHandler
public void PreInit(FMLPreInitializationEvent event){
event.getModMetadata().version = Versions.fullVersionString();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy);
proxy.preInit();
ModBlocks.init();
ModItems.init();
CapabilityMinecartDestination.register();
CapabilityDestinationProvider.register();
MinecraftForge.EVENT_BUS.register(proxy);
MinecraftForge.EVENT_BUS.register(new com.minemaarten.signals.event.EventHandler());
MinecraftForge.EVENT_BUS.register(new RailReplacerEventHandler());
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(ModItems.TICKET, new BehaviorDispenseTicket());
asmData = event.getAsmData();
}
示例6: dispenseStack
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public ItemStack dispenseStack(IBlockSource dispenser, ItemStack cartItemStack)
{
EntityMinecartBase entityMinecartBase;
World world = dispenser.getWorld();
boolean cartSpawned = false;
if(ItemStackUtils.isItemInstanceOf(cartItemStack, ItemMinecartBase.class))
{
ItemMinecartBase itemMinecartBase = (ItemMinecartBase)cartItemStack.getItem();
entityMinecartBase = itemMinecartBase.getEntityFromItem(world, cartItemStack);
if(entityMinecartBase != null)
{
EnumFacing enumfacing = BlockDispenser.getFacing(dispenser.getBlockMetadata());
BlockPos blockpos = dispenser.getBlockPos().offset(enumfacing);
cartSpawned = itemMinecartBase.placeCart(cartItemStack, world, blockpos, entityMinecartBase);
}
}
if(!cartSpawned)
{
cartItemStack = super.dispenseStack(dispenser, cartItemStack);
}
return cartItemStack;
}
示例7: ItemLC
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public ItemLC(ItemArmor.ArmorMaterial material, int renderIndex, int armorType)
{
super(material, renderIndex, armorType);
this.material = material;
this.armorType = armorType;
if(this.armorType == 0)
name = "LeatherChainHelmet";
else if(this.armorType == 1)
name = "LeatherChainChest";
else if(this.armorType == 2)
name = "LeatherChainLegs";
else if(this.armorType == 3)
name = "LeatherChainBoots";
else
name = "LeatherChainHelmet";
GameRegistry.registerItem(this, name);
setUnlocalizedName(mod_Rediscovered.modid + "_" + name);
this.renderIndex = renderIndex;
this.damageReduceAmount = material.getDamageReductionAmount(armorType);
this.setMaxDamage(material.getDurability(armorType));
this.maxStackSize = 1;
this.setCreativeTab(CreativeTabs.tabCombat);
BlockDispenser.dispenseBehaviorRegistry.putObject(this, dispenserBehavior);
}
示例8: dispenseStack
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
/**
* Dispense the specified stack, play the dispense sound and spawn particles.
*/
public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
World world = par1IBlockSource.getWorld();
IPosition iposition = BlockDispenser.func_149939_a(par1IBlockSource);
EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
ItemStack stack = par2ItemStack.splitStack(1);
if (matchesItem(par2ItemStack)) {
// dispense item as projectile because the item matches
IProjectile iprojectile = this.getProjectileEntity(world, iposition, par2ItemStack);
iprojectile.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
world.spawnEntityInWorld((Entity) iprojectile);
} else {
// dispense item as item because it doesn't match
BehaviorDefaultDispenseItem.doDispense(world, stack, 6, enumfacing, iposition);
}
return par2ItemStack;
}
示例9: dispenseStack
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
float y = 1.1F;
World var3 = source.getWorld();
IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
EnumFacing var5 = BlockDispenser.getFacing(source.getBlockMetadata());
IProjectile var6 = this.getProjectileEntity(var3, var4, stack.getItemDamage());
if(var6 != null)
{
var6.setThrowableHeading((double)var5.getFrontOffsetX(), 0.10000000149011612D*y, (double)var5.getFrontOffsetY(), this.func_82500_b(), this.func_82498_a());
var3.spawnEntityInWorld((Entity)var6);
stack.splitStack(1);
}
return stack;
}
示例10: dispenseStack
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
float y = 1.1F;
World var3 = source.getWorld();
IPosition var4 = BlockDispenser.getIPositionFromBlockSource(source);
EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
IProjectile iprojectile = this.getProjectileEntity(var3, var4, stack.getItemDamage());
if(iprojectile != null)
{
iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
var3.spawnEntityInWorld((Entity)iprojectile);
stack.splitStack(1);
}
return stack;
}
示例11: init
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public static void init() {
EntityRegistry.registerModEntity(EntityMagician.class, "entityMagician", mageID, MagiciansArtifice.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntitySoulFragment.class, "entitySoul", soulID, MagiciansArtifice.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityBossOverworld.class, "bossOverworld", overworldBossID, MagiciansArtifice.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityBossNether.class, "bossNether", netherBossID, MagiciansArtifice.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityBossEnder.class, "bossEnder", enderBossID, MagiciansArtifice.instance, 80, 3, true);
//EntityRegistry.registerModEntity(EntityPetPheonix.class, "petPheonix", pheonixID, MagiciansArtifice.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityPetAppling.class, "petAppling", applingID, MagiciansArtifice.instance, 80, 3, true);
EntityRegistry.registerModEntity(EntityPetDragon.class, "petDragon", dragonID, MagiciansArtifice.instance, 80, 3, true);
//EntityRegistry.registerModEntity(EntityPetRat.class, "petRat", ratID, MagiciansArtifice.instance, 80, 3, true);
BlockDispenser.dispenseBehaviorRegistry.putObject(ItemRegistry.horcrux, new DispenserSoulBehavior());
registerEntityEgg(EntityMagician.class, 0x000349, 0xFFE343);
registerEntityEgg(EntityBossOverworld.class, 0xBBF2FF, 0xFFFFFF);
registerEntityEgg(EntityBossNether.class, 0xDA0000, 0x3B0000);
registerEntityEgg(EntityBossEnder.class, 0x3C0059, 0x2B0C36);
registerEntityEgg(EntityPetAppling.class, 0xDE0101, 0xFFC8C8);
registerEntityEgg(EntityPetDragon.class, 0xDE0101, 0xFFC8C8);
registerVillagers();
}
示例12: dispenseStack
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack)
{
EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
World world = par1IBlockSource.getWorld();
int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
if (par2ItemStack.hasTagCompound() && par2ItemStack.stackTagCompound.hasKey("ownerName")) {
EntitySoulFragment soul = new EntitySoulFragment(world);
soul.setPlayerName(par2ItemStack.stackTagCompound.getString("ownerName"));
soul.setLocationAndAngles(i,j,k,0,0);
world.spawnEntityInWorld(soul);
System.err.println(soul);
System.err.println(soul.playerName);
}
return par2ItemStack;
}
示例13: dispenseStack
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public ItemStack dispenseStack(IBlockSource blockSource, ItemStack stack) {
if (NBTHelper.hasTag(stack, "identifier")) {
World world = blockSource.getWorld();
IPosition iposition = BlockDispenser.func_149939_a(blockSource);
EnumFacing enumfacing = BlockDispenser.func_149937_b(blockSource.getBlockMetadata());
EntityNanoBotSwarm iprojectile = new EntityNanoBotSwarm(world, iposition.getX(), iposition.getY(), iposition.getZ());
iprojectile.antennaIdentifier = UUID.fromString(NBTHelper.getString(stack, "identifier"));
if (NBTHelper.hasTag(stack, "label"))
iprojectile.label = NBTHelper.getString(stack, "label");
iprojectile.setThrowableHeading((double) enumfacing.getFrontOffsetX(), (double) ((float) enumfacing.getFrontOffsetY()+0.1F), (double) enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
world.spawnEntityInWorld(iprojectile);
stack.splitStack(1);
} else {
return super.dispenseStack(blockSource, stack);
}
return stack;
}
示例14: dispenseArmor
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.func_189992_e().getValue(BlockDispenser.FACING));
List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));
if (list.isEmpty())
{
return null;
}
else
{
EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
ItemStack itemstack = stack.copy();
itemstack.stackSize = 1;
entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);
if (entitylivingbase instanceof EntityLiving)
{
((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
}
--stack.stackSize;
return stack;
}
}
示例15: registerItems
import net.minecraft.block.BlockDispenser; //导入依赖的package包/类
private static void registerItems() {
try {
for (Field f: ZSSItems.class.getFields()) {
if (Item.class.isAssignableFrom(f.getType())) {
Item item = (Item) f.get(null);
if (item != null) {
ZSSItems.registerItemComparatorMapping(item);
String name = item.getUnlocalizedName();
GameRegistry.registerItem(item, name.substring(name.lastIndexOf(".") + 1));
if (item instanceof ICustomDispenserBehavior) {
BlockDispenser.dispenseBehaviorRegistry.putObject(item, ((ICustomDispenserBehavior) item).getNewDispenserBehavior());
}
}
}
}
} catch(Exception e) {
ZSSMain.logger.warn("Caught exception while registering items: " + e.toString());
e.printStackTrace();
}
}