package me.km.inventory; import me.km.snuviscript.SnuviInventory; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.ClickType; import net.minecraft.inventory.ContainerChest; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.network.play.server.SPacketOpenWindow; public class CustomContainer extends ContainerChest { public CustomContainer(String title, int slotCount, EntityPlayer p) { super(p.inventory, new EntityInventory(title, slotCount, p), p); } public CustomContainer(SnuviInventory inv, EntityPlayer p) { super(p.inventory, inv, p); } public EntityInventory getShownInventory() { return (EntityInventory) this.getLowerChestInventory(); } public void openForPlayer(EntityPlayerMP p) { if(p.openContainer != p.inventoryContainer) { p.closeScreen(); } p.getNextWindowId(); IInventory inv = this.getLowerChestInventory(); p.connection.sendPacket(new SPacketOpenWindow(p.currentWindowId, "minecraft:container", inv.getDisplayName(), inv.getSizeInventory())); p.openContainer = this; p.openContainer.windowId = p.currentWindowId; p.openContainer.addListener(p); } public boolean noClicking(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { return true; } @Override public final ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { if(noClicking(slotId, dragType, clickTypeIn, player)) { onCanceledClick(slotId, dragType, clickTypeIn, player); return ItemStack.EMPTY; } return super.slotClick(slotId, dragType, clickTypeIn, player); } public void onCanceledClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) { } }