how to make a gui that binds to an item

Started by Cevvity on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how to make a gui that binds to an item

I'm trying to make a gui that binds to an item so it doesn't clear the items when I close it and reopen it and I think it has something to do with player-persistent variables. Any ideas?

 

(By the way, I'm using the fabric generator plugin)

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm not 100% familiar with…
Wed, 01/17/2024 - 12:46

I'm not 100% familiar with the fabric generator, though I assume it's fairly similar. The trouble with making a GUI linked to an item is that MCreator's GUI system is mainly designed for block entities, (chests, blocks with inventories, etc), so an item GUI is more difficult, (if not impossible.) You're on the right track with player-persistent variables.

Essentially, you would need to make a player persistent itemstack variable for each slot of the GUI, and possibly player persistent number variables to save the number of items in each slot. Whenever the GUI is opened, you would have a procedure set the items from these variables in each slot, and whenever it's closed, you would clear each slot. (And make sure the items don't automatically return to the player's inventory.) You would then need an additional procedure to update the correct variable whenever an item is added or removed from a slot. From there, use the 'player right clicks with item' trigger to open the GUI. Again, not sure how well this method will work, and it'll definitely get redundant if you have a lot of slots to keep track of, (MCreator doesn't really support struct variables), but worth a shot.

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
thanks!
Thu, 01/18/2024 - 23:16

thanks!