use of com.almuradev.almura.shared.tileentity.MultiSlotTileEntity in project Almura by AlmuraDev.
the class CapabilityDualItemHandlerGuiHandler method getClientGuiElement.
@SideOnly(Side.CLIENT)
@Nullable
@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
final BlockPos pos = new BlockPos(x, y, z);
final Block block = world.getBlockState(pos).getBlock();
final TileEntity te = world.getTileEntity(pos);
if (te == null || !(te instanceof MultiSlotTileEntity)) {
return null;
}
final IItemHandler teItemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (teItemHandler == null) {
return null;
}
final IItemHandler playerItemHandler = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (playerItemHandler == null) {
return null;
}
return new DualItemHandlerGui(teItemHandler, playerItemHandler, new TextComponentString(block.getLocalizedName()), new TextComponentTranslation("container.inventory"));
}
use of com.almuradev.almura.shared.tileentity.MultiSlotTileEntity in project Almura by AlmuraDev.
the class CapabilityDualItemHandlerGuiHandler method getServerGuiElement.
@Nullable
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
final TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
if (te == null || !(te instanceof MultiSlotTileEntity)) {
return null;
}
final IItemHandler teItemHandler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (teItemHandler == null) {
return null;
}
final IItemHandler playerItemHandler = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (playerItemHandler == null) {
return null;
}
return new DualItemHandlerContainer(teItemHandler, playerItemHandler);
}
use of com.almuradev.almura.shared.tileentity.MultiSlotTileEntity in project Almura by AlmuraDev.
the class StorageBlock method createNewTileEntity.
@Nullable
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
final MultiSlotTileEntity mte = new MultiSlotTileEntity();
final IMultiSlotItemHandler itemHandler = (MultiSlotItemHandler) mte.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (this.slotAmount > itemHandler.getSlots()) {
itemHandler.resize(this.slotAmount);
}
return mte;
}
Aggregations