Skip to content

Natural spawning

Iltotore edited this page Jul 26, 2020 · 1 revision

Biome spawning

CustomEntityAPI supports biome-managed spawning for your custom entities. This feature is implemented trough the CustomEntityType interface using the getSpawns method:

@Override
public Collection<BiomeSpawn> getSpawns(ServerVersion version) {
    return Collections.singleton(
            BiomeSpawn.builder()
                    .in(Biome.THE_END, Biome.END_HIGHLANDS)
                    .weighing(100)
                    .withMaximum(4)
                    .build()
    );
}

In this example, a Collection of a single BiomeSpawn, covering the biomes THE_END and END_HIGHLANDS with a weight of 100 and a maximum of 4 entities per spawn is returned.

Notes:

  • A bigger weight will increase your mob spawn chance to the detriment of other entities one.
  • The minimal count of entities spawned per time should be positive.
  • The maximal count of entities spawned per time should be superior or equal than the minimal.

Replacing vanilla spawn

CustomEntityAPI provides a simple way to override your entity's base spawn by using the CustomEntityType#isVanilla method.

@Override
public boolean isVanilla(ServerVersion version) {
    return true;
}

Returning true means that your custom entity will overwrite its base spawns.

Clone this wiki locally