Saving item to a slot in GUI

Started by Jomst0r on

Topic category: Help with modding (Java Edition)

Last seen on 14:45, 28. Jun 2024
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Saving item to a slot in GUI

I've tried checking the forum before, but the ideas simply don't work.

I'm trying to add an Arc-Reactor slot to a GUI, that is done, it also saves to a global variable, but it does not load it into the slot with the "Open GUI" function that I have added.

I've been at this for hours not being able to figure it out, please help

Last seen on 17:01, 18. Jul 2024
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've also had trouble with…
Wed, 06/19/2024 - 14:02

I've also had trouble with the "Open GUI" trigger combined with "put this in that slot of the GUI"; I suspect that because the GUI isn't actually open yet, there's no slot to put the block in.

I was intending to try and put a delay, so it's "after opening, in X ticks, put this thing here", because the GUI should be there by then.  Or, if that didn't work, circumvent the "Open GUI" trigger entirely, by having a tick event (item, block, whatever) that goes "If this GUI is open and this variable is X, put this here, then change that variable to Y", which is...  not efficient, but hey.

Haven't got around to attempting these, though, so I'm not certain what'll work - but some possibilities, anyway.

Last seen on 14:45, 28. Jun 2024
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have tried with a delay,…
Thu, 06/20/2024 - 13:59

I have tried with a delay, didn't really seem to work.
I don't know if that has something to do with my code that saves the item to a variable or not but eh ¯\_(ツ)_/¯

Last seen on 11:12, 13. Jul 2024
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can confirm doing it on …
Thu, 06/20/2024 - 14:14

Can confirm doing it on "while GUI open" works fine for me

Last seen on 14:45, 28. Jun 2024
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A have a sad suspicion that…
Mon, 06/24/2024 - 09:06

A have a sad suspicion that it is because you cannot save the item in a slot to a global variable when you close the GUI.

Last seen on 03:53, 25. Sep 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The way i found that works…
Mon, 06/24/2024 - 16:02

The way i found that works for me is to Create a procedure that "Saves" the item you want in the slot as a String NBT for whatever the GUI is attached to and this same procedure will also set a Logic NBT to True (IE if you have a different "String" for each item that goes into that slot and when the save procedure activates it sets the NBT to that String and logic to True to show that the GUI has a bound item). Then you use a procedure to set the NBT data of that item to "None" when the GUI is opened ONLY IF the Logic value is False. Then on GUI tick update create a procedure that IF Logic NBT is True then set Item in slot based on the String NBT data.