Topic category: Help with Minecraft modding (Java Edition)
Not sure if it's a bug, or if I'm doing something wrong.
So I made two items. Pickaxe and an food item. Pickaxe has a 50% chance to explode after mining a block. However, sometimes the explosion happens only on client side, and not server side (meaning the blocks are still there, but player doesn't see them and there's no sound effect for explosion).
Similaily, food after eating has a 70% chance, to give nausea effect for 1 minute. But sometimes, just like with a pickaxe, the effect is given only on the client side, meaning that if you type /effect @p clear the game responds "Couldn't take any effects from Player as they do not have any", and if you reconnect, the effect is gone.
When I set the chance to 100% on pickaxe, the explosion always happens on both client side and server side (however I noticed a minor desync between which blocks were actually destroyed in explosion on server side).
This is because some procedures are triggered on both server and client-side and chance is calculated for each side separately.
You need to use is remote world procedure block found in world data and only execute your procedure if the world is not remote, as you only want such procedures to be executed on the server-side.
Wrap the whole procedure with if not remote world.
Thank you, it works!
You are welcome, I plan to make a wiki page for this to explaing this to avoid confusion like this in the future.