Started by
mike98
on
Topic category: Troubleshooting, bugs, and solutions
Hi, I think I found a bug. The "block added" trigger executes its code twice every time a block is placed. You can easily test it by creating a procedure which adds 1 to the counter every time code gets executed. I did it, and every time a place down a block, the counter value increases by 2.
Welcome to the world of client and server-side. Both sides execute procedures.
Check https://mcreator.net/wiki/developing-multiplayer-compatible-mods
I found a way to work round it.
1. Create a global variable "counter", type: "number, scope: "global_map", set initial value to 0
2. Structure your procedure in the following way:
IF (get global: "counter") = 1
DO (set global: "counter") to 0
ELSE IF (get global: "counter") = 0
DO put your code here & (set global: "counter") to 1
So what it does is during the first run it will execute your code, and during the second run it will only set the "counter" to 0. Hope someone will find this helpful.
Very interesting, thank you for the link. I wish I found it yesterday, it would have saved me a lot of time hah It's all clear now! :)
Actually... sorry for spamming but I've just tried using the "if NOT Is provided world remote (client-side)" and my code still executes twice. Am I still missing something?
I figured it out
If [is provided world remote (client side)] = true
Do put your code here
Nvm, I thought I had it working. I'll just stick to my "counter" method for now