Skip to content

Interacting with mobs


To avoid confusion, Geary comes with a BukkitEntity typealias for Bukkit's Entity interface.

All bukkit entities get a geary entity created for them when spawned (and removed when despawned.)

Entity syntax

val pig: Pig

// Get the associated geary entity
val gearyPig = pig.toGeary()

// Get the bukkit entity using components
pig.toBukkit() // equivalent

// each entity gets both the BukkitEntity component, and the specific instance
pig.toBukkit<Pig>() // attempts to cast get<BukkitEntity>()

Persisting data

Any persisting components will be saved and loaded to the mob's persistent data container on NBT save/load.

class Owner(
    val uuid: @SerializableWith(UUIDSerializer::class) UUID

val pig: Pig
val player: Player