Search in sources :

Example 1 with DualItemHandlerContainer

use of com.almuradev.almura.shared.inventory.DualItemHandlerContainer 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);
}
Also used : MultiSlotTileEntity(com.almuradev.almura.shared.tileentity.MultiSlotTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) IItemHandler(net.minecraftforge.items.IItemHandler) BlockPos(net.minecraft.util.math.BlockPos) DualItemHandlerContainer(com.almuradev.almura.shared.inventory.DualItemHandlerContainer) MultiSlotTileEntity(com.almuradev.almura.shared.tileentity.MultiSlotTileEntity) Nullable(javax.annotation.Nullable)

Aggregations

DualItemHandlerContainer (com.almuradev.almura.shared.inventory.DualItemHandlerContainer)1 MultiSlotTileEntity (com.almuradev.almura.shared.tileentity.MultiSlotTileEntity)1 Nullable (javax.annotation.Nullable)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 IItemHandler (net.minecraftforge.items.IItemHandler)1