Topic category: Help with Minecraft modding (Java Edition)
Hello everyone,
I’m working on a mod in MCreator 2026.2 and I’ve created a custom system called Soul Energy. I already have the variable working correctly and it updates properly in procedures.
However, I’m stuck on one specific issue:
I don’t know how to display this variable inside a GUI text element so that it updates dynamically for the player.
What I want to achieve is something like this in the GUI:
https://i.imgur.com/GtAs2lc.png
And this is how my variable is currently set up:
https://i.imgur.com/4dSAE4s.png
What is the correct way in MCreator 2026.2 to:
- correctly read a player persistent variable (like soul_energy)
- and display it inside a GUI label/text element
- while keeping it updating in real time?
I tried looking for “get variable” blocks in procedures and GUI text settings, but I can’t find a working way to directly insert the variable into the text.
Any help or example setup would be really appreciated.
Thank you in advance!
The way you can do this is create an overlay or GUI and make a text label. Then set the text provider to a procedure that returns the variable. If the variable is a number you will have to use the "number to string" block. Thus, an automatically updating display of the variable.
Hope this helps!
Could you be a bit more specific? I'm new to this and don't really understand how to do it. A step-by-step explanation would help me a lot. Thanks!
I don't have access to a computer at the moment so I can't give you a detailed explanation, but basically, create a new procedure, go to the Flow Control tab, and put a "return text" block. Then go to the custom variables tab and grab a "get custom variable [variable name, e.g. soulEnergy]" block. Next you have to convert the number into a string. Either search up "convert number" or I think it's in either the Math or Text tabs. Plug the variable block into that, and that whole thing into the return block.
Step 1 is now complete. Step 2 is actually making the display. Create a new Overlay element. Name it SoulEnergyDisplay or something like that. Inside of it, create a new Text label. In the creation menu, you should see a text box, and next to it a drop-down with "Fixed:" or something like that. Click on that, and select the procedure you just made. You can customize the color of the text, and then click "add" or "save" or really whatever the green confirm button says on the edit window.
Save the overlay, and you now have a simple soul energy display overlay that will show your current energy. You can add additional text labels so it says like "Soul Energy: X" rather than just X.
I hope this helps!