"Block added" trigger bug

Started by mike98 on Tue, 08/18/2020 - 18:04

Topic category: Bugs and solutions

Last seen on 18:31, 19. Aug 2020
Joined Feb 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
"Block added" trigger bug
Tue, 08/18/2020 - 18:04

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.

Last seen on 19:03, 24. Oct 2020
Joined Apr 2010
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Hi, I think I found a bug…
Tue, 08/18/2020 - 18:58

Hi, I think I found a bug. The "block added" trigger executes its code twice every time a block is placed.

Welcome to the world of client and server-side. Both sides execute procedures.

Check https://mcreator.net/wiki/developing-multiplayer-compatible-mods

Last seen on 18:31, 19. Aug 2020
Joined Feb 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I found a way to work round…
Tue, 08/18/2020 - 19:02

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.

 Mcreator code

Last seen on 18:31, 19. Aug 2020
Joined Feb 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Very interesting, thank you…
Tue, 08/18/2020 - 19:11

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! :)

Last seen on 18:31, 19. Aug 2020
Joined Feb 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Actually... sorry for…
Tue, 08/18/2020 - 19:26

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?

Last seen on 18:31, 19. Aug 2020
Joined Feb 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I figured it out   If [is…
Wed, 08/19/2020 - 15:10

I figured it out

 

If [is provided world remote (client side)] = true

Do put your code here

Last seen on 18:31, 19. Aug 2020
Joined Feb 2020
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Nvm, I thought I had it…
Wed, 08/19/2020 - 17:07

Nvm, I thought I had it working. I'll just stick to my "counter" method for now