Started by
Ch336ico
on
Topic category: Help with Minecraft modding (Java Edition)
The local variables resets once the procedure run again? For example, I have a local variable of an entity that get the entity that I hit in the procedure "When living entity is hit with tool", everytime I do a new hit in the same entity the variable resets?
Correct, the variable is reset after every trigger.The variable only exists in that instance of the procedure. it also causes it so that the procedure can run multiple times at once and still be separate variables. When the procedure finishes, the variable is now nonexistant until the procedure is recalled since it only exists inside that one procedure .
To not do this. make a global variable.
-PixelKid
Thanks again! You are salving my life ngl, but how do I do a global variable of an entity if there is no entity type variables in the global section?
Currently there is no direct support for that, but the best workaround is to create a string variable and store entity data plus variable in it. Like: entityiszombie_variable, but i don't know how well this will work.
I haven't done this so I can't help to much in this.
-PixelKid
Alr I will try, thx
Sorry for not thinking of this sooner, But I just realized that you can assign NBT tags to an entity. I haven't really done this before. The way to do it is put the variable inside the NBT tag and add it to the entity.
To see if it has the TAG, do :
if entity had _ NBT tag
then: _
to change:
remove _NBT tag of entity
add _ NBT tag to entity
Hope I helped! PixelKid