Topic category: User side tutorials
Before you begin, make sure that:
1)your procedure is completely written and will not change dependencies after synchronization is performed
2)Your gui is completely ready to work and does not require additional changes, since its code will be locked
3)you have at least one button that runs a procedure that reads the text of the text field
Steps
1)lock code of your GUI
2)open <your gui name>Screen.java class
3)find 2 lines of code starting with:
PacketDistributor
<your gui name >ButtonMessage
and add after the coordinates <your textbox name >.getValue()
4)save <guiname>Screen.java file and open <guiname>ButtonMessage.java
5)in the button network package, after each line with coordinate information (Int), add information about the text in your text field (String / Utf {for buffer }) in the same way as the line with coordinates, replacing only the names and data type
6) save <guiname>ButtonMessage.java (network packet) and open your procedure in blockly
7)replace broken block "get text inside textfield" to your custom text dependency of String <dependency> = <textboxname>
8)save procedure and check result on server
NOTE
1)In version 1.20.1 mcreator 2023.4 the names of the lines of code are slightly different, but if you can basicly understand the code and add a string near the int, you can do this on version 1.20.1
2)I don’t know Java at all and I don’t know how to program, I discovered this completely by accident while experimenting with the network package and it may not work on some versions, and I haven’t tried fabric
oops, I probably posted this in the wrong section...
if in PacketDistributor.SERVER.noArg().send(new TestsyncButtonMessage(0, x, y, z, textbox.getValue()));
TestsyncButtonMessage.handleButtonAction(entity, 0, x, y, z, textbox.getValue());
you don’t have 0, but 1 2, etc., this is normal, this is the ID of your buttons, you need to find your button among them, this can be found in the button message network package, each digit corresponds to the procedure
Moved the topic category, no problem :)
hmmmphmmm.... Step one..... Step one........ Hmmphpmmmm... Oh my brain
@151chit Thank you very much for this tutorial.
I took the liberty of making a tutorial video on my Youtube channel (In French):
https://www.youtube.com/watch?v=sN9mlpU7MeI&lc=Ugybp_ZG-R9cQFL8dnJ4AaABAg
And in my series on creating plugins for MCreator, I will show how to transform it into a plugin.
I wrote a plugin for Minecraft versions 1.20.1 forge and 1.20.4 neoforge, which does this automatically with an arbitrary number of text fields and with support for the trigger “every tick while the gui is open”, with the addition of a new block of procedures for reading text fields for the server: https://mcreator.net/plugin/107077/text-fields-synchronizer