How do i make a block that acts like a mob spawner?

Started by Minecraftmaker12 on

Topic category: Help with MCreator software

Joined Jan 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do i make a block that acts like a mob spawner?

I'm making a mod about cloning prehistoric creatures, and i need to make it spawn a creature of the egg type i put in. and it only spawns one when you put in the egg

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if im wan't to make a …
Wed, 11/02/2022 - 11:31

if im wan't to make a "living mob spawner" i'm makeing this code [ i use zombie but it cut be enyting]:

                if (0.8 <= Math.random()) {

if (world instanceof ServerLevel _level) {
Entity entityToSpawn = new Zombie(EntityType.ZOMBIE, _level);
entityToSpawn.moveTo(x, y, z, world.getRandom().nextFloat() * 360F, 0);
if (entityToSpawn instanceof Mob _mobToSpawn)
_mobToSpawn.finalizeSpawn(_level, world.getCurrentDifficultyAt(entityToSpawn.blockPosition()), MobSpawnType.MOB_SUMMONED,
null, null);
world.addFreshEntity(entityToSpawn);
}
}
}
}
}
}
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if this is not working, i…
Wed, 11/02/2022 - 11:33

if this is not working, i can make a difrent  code

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
if you don't undersstent it,…
Wed, 11/02/2022 - 11:35

if you don't undersstent it, i can try to explein it, but it will be dificult