Started by
s_crowe31
on
Topic category: Help with Minecraft modding (Java Edition)
I want to have my armor piece increase my global variable "Energy" by 35 when equipped, however because the procedure is checking for whether the armor is equipped or not every player tick, it is also increasing "Energy" by 35 every player tick. Is there a way around this? Images with code blocks would be helpful, I'm very amateur at this, but any help is much appreciated. Thank you bunches for your time and brainpower!!!
Link to my current code block
https://www.dropbox.com/scl/fi/p2nrllex1naz26b0ixu0k/Screenshot-2024-10…
You need a logic in there. You also dont need the repeat 1 times block. Make a local variable called (on) or something, or make a logic variable or nbt whatever you want.
If armor slot [2] = [custom armour]
If logic (on) = false
set logic (on) = true
set number (Energy) to ([get energy] + 35)
Else if logic (on) = true
set logic (on) = false
set number (Energy) to ([get energy] - 35)
That should only add 35 energy when first putting on the chestplate. Then if they take off the chestplate it will remove the added energy.
Will you be my mentor GOD BLESS YOU! I will try this. I already know it will work oh powerful sensei! Thank you for you enlightening teachings master!
God you're gorgeous
Did I set it up incorrectly? It still increases infinitely?
https://www.dropbox.com/scl/fi/sjqz0xj2voaewkncwepql/423.png?rlkey=gtz0…
To be honest I dont know if a local variable will work. Thats why I said use either local variable, nbt or player variable. Try making a player variable instead of a local one and see if it works then.
You could also do this on item side. Eg make the item do an inventory tick, that way you can use a custom data logic tag instead of needing variables. Like this on tick event:
It may just be a local variable issue.
Also shouldnt your strength stat variable be player persistent? Otherwise everyone has the same and its not linked to any player.