本文整理汇总了Java中net.minecraft.dispenser.IBehaviorDispenseItem.dispense方法的典型用法代码示例。如果您正苦于以下问题:Java IBehaviorDispenseItem.dispense方法的具体用法?Java IBehaviorDispenseItem.dispense怎么用?Java IBehaviorDispenseItem.dispense使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.dispenser.IBehaviorDispenseItem
的用法示例。
在下文中一共展示了IBehaviorDispenseItem.dispense方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispense
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
protected void dispense(World worldIn, BlockPos pos)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
worldIn.playAuxSFX(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
}
}
}
}
示例2: dispense
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
protected void dispense(World worldIn, BlockPos pos)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int i = tileentitydispenser.getDispenseSlot();
if (i < 0)
{
worldIn.playEvent(1001, pos, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(i, itemstack1.stackSize <= 0 ? null : itemstack1);
}
}
}
}
示例3: dispense
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
/**
* pulled from BlockDispenser
*
* @param worldIn
* @param pos
*/
protected void dispense(World worldIn, BlockPos pos) {
if (this.timeSinceDropped > 0) {
this.timeSinceDropped--;
return;
}
BlockSourceImpl source = new BlockSourceImpl(worldIn, pos);
int i = this.getDispenseSlot(worldIn.rand);
if (i < 0) {
world.playEvent(1001, pos, 0);
this.timeSinceDropped = TIME_BTW_DROPS;
}
else {
ItemStack itemstack = this.getStackInSlot(i);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);
// ModCyclic.logger.info("BEHAVIOR "+ibehaviordispenseitem);
try {
ItemStack result = ibehaviordispenseitem.dispense(source, itemstack);
this.setInventorySlotContents(i, result);
this.timeSinceDropped = TIME_BTW_DROPS;
}
catch (Exception e) {
ModCyclic.logger.error(e.getMessage());
}
}
}
示例4: func_149941_e
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl var5 = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser var6 = (TileEntityDispenser)var5.getBlockTileEntity();
if (var6 != null)
{
int var7 = var6.func_146017_i();
if (var7 < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack var8 = var6.getStackInSlot(var7);
IBehaviorDispenseItem var9 = this.func_149940_a(var8);
if (var9 != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack var10 = var9.dispense(var5, var8);
var6.setInventorySlotContents(var7, var10.stackSize == 0 ? null : var10);
}
}
}
}
示例5: func_149941_e
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.func_146017_i();
if (l < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
IBehaviorDispenseItem ibehaviordispenseitem = this.func_149940_a(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}
}
}
示例6: dispense
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
protected void dispense(World par1World, int par2, int par3, int par4)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(par1World, par2, par3, par4);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.getRandomStackFromInventory();
if (l < 0)
{
par1World.playAuxSFX(1001, par2, par3, par4, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
IBehaviorDispenseItem ibehaviordispenseitem = this.getBehaviorForItemStack(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}
}
}
示例7: callMethod
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException {
if (!Config.enableFlingingTurtle)
throw new LuaException("Flinging turtles have been disabled");
if (arguments.length > 0 && !(arguments[0] instanceof Double))
throw new LuaException("Bad argument #1 (expected number)");
int slot = 1;
int direction;
if (method == 1)
direction = ForgeDirection.DOWN.flag; //Why these are reversed, idk. Dispensers be dum
else if (method == 2)
direction = ForgeDirection.UP.flag;
else
direction = turtle.getDirection();
turtle.getDirection();
if (arguments.length > 0)
slot += (int)(double)(Double)arguments[0];
else
slot = turtle.getSelectedSlot();
synchronized (this) {
ItemStack stack = turtle.getInventory().getStackInSlot(slot);
if (stack != null) {
IBehaviorDispenseItem behavior = (IBehaviorDispenseItem) BlockDispenser.dispenseBehaviorRegistry.getObject(stack.getItem());
if (behavior != IBehaviorDispenseItem.itemDispenseBehaviorProvider) {
BlockSourceTurtle blockSource = new BlockSourceTurtle(direction);
ItemStack newStack = behavior.dispense(blockSource, stack);
turtle.getInventory().setInventorySlotContents(slot, newStack.stackSize == 0 ? null : newStack);
turtle.getInventory().markDirty();
}
}
}
return new Object[0];
}
示例8: func_149941_e
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
public void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null)
{
int l = tileentitydispenser.func_146017_i();
if (l < 0)
{
p_149941_1_.playAuxSFX(1001, p_149941_2_, p_149941_3_, p_149941_4_, 0);
}
else
{
ItemStack itemstack = tileentitydispenser.getStackInSlot(l);
IBehaviorDispenseItem ibehaviordispenseitem = this.func_149940_a(itemstack);
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}
}
}
示例9: dispense
import net.minecraft.dispenser.IBehaviorDispenseItem; //导入方法依赖的package包/类
/** Custom dispense routines */
@Override
protected void dispense(World worldIn, BlockPos pos) {
BlockSourceImpl src = new BlockSourceImpl(worldIn, pos);
TileEntityDispenser tile = (TileEntityDispenser)src.getBlockTileEntity();
if (tile != null) {
int i = tile.getDispenseSlot();
if (i < 0) {
worldIn.playEvent(1001, pos, 0);
} else {
// get the active item from its slot
ItemStack itemstack = tile.getStackInSlot(i);
IBehaviorDispenseItem defaultbehavior = this.getBehavior(itemstack);
// make sure it's not regular dropper behavior
if (defaultbehavior != IBehaviorDispenseItem.DEFAULT_BEHAVIOR) {
ItemStack itemstack1 = null;
// replace vanilla behavior
if(defaultbehavior instanceof BehaviorProjectileDispense) {
itemstack1 = this.dispenseProjectile((BehaviorProjectileDispense)defaultbehavior, src, itemstack);
} else if(itemstack.getItem() instanceof ItemSplashPotion || itemstack.getItem() instanceof ItemLingeringPotion) {
itemstack1 = this.dispensePotion(src, itemstack);
} else if(itemstack.getItem() instanceof ItemFireball) {
itemstack1 = this.dispenseFireball(src, itemstack);
}
// revert to vanilla on failure
if(itemstack1 == null) {
itemstack1 = defaultbehavior.dispense(src, itemstack);
}
// update the inventory
tile.setInventorySlotContents(i, itemstack1.getCount() <= 0 ? ItemStack.EMPTY : itemstack1);
}
}
}
}