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

  • Author
15 hours ago, diesieben07 said:

EntityPlayer#openContainer to get the currently open Container. Then Container#inventorySlots to get all Slots. Then Slot#getStack to get the ItemStack in that slot.

It doesn't work. It seems to always access the player inventory.

Edited by Codemetry

  • Author
16 hours ago, diesieben07 said:

EntityPlayer#openContainer to get the currently open Container. Then Container#inventorySlots to get all Slots. Then Slot#getStack to get the ItemStack in that slot.

Firstly, EntityPlayer#openContainer is assigned the container of the opened chest AFTER the initialization (GuiScreen#initGui)ย of the opened GuiChest (the container is stored in GuiContainer). So, I changed to try to access the chest contents in InitGuiEvent.Post event handler.

ย 

Secondly, I found that the container stored in GuiContainer is a ContainerChest containing the player inventory AND the chest inventory. Therefore, it is not accurate to access the container and directly get the item stacks via it. Then, I found that ContainerChest#getLowerChestInventory returns the chest inventory (somehow it is called lower inventory).

ย 

Finally, I checked the runtime type of the inventory returned byย ContainerChest#getLowerChestInventory. It turns out to be ContainerLocalMenu. The only place which constructs new ContainerLocalMenus is NetHandlerPlayClient#handleOpenWindow. However, the method accepts a packet that does not store the chest inventory contents.

ย 

Where did I go wrong? How do I access the chest contents?

Edited by Codemetry

  • Author
2 hours ago, diesieben07 said:

Inventory contents are sent later in a separate packet.

Do you know the packet type name?

ย 

Which event should I handle and access the chest contents inside the event handler?

Edited by Codemetry

  • Author
3 minutes ago, diesieben07 said:

Doesn't matter.

ย 

There is no event. The chest contents could change at any point. Please explain what exactly you are trying to achieve.

Read the contents of a chest upon opening, and detect its changes.

I wanted the packet name to check the source code and see if there is any way I can detect.

Edited by Codemetry

  • Author
4 hours ago, diesieben07 said:

There is no better way than to check every tick.

How do I checkย if the chest contents are loaded?

  • Author
8 hours ago, diesieben07 said:

You can't. There is no way to tell client-side whether you are looking at an empty inventory or the contents have not arrived yet.

Thanks for helping me.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.