Independent GUI (without block or item) deletes item when closing inventory.

Started by Computer Chip on

Topic category: Help with modding (Java Edition)

Last seen on 23:01, 18. Apr 2024
Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Independent GUI (without block or item) deletes item when closing inventory.

I'm making a new GUI that has no block or item connected to it, just a keybind. Essentially just a second inventory for the player to have but with only two slots. Every time I place an item in either of the slots, as soon as I close it and reopen it, the item has disappeared into thin air. I was curious to know if anyone has a solution because all the other tutorials I have found have proven to be either outdated or have an item or block as a source for the inventory. Is there a way to add an inventory to an independent GUI?

Not bounding a GUI to…
Mon, 01/09/2023 - 04:30

Not bounding a GUI to something is simply making it a screen. In your case, as you only have 2 slots, you can save both slots inside 2 player global vars when the GUI is closed and when you re-open it, you set the itemstack back inside both slots.