本文整理汇总了Java中net.minecraft.tileentity.IHopper类的典型用法代码示例。如果您正苦于以下问题:Java IHopper类的具体用法?Java IHopper怎么用?Java IHopper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IHopper类属于net.minecraft.tileentity包,在下文中一共展示了IHopper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: extractHook
import net.minecraft.tileentity.IHopper; //导入依赖的package包/类
public static Boolean extractHook(IHopper dest)
{
TileEntity tileEntity = dest.getWorld().getTileEntity(new BlockPos(dest.getXPos(), dest.getYPos() + 1, dest.getZPos()));
if (tileEntity == null || !tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN))
return null;
IItemHandler handler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN);
for (int i = 0; i < handler.getSlots(); i++)
{
ItemStack extractItem = handler.extractItem(i, 1, true);
if (extractItem != null)
{
for (int j = 0; j < dest.getSizeInventory(); j++)
{
ItemStack destStack = dest.getStackInSlot(j);
if (dest.isItemValidForSlot(j, extractItem) && (destStack == null || destStack.stackSize < destStack.getMaxStackSize() && destStack.stackSize < dest.getInventoryStackLimit() && ItemHandlerHelper.canItemStacksStack(extractItem, destStack)))
{
extractItem = handler.extractItem(i, 1, false);
if (destStack == null)
dest.setInventorySlotContents(j, extractItem);
else
{
destStack.stackSize++;
dest.setInventorySlotContents(j, destStack);
}
dest.markDirty();
return true;
}
}
}
}
return false;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:VanillaInventoryCodeHooks.java
示例2: insertHook
import net.minecraft.tileentity.IHopper; //导入依赖的package包/类
public static boolean insertHook(IHopper hopper, EnumFacing facing)
{
TileEntity tileEntity = hopper.getWorld().getTileEntity(
new BlockPos(hopper.getXPos(), hopper.getYPos(), hopper.getZPos()).offset(facing));
if (tileEntity == null)
return false;
if (!tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()))
return false;
IItemHandler handler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());
for (int i = 0; i < hopper.getSizeInventory(); i++)
{
ItemStack stackInSlot = hopper.getStackInSlot(i);
if (stackInSlot != null)
{
ItemStack insert = stackInSlot.copy();
insert.stackSize = 1;
ItemStack newStack = ItemHandlerHelper.insertItem(handler, insert, true);
if (newStack == null || newStack.stackSize == 0)
{
ItemHandlerHelper.insertItem(handler, hopper.decrStackSize(i, 1), false);
hopper.markDirty();
return true;
}
}
}
return true;
}
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:VanillaInventoryCodeHooks.java
示例3: getInputInventory
import net.minecraft.tileentity.IHopper; //导入依赖的package包/类
@Override
public Inventory getInputInventory() {
return (Inventory) TileEntityHopper.getHopperInventory((IHopper) this);
}
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:5,代码来源:MixinTileEntityHopper.java
注:本文中的net.minecraft.tileentity.IHopper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论