Topic category: Help with Minecraft modding (Java Edition)
I use a fairly simple armor procedure that applies an effect when taking damage, but for some reason it works very strangely. The procedure looks like this:
1: When a creature is attacked
2: If the event/target entity 2 armor slot contains (the desired armor piece) and a random number from 1 to 10 inclusive > 8
3: The regeneration effect level 1 is applied for 200 ticks on event/target entity
Now the problem itself. The only thing that works in this procedure is random. The effect is applied, but it doesn't work (it doesn't heal health, but the hearts animate), and when the timer runs out, it's still on the character (while still not working). What am I doing wrong, and what should I add to the procedure?
P.s:Im use MCreator 2023.1
My guess is that it's a client-server desynchronization issue. Which would cause regeneration to be applied on client-side (visual only) 2 of 10 times, and server-side (visual and function) also 2 of 10 times, without necessarily overlapping all the time.
To fix it, my advice would be to put the whole procedure in another if condition, [if[not[is provided world client-side]]]. That way it'll run on server-side only, which can fix several bugs when working with randomization, explosions, and potion effects.