本文整理匯總了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();
}
}