本文整理汇总了Java中net.minecraftforge.items.wrapper.SidedInvWrapper类的典型用法代码示例。如果您正苦于以下问题:Java SidedInvWrapper类的具体用法?Java SidedInvWrapper怎么用?Java SidedInvWrapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SidedInvWrapper类属于net.minecraftforge.items.wrapper包,在下文中一共展示了SidedInvWrapper类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getItemHandler
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
public static IItemHandler getItemHandler(World world, BlockPos pos, EnumFacing side, boolean includeEntities) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof IDrawer) {
return new DrawerWrapper((IDrawer) te);
} else if (te instanceof IDrawerGroup) {
return new DrawerGroupWrapper((IDrawerGroup) te);
} else if (te == null || !te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side)) {
IInventory inv = includeEntities ? TileEntityHopper.getInventoryAtPosition(world, pos.getX(), pos.getY(), pos.getZ()) : (te instanceof IInventory ? (IInventory) te : null);
if (inv != null) {
if (inv instanceof ISidedInventory) {
return new SidedInvWrapper((ISidedInventory) inv, side);
} else {
return new InvWrapper(inv);
}
} else
return null;
} else {
return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
}
}
示例2: getCapability
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
if (!getStack().isEmpty() && capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY && facing == EnumFacing.DOWN) {
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(new SidedInvWrapper(this, facing));
}
return super.getCapability(capability, facing);
}
示例3: getItemHandlerCap
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
@Deprecated
public static IItemHandler getItemHandlerCap(TileEntity tileEntity, EnumFacing face) {
if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, face)) {
return tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, face);
} else if (tileEntity instanceof ISidedInventory && face != null) {
return new SidedInvWrapper(((ISidedInventory) tileEntity), face);
} else if (tileEntity instanceof IInventory) {
return new InvWrapper(((IInventory) tileEntity));
}
return new EmptyHandler();
}
示例4: getItemHandler_Raw
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
/**
* Grabs the IItemHandler capability for the tile,
* Will wrap if the cap doesnt exist, If you care about only interacting with the cap,
* Then use {@link #hasItemHandler_Raw} to check if the tile only has the cap before calling.
*
* @param tile The tile.
* @param face The face.
* @return The handler, wrapped if the tile uses legacy interfaces and no cap.
*/
public static IItemHandler getItemHandler_Raw(TileEntity tile, EnumFacing face) {
if (hasItemHandler(tile, face)) {
if (hasItemHandler_Raw(tile, face)) {
return tile.getCapability(ITEM_HANDLER, face);
} else {
if (tile instanceof ISidedInventory && face != null) {
return new SidedInvWrapper((ISidedInventory) tile, face);
} else {
return new InvWrapper((IInventory) tile);
}
}
}
return null;
}
示例5: makeInvWrapper
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
/** Create six inventory wrappers for each inventory */
public static SidedInvWrapper[] makeInvWrapper(ISidedInventory inv) {
SidedInvWrapper[] wrapper = new SidedInvWrapper[6];
for(int i = 0; i < 6; i++) {
wrapper[i] = new SidedInvWrapper(inv, EnumFacing.getFront(i));
}
return wrapper;
}
示例6: getCapability
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
@Override
@Nonnull
public <T> T getCapability(@Nonnull Capability<T> capability, @Nonnull EnumFacing facing) {
if (capability == CapabilityEnergy.ENERGY)
return CapabilityEnergy.ENERGY.cast(this);
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY)
return (T) new SidedInvWrapper(this, facing);
return super.getCapability(capability, facing);
}
示例7: tryGetHandler
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
public static IItemHandler tryGetHandler(TileEntity te, EnumFacing side) {
if (te == null) return null;
if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side))
return te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side);
if (te instanceof ISidedInventory)
return new SidedInvWrapper((ISidedInventory)te, side);
if (te instanceof IInventory)
return new InvWrapper((IInventory)te);
return null;
}
示例8: getInventoryWrapper
import net.minecraftforge.items.wrapper.SidedInvWrapper; //导入依赖的package包/类
protected SidedInvWrapper getInventoryWrapper(EnumFacing side)
{
if (!this.inventoryWrapperCache.containsKey(side))
this.inventoryWrapperCache.put(side, new SidedInvWrapper(this, side));
return this.inventoryWrapperCache.get(side);
}