本文整理汇总了Java中net.minecraft.dispenser.BehaviorDefaultDispenseItem类的典型用法代码示例。如果您正苦于以下问题:Java BehaviorDefaultDispenseItem类的具体用法?Java BehaviorDefaultDispenseItem怎么用?Java BehaviorDefaultDispenseItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorDefaultDispenseItem类属于net.minecraft.dispenser包,在下文中一共展示了BehaviorDefaultDispenseItem类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispenseStack
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; //导入依赖的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;
}
示例2: registerItems
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; //导入依赖的package包/类
public static void registerItems() {
if (!((RegistrySimple)BlockDispenser.dispenseBehaviorRegistry).containsKey((Object)Items.glass_bottle)) {
BlockDispenser.dispenseBehaviorRegistry.putObject((Object)Items.glass_bottle, (Object)new BehaviorDefaultDispenseItem() {
private final BehaviorDefaultDispenseItem field_150840_b = new BehaviorDefaultDispenseItem();
public ItemStack dispenseStack(final IBlockSource par1IBlockSource, final ItemStack par2ItemStack) {
final EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
final World world = par1IBlockSource.getWorld();
final int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
final int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
final int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
final Material material = world.getBlock(i, j, k).getMaterial();
final int l = world.getBlockMetadata(i, j, k);
if (Material.water.equals(material) && l == 0) {
final Item item = (Item)Items.potionitem;
if (--par2ItemStack.stackSize == 0) {
par2ItemStack.func_150996_a(item);
par2ItemStack.stackSize = 1;
par2ItemStack.setTagCompound((NBTTagCompound)null);
}
else if (((TileEntityDispenser)par1IBlockSource.getBlockTileEntity()).func_146019_a(new ItemStack(item)) < 0) {
this.field_150840_b.dispense(par1IBlockSource, new ItemStack(item));
}
return par2ItemStack;
}
return super.dispenseStack(par1IBlockSource, par2ItemStack);
}
});
}
}
示例3: dispenseAccessory
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; //导入依赖的package包/类
public static ItemStack dispenseAccessory(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);
if (entitylivingbase instanceof EntityPlayer)
{
ItemStack itemstack = stack.copy();
itemstack.stackSize = 1;
PlayerAether playerAether = PlayerAether.get((EntityPlayer) entitylivingbase);
if (!playerAether.accessories.setInventoryAccessory(itemstack))
{
BehaviorDefaultDispenseItem.doDispense(blockSource.getWorld(), itemstack, 6, (EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING), BlockDispenser.getDispensePosition(blockSource));
}
--stack.stackSize;
return stack;
}
}
return stack;
}
示例4: BehaviorGel
import net.minecraft.dispenser.BehaviorDefaultDispenseItem; //导入依赖的package包/类
public BehaviorGel(MinecraftServer server) {
this.server = server;
this.defaultBehavior = new BehaviorDefaultDispenseItem();
}