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