[RESOLVED] How to limit the number of mobs that spawn when using the "Spawn Entity" procedure template?

Started by bmccahon on

Topic category: Help with MCreator software

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[RESOLVED] How to limit the number of mobs that spawn when using the "Spawn Entity" procedure template?
Wed, 07/19/2023 - 04:38 (edited)

Hello all!

 

I'm currently working on a Java Edition mod feature that adds silkworms and silk moths into the game. I'm wanting the silkworms to spawn in naturally to start, and then change into a silk moth after a certain amount of time. I found a code template for this, which I have used (please see a photo of my code here), but when trialling the feature in-game I have found that after placing one silkworm down, it will change into several silk moths at the allotted time. Is there any way to include a limit in the code so that only 1 silk moth spawns in?

 

Thanks for any help!

Edited by bmccahon on Wed, 07/19/2023 - 04:38
Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks so much for your help…
Mon, 07/17/2023 - 23:57

Thanks so much for your help! I tried this and I think it partially worked, however I am still having issues with multiple silk moths spawning in following the silkworm despawn. I've noticed the number of silk moths that spawn matches the number of ticks in the wait procedure, so for example <Wait 20 ticks then on server-side> would spawn 20 silk moths. 

Would you have any idea how to resolve this?

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If the issue is the wait…
Tue, 07/18/2023 - 20:11

If the issue is the wait condition, you could also try creating an NBT timer. "On entity tock update" -> if timer # is greater than 0 subtract one from the timer

An "on entity spawn" procedure set the timer to your amount (20 ticks per your image)

On your current procedure, remove the wait and replace it with an if timer is = to 0 then run procedure.

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Using an NBT timer worked…
Wed, 07/19/2023 - 04:38

Using an NBT timer worked perfectly! No more excess moths spawning in. 

For anyone who needs help with this in future, I followed NorthWestTrees tutorial to learn how to make the process: https://www.youtube.com/watch?v=gTbWiMu-M-0

Thanks Stitch and Klemen for your help!