net.minecraft.world.ILockableContainer Java Examples

The following examples show how to use net.minecraft.world.ILockableContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CraftInventoryDoubleChest.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) {
    super(new InventoryLargeChest("Large chest", (ILockableContainer) left.getInventory(), (ILockableContainer) right.getInventory()));
    this.left = left;
    this.right = right;
}
 
Example #2
Source File: TileRequest.java    From HoloInventory with MIT License 4 votes vote down vote up
@Override
public ResponseMessage onMessage(TileRequest message, MessageContext ctx)
{
    World world = DimensionManager.getWorld(message.dim);
    if (world == null) return null;
    TileEntity te = world.getTileEntity(message.pos);
    if (te == null) return null;

    if (Helper.banned.contains(te.getClass().getCanonicalName())) return null;
    if (te instanceof ILockableContainer && !ctx.getServerHandler().player.canOpen(((ILockableContainer) te).getLockCode())) return null;

    if (te instanceof TileEntityEnderChest)
    {
        return new PlainInventory(message.pos, ctx.getServerHandler().player.getInventoryEnderChest());
    }
    else if (te instanceof BlockJukebox.TileEntityJukebox)
    {
        InventoryBasic ib = new InventoryBasic("minecraft:jukebox", false, 1);
        ib.setInventorySlotContents(0, ((BlockJukebox.TileEntityJukebox) te).getRecord());
        return new PlainInventory(message.pos, ib).setName(Blocks.JUKEBOX.getUnlocalizedName());
    }
    else if (te instanceof TileEntityChest)
    {
        Block b = world.getBlockState(message.pos).getBlock();
        if (b instanceof BlockChest)
        {
            IInventory i = ((BlockChest) b).getLockableContainer(world, message.pos);
            if (i != null) return new PlainInventory(message.pos, i);
            return null;
        }
        return new PlainInventory(message.pos, ((TileEntityChest) te));
    }
    else if (te instanceof IInventory)
    {
        return new PlainInventory(message.pos, (IInventory) te);
    }
    else if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null))
    {
        IItemHandler iih = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
        if (iih == null)
        {
            HoloInventory.getLogger().warn("Error: Block at {} (Class: {} Te: {} Block: {}) returned null after indicating the capability is available.", message.pos, te.getClass().getName(), te, te.getBlockType());
            return null;
        }
        if (te instanceof INamedItemHandler) {
        	INamedItemHandler namedHandler = (INamedItemHandler) te;
        	return new PlainInventory(message.pos, namedHandler.getItemHandlerName(), iih);
        }
        return new PlainInventory(message.pos, te.getBlockType().getUnlocalizedName(), iih);
    }

    return null;
}