Started by
Minecraftmaker12
on
Topic category: Help with MCreator software
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
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);
}
}
}
}
}
}
if this is not working, i can make a difrent code
if you don't undersstent it, i can try to explein it, but it will be dificult