Jump to content

Recommended Posts

Posted

I'm making a client side mod that doesn't allow you to close chests with certain items in them... however, I've been encountering difficulties in not only finding out when a player opens a chest, but also reading the contents. Here's my code, for reference:

@SubscribeEvent
    public void openChest(PlayerInteractEvent event){
        Minecraft.getMinecraft().player.sendMessage(new TextComponentString(Minecraft.getMinecraft().player.openContainer.toString()));
        if (Minecraft.getMinecraft().player.openContainer instanceof ContainerChest) { // verify that it's really a chest
            ContainerChest chest = (ContainerChest)Minecraft.getMinecraft().player.openContainer; // it's now safe to cast
            IInventory inv = chest.getLowerChestInventory();
            //do things with inv
        }
    }

 

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.