Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

PROBLEM DESCRIPTION :

Hello, I was thinking of a fun algorithm ! I try to detect if there's items in a Chest and if there's items in it I should be able to display them in the chat. I putted 1 apple in each slots of the chest but it still say the message "empty" idk why

 

THE CODE :

 public void onEvent(Event e) {
        if (e instanceof EventUpdate) { 
               
            if (e.isPre()) {
                
                 for (Object o : mc.theWorld.loadedTileEntityList) {
                    if (o instanceof TileEntityChest && mc.currentScreen instanceof GuiChest) { // If this is a Chest and If we are on the chest inventory
                        TileEntityChest chest = (TileEntityChest) o;
                        
                        mc.thePlayer.sendChatMessage("Found chest at " + chest.getPos().getX() + ", " + chest.getPos().getY() + ", " + chest.getPos().getZ());
                        
                        for (int i = 0; i < chest.getSizeInventory(); i++) {
                            ItemStack itemStack = chest.getStackInSlot(i); // Returns the stack in slot i
                            if (itemStack != null && itemStack.stackSize > 0) {
                                String itemName = itemStack.getDisplayName();
                                mc.thePlayer.sendChatMessage("Slot " + i + ": " + itemName);
                            } else {
                                mc.thePlayer.sendChatMessage("Slot " + i + ": Empty");
                            }
                        }
                    }
                } 
                
        }
        
    }
    
}

WHAT I'VE TRIED/WHAT I KNOW :

To detect the Chest and you see that there's the chest Coords in the chat

To detect the slots and It displays all the slots (27) but no element in it (that's the problem)

 

The version you are using is no longer supported on this forum.

Please update to a modern version of Minecraft to receive support.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Guest
This topic is now closed to further replies.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.