Search in sources :

Example 1 with DualItemHandlerGui

use of com.almuradev.almura.shared.network.handler.DualItemHandlerGui 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"));
}
Also used : MultiSlotTileEntity(com.almuradev.almura.shared.tileentity.MultiSlotTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) DualItemHandlerGui(com.almuradev.almura.shared.network.handler.DualItemHandlerGui) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IItemHandler(net.minecraftforge.items.IItemHandler) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) MultiSlotTileEntity(com.almuradev.almura.shared.tileentity.MultiSlotTileEntity) TextComponentString(net.minecraft.util.text.TextComponentString) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nullable(javax.annotation.Nullable)

Aggregations

DualItemHandlerGui (com.almuradev.almura.shared.network.handler.DualItemHandlerGui)1 MultiSlotTileEntity (com.almuradev.almura.shared.tileentity.MultiSlotTileEntity)1 Nullable (javax.annotation.Nullable)1 Block (net.minecraft.block.Block)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 IItemHandler (net.minecraftforge.items.IItemHandler)1