My mod confuses Stone with Cobblestone?

Started by hishykot on

Topic category: Help with modding (Java Edition)

Last seen on 10:04, 21. Dec 2023
Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
My mod confuses Stone with Cobblestone?

Hello!

I have a problem with procedures. So I just started using Mcreator today and have this issue with the program seemingly confusing Stone with Cobblestone.

The first one works great:

 

Player right clicks block:

If Item in main-hand is “StoneChisel” AND is Get block the same block as “Stone”

   (

   if not in game mode CREATIVE

      (

      Deal “1” damage to item in main-hand;

      );

   Swing main hand;

   Play break effect of “Stone”;

   Replace block with “Cobblestone”, keep state;

   Spawn item/gem “Pebble” <…>;

   );


This just simply replaces stone with cobblestone when right-clicked with stone chisel and drops pebble right above it, no problems here.
The problem starts, presumably, in the next procedure, it’s a bit more complex (I hope my pseudo code-like formatting helps):


Player right clicks block:

If Item in main-hand is “Stone Chisel” AND Is Get block the same block as “Cobblestone”

   (

   If Random Int 1…10 = 1

      (

      Swing main hand;

      Remove block and spawn break particles;

      Play break effect of “Cobblestone”;

      Spawn item/gem “Stone Axe Head”;

      If not in game mode CREATIVE

         (

         Remove “1” “Stone Chisel” from main inventory

         );

      );
else

   Swing main hand;

   Spawn “10” particles <…> type ASH;

   If not in game mode CREATIVE

      (
      Deal “10” damage to Item in main-hand;

      );

   );

 

Yes, I did nest three if statement and yes, I did use RNG to determine loot, I just don’t want to mess around with variables and loottables for now.


The exact problem is: while playtesting right clicking STONE removes chisel as if it was a COBBLESTONE that was clicked, so it executes the second procedure for some reason while at the same time executing the first one too (because pebble also spawns).

I have a suspicion that the mod executes both prosedures consequently, spawning pebble, turning stone into cobblestone and realising that (somehow) it was cobblestone that was clicked all along! But that’s just a theory and I don’t really know how to test it nor fix it.

So overall,
I don’t get it :(

Can anyone explain?


P.S. Not a native English speaker.

Last seen on 20:36, 6. Feb 2024
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Your script just uses …
Tue, 02/06/2024 - 20:36

Your script just uses "Player right clicks block", which means by the time your second procedure gets the block to check it, the block is already changed. You can solve this by cancelling the event, which should prevent all further event handlers from running. (I don't remember the exact block name, as it's been a while since I last used MCreator.)