Search in sources :

Example 1 with MultiSlotTileEntity

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"));
}
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)

Example 2 with MultiSlotTileEntity

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);
}
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)

Example 3 with MultiSlotTileEntity

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;
}
Also used : MultiSlotItemHandler(com.almuradev.almura.shared.capability.impl.MultiSlotItemHandler) IMultiSlotItemHandler(com.almuradev.almura.shared.capability.IMultiSlotItemHandler) MultiSlotTileEntity(com.almuradev.almura.shared.tileentity.MultiSlotTileEntity) IMultiSlotItemHandler(com.almuradev.almura.shared.capability.IMultiSlotItemHandler) Nullable(javax.annotation.Nullable)

Aggregations

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