← Roadmap

EffectiveCompositeEntity

Composite entities

Why

Some "mobs" are several entities: body + display head + hitbox. They must spawn together, be removed together and let you reach the rest from any part.

EffectiveCompositeEntity links several EffectiveEntity into a group through PDC: the first is the parent, the rest are children. Removing any part removes the whole group.

Minimal example

Composite entity
object Golem : EffectiveCompositeEntity() {
    override fun getNamespacedData() = MyPlugin.instance to "golem"

    override fun getEffectiveEntities() = listOf(GolemBody, GolemHead)

    fun init() {}
}

val parts = Golem.spawnEntities(location)
val head = Golem.getChild(parts[0], GolemHead.getNamespacedKey())
val body = Golem.getParent(head!!)

What to override

  • getNamespacedData() *
    Plugin and group id
  • getEffectiveEntities() *
    Parts; index 0 is the parent. At least two
  • getAdditionalArgs()
    Default: null
    Group parameters in PDC

* required

Pitfalls

  • All parts spawn at the same point — positioning parts relative to each other is your plugin's job.
  • Parts are regular EffectiveEntity with their own init(); they need initialising too.