Started by
pondu
on
Topic category: Help with Minecraft modding (Java Edition)
Even after the tick ends, the potion effect remains. If you use it again, it will overlap. What should I do? How do I set the limit for the potion effect?
https://imgur.com/S9AGh4h
Edited by pondu on Tue, 09/12/2023 - 00:53
You could use 3 integers instead of 2 (ie. 0, 1)
This way 0 = active
1 = inactive
2 = inactive but potion effect applied.
also only set the nbt tag "1" to 0 when its 2 or 0
You could use 3 integers instead of 2 (ie. 0, 1)
This way 0 = active
1 = inactive
2 = inactive but potion effect applied.
also only set the nbt tag "1" to 0 when its 2 or 0
Psedo code:
Acual code:
You could do rusty's method or you can keep yours like my image below
Just replace effect with yours. then change nbt tag to whatever you want, I do recommend using something longer then "1" to not run the risk of mods doing the same nbt.
And then keep how you have your armor with armor value, just remove the extras. Unneeded. I used a local variable to help mimic your setup as I don't have the armor thing you have.
@SkylieTuff The effect would still stack since your constantly applying the operations on the variables which changed.
The result of this and the initial code hasn't changed
The metjod you've used is literally used to do incremental changes. Its used to make the operations performed STACK
Basically:
This is the same as
The code will store the changes in the same variable that it'll later chnage AGAIN.
Its like you store some boxes in your house. Later when you deposit more you aren't RESETTING the #boxes you're merely ADDING MORE TO THE CURRENT AMOUNT
the new value is #boxes + x
since you're storing in the same house you're constantly adding the boxes without reseting them.
The code doesn't know wether it has to stop changing/incrementing the variable until you tell it to.
@rusty it wasn't for you & if you read, I used variables to make a monicker for op. But I also realize what he wants and I could give him a ten times better solution. Lol. If he wants one. And I just used his solution and removed some things and change things because I was too tired to realize what op was wanting when I did it.