i need help with global vars in my mod.

Started by VoidOfTheSkies on

Topic category: Help with modding (Java Edition)

Last seen on 18:17, 22. Aug 2020
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i need help with global vars in my mod.

so, i am making a mod that uses a global var named 'aether', its a number variable that is set by the global session.
the place where it doesent work is when it is meant to check if the var 'aether' is above 0 (but not 0), when this is met, it sets a item in a output slot of a gui. the item always appears in the gui, however the variable does not change, even when i have stated that in will change by -1.

so, i open the gui, and press a button, it then checks if it is next to a certain block. if that is it, then it will reduce the variable by 1 and add a item to the output slot, it works when checking if next to the block, it just doesent change the variable, it just ignores it entirely

 

Do not use GLOBAL_SESSION…
Sat, 08/22/2020 - 18:12

Do not use GLOBAL_SESSION variable. There is only 0.0001% cases where you would want to use this.

Please take a read of this page and make sure you understand all parts: https://mcreator.net/wiki/variables

Also, read https://mcreator.net/wiki/developing-multiplayer-compatible-mods, especially:

Using GLOBAL_SESSION variables

Another important thing to keep in mind is that GLOBAL_SESSION variables are specific per Java runtime instance and as client and world run on different Java runtime instances or even different computers and locations, these two variables will hold different value for each client connected to the server and another different value for the server.

This limits the usability of GLOBAL_SESSION variable type for multiplayer scenarios. If you do not have a good reason to use them, do not.