(SOLVED) How to connect textfield from the GUI to variables

Started by ImSeyo on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
(SOLVED) How to connect textfield from the GUI to variables
Sun, 07/16/2023 - 14:45 (edited)

Set the health of the mob depending on the numbers in the textfield from the GUI

I tried to make sure that if I write any number in the textfield in GUI, then this number will be applied to the health of the mob when it first appears. That is, if I write a value of 100 in the textfield, then the mob will have 100 hp. The problem is that no matter how I tried to solve it, I got an error. None of the procedures worked. Does anyone know how to solve this?

Edited by ImSeyo on Sun, 07/16/2023 - 14:45
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
No matter, I figured it out,…
Sun, 07/16/2023 - 14:45

No matter, I figured it out, it turns out it was so easy! It was necessary to insert not only a textfield into GUI, but also a button. Then it was necessary to create the procedure "set (event/target) custom number NBT tag (your Tag) to Number from text Get text inside textfield (yourTextfieldName)". After you have created this procedure, put it in the button and that's it! To make sure that it worked, you need to do any verification using your NBT tag