While loop not working + applying slowness until block gone

Started by 2emk7 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
While loop not working + applying slowness until block gone

I am making a bear trap which why stepped on, closes and the block switches to beartrap_0 to beartrap_1 to beartrap_2, then deals the damage and plays the sound. All of that works perfectly (besides the audio playing multiple times) but i run into issues under the sound block. With the while block nothing in it will work, and the version i tried without the while block( everything contained in the if do else block) but it only runs for 20 ticks then stops. I want to make it so that you have slowness/ wont be able to move until the beartrap is gone. To me it looks like everything should work, but in contract ive only been using mcreator for 1 day. Any help would be greatly appreciated!
 

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You need to be pretty…
Thu, 07/27/2023 - 06:18

You need to be pretty careful with Wait and While blocks; they're useful, but they can break things pretty easily- your procedure probably isn't working because the While block is either always true, (because the beartrap is always the same), or because the while block never triggers, since you have the change on a delay.

I'd recommend restructuring this to have each of these actions unique to each state of the beartrap, instead of trying to run them all through the same procedure. For example:

  • Have the first bear trap state trigger a procedure that waits a couple ticks then transforms into the second state; triggered when a player steps on it.
  • Then have the second state transform into the third state after a couple of ticks. (In the Advanced Properties tab, set the update tick delay to however long you want it to wait, then just trigger the next procedure on update tick.)
  • Repeat this for however many intermediate states you have.
  • Then, with the second to last state, instead of just transforming, have its update tick procedure also damage and inflict slowness on anything that's standing on it.
  • Then have the final stage continue to inflict slowness or something while the player is standing on it, or force teleport the nearest player to it to prevent them from moving. 

 

...In short, try separating this out so that each state calls the next step, instead of trying to do it all at once.