Started by
TalkingScribe
on
Topic category: Help with Minecraft modding (Java Edition)
OK, so I basically have this
If random(0,1) < 0.2
spawn a bunch of particles
do a bunch of other stuff
End
If the random number is < 0.2, then all the "other stuff" works just fine.
The particles work as intended 20% of the time. But that 20% bares no relation to the random number being generated.
If I change the comparison number to something else, for example 0.5, the particles still work as often as they should (50% of the time) but it's as if they have a separate number they are checking against.
I figured it out.
And for any future people who come across this, here's what happened:
The client and the server run the procedure separately, so you get different random numbers on each side. The particles are possessed client side and the "other stuff" (in this case damage and setting mobs on fire) is possessed server side. Using a global variable helped, since they are synced from the server to the client, but required a delay in the server side parts because it doesn't sync until after the procedure is done running.
The final procedure ended up looking like this
https://i.imgur.com/c9LO6r4.png
If anyone knows of an easier or cleaner way to do this, please chime in.