本文整理匯總了Java中net.minecraft.tileentity.TileEntityHopper.insertStack方法的典型用法代碼示例。如果您正苦於以下問題:Java TileEntityHopper.insertStack方法的具體用法?Java TileEntityHopper.insertStack怎麽用?Java TileEntityHopper.insertStack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.tileentity.TileEntityHopper
的用法示例。
在下文中一共展示了TileEntityHopper.insertStack方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: dispense
import net.minecraft.tileentity.TileEntityHopper; //導入方法依賴的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);
int i1 = par1World.getBlockMetadata(par2, par3, par4) & 7;
IInventory iinventory = TileEntityHopper.getInventoryAtLocation(par1World, (double)(par2 + Facing.offsetsXForSide[i1]), (double)(par3 + Facing.offsetsYForSide[i1]), (double)(par4 + Facing.offsetsZForSide[i1]));
ItemStack itemstack1;
if (iinventory != null)
{
itemstack1 = TileEntityHopper.insertStack(iinventory, itemstack.copy().splitStack(1), Facing.oppositeSide[i1]);
if (itemstack1 == null)
{
itemstack1 = itemstack.copy();
if (--itemstack1.stackSize == 0)
{
itemstack1 = null;
}
}
else
{
itemstack1 = itemstack.copy();
}
}
else
{
itemstack1 = this.dropperDefaultBehaviour.dispense(blocksourceimpl, itemstack);
if (itemstack1 != null && itemstack1.stackSize == 0)
{
itemstack1 = null;
}
}
tileentitydispenser.setInventorySlotContents(l, itemstack1);
}
}
}