Desync between server side and client side when using random chance.

Started by Kuba4ful on

Topic category: Help with modding (Java Edition)

Last seen on 13:26, 1. Oct 2022
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Desync between server side and client side when using random chance.

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…
Sat, 09/14/2019 - 11:29

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.

Last seen on 13:26, 1. Oct 2022
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you, it works!
Mon, 09/16/2019 - 10:58

Thank you, it works!

You are welcome, I plan to…
Mon, 09/16/2019 - 11:14

You are welcome, I plan to make a wiki page for this to explaing this to avoid confusion like this in the future.