Skip to content

Spawning API

Bootstrapped Spawner

kotlin
val spawner = StomMobs.spawnerWithVanillaProfiles(node)
java
MobSpawner spawner = StomMobs.spawnerWithVanillaProfiles(node);

This creates a MobSpawner, registers built-in vanilla profiles, and binds lifecycle listeners.

Spawn by Profile Id

kotlin
spawner.spawnAt("vanilla:zombie", instance, 0.0, 42.0, 0.0, level = 6)
java
spawner.spawnAt("vanilla:zombie", instance, 0, 42, 0, 6);

Spawn by Profile Object

kotlin
val profile: codes.bed.minestom.mobs.api.MobProfile = TODO()
spawner.spawnAt(profile, instance, 5.0, 42.0, 5.0, level = 4)
java
MobProfile profile = ...; // obtain profile
spawner.spawnAt(profile, instance, 5, 42, 5, 4);

Destination Following

You can set a destination block or a player to follow automatically.

kotlin
val mob = spawner.spawnAt("vanilla:zombie", instance, 0.0, 42.0, 0.0, level = 1)

// Follow a fixed block position
spawner.setDestinationBlock(mob, Pos(30.0, 42.0, 30.0))

// Follow a player destination
spawner.setPlayerDestination(mob, player)

// Stop destination-follow behavior
spawner.clearDestination(mob)
java
var mob = spawner.spawnAt("vanilla:zombie", instance, 0, 42, 0, 1);

// Follow a fixed block position
spawner.setDestinationBlock(mob, new Pos(30, 42, 30));

// Follow a player destination
spawner.setPlayerDestination(mob, player);

// Stop destination-follow behavior
spawner.clearDestination(mob);

Advanced Spawning

Use builders or DSL for more control over the spawn event (e.g. equipment, metadata).

java
MobSpawnBuilder.create(spawner)
    .profileId("vanilla:villager")
    .instance(instance)
    .position(new Pos(4, 42, 4))
    .level(2)
    .spawn();
kotlin
import codes.bed.minestom.mobs.dsl.*

spawnMob(spawner, "vanilla:villager") {
    instance(instance)
    position(Pos(4.0, 42.0, 4.0))
    // can configure entity meta or equipment here if supported
}

Interactive Spawning

You can also use spawn eggs to let players spawn mobs manually.

See Spawn Eggs API for details.

Kotlin Spawn DSL

kotlin
spawner.spawnMob {
    profileId = "vanilla:sheep"
    this.instance = instance
    position = Pos(8.0, 42.0, 8.0)
    level = 2
}

Released under the MIT License.