Started by
Lilyofluck
on
Topic category: Help with MCreator software
I'm trying to make a wand and magic system where you can cast spells with a right click and change the spells you can cast by crouching and right-clicking. The problem is GUI opens whenever I right-click and hold the wand (Because the GUI is linked to the item). I don't know if I can change how I can open GUIs.
We can close any open GUI whenever you right-click unless you are crouching. Though, if anyone has a better way I would greatly appreciate
It would take custom code to do this, it is easy though. I hope mcreator adds options like these in the future.
I have done things similar to this in some of my mods. You have to add this line of code in a certain spot so it only opens the bound inventory when the player is/isn't sneaking.
Open your WandItemNameItem.java file in the editor.
Step 1: Find the below class.
In this class change one line of code.
Step 2: Change this line
To this if you want it to open when they aren't pressing shift
Example 1:
Or this if you want it to open when they are pressing shift
Example 2:
Just make sure to do this when you are done creating the item!
Step 3: In Spell Cast Procedure, check for the opposite of above
For example: If you want your inventory to only open when you are sneaking use the second example. Then in your Spell Casting procedure, check if the entity is not sneaking before the rest of your procedure.
I just tested this is in a test pack and it works fine. Alternatively you could edit the gui but the item is much easier as it is just one line of code and you could literally copy and paste it from right here into that spot.
In the procedure for the wand casting, put an if block that checks if the player is crouching (There is a block that checks for this)
If they ARE crouching, open the GUI.
If not, then cast the current spell.
Mr_Arrhythmia that won't bind the gui to the item though, the way I described does, so it will keep items in their slots if he is using items.
Well, I already save the items in the GUI in NBT tags so I can check if they are the right item (To cast a spell). So the one up top could work. Thanks for the info though. MCreator definitely needs the ability to specify when to open GUIs.