Started by
iMeeTake
on
Topic category: Help with Minecraft modding (Java Edition)
Hi all! I want to make a mod for a backpack that would work through a slot in the Curios API. There were no problems creating the backpack as an item for Curios. How can I make it so that when I press a key, the graphical interface of the backpack that is currently worn opens and so that things are saved in a specific backpack even after closing the GUI?
Edited by iMeeTake on Tue, 09/10/2024 - 18:27
On keybind pressed, check for item in inventory, if = true, then use the open gui procedure. Idk how to check a certain curio slot but if theres no procedure then you can use the trigger in inventory tick. In the gui settings or the inventory slots themselves there should be an option to save items when closed.
I figured out how to make the GUI open only if there is a backpack in a particular slot. At the same time, when I close the GUI, all the objects placed there come back to me. I do not know what to do with it :(
Go to your gui and click on the inventory slots, uncheck the box which says drop items when gui not bound to any external inventory is closed. The gui should be bound to the backpack item, idk how to bind it without having it trigger on right click, you could also have it so the gui opens on right click when in hand and also when key pressed in inventory?
I want the backpack to be opened with a key when it is in the Curios slot. The ability to right-click to open it is not needed... I don't understand how to make different backpacks have separate interfaces from each other and everything work well :(
UPD: if you simply attach a GUI to the backpack and open it using a key with the condition that the backpack is on, objects can be put down, but when you open the backpack again they will not be there
Go to the items advanced properties and bind the item to your backpack gui. Add the number of slots etc. This will make it so the gui and its inventory is bound to the backpack item and the items will save within it. Although this will automatically make it so that when you right click the inventory will open. Idk if theres some way to override this but you could add a trigger to on right clicked to close any open gui. Although when keybind pressed wont open the specific gui bound to the backpack but to a general temporary gui which is why the items either disappear or drop back into your inventory depending on the inventory slots settings.
There might be a way to recognise and store the items through nbt values but you would have to check every slot in the open gui when closing it and re add the items upon opening it again.