EffectiveEntityWithSpawnEgg

An EffectiveEntity that also gets a matching spawn-egg item.

The framework auto-creates a SummoningEggItem (namespaced <id>_spawn_egg) which spawns this entity where used. Override getSpawnEggMaterial, getSpawnPlacement or editSpawnEggMeta to customize the egg; hand it out with getSpawnEggItem.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Backing cache of live entities of this type; kept in sync via chunk/world events.

Link copied to clipboard

The spawn-egg item bound to this entity type.

Functions

Link copied to clipboard
fun addEntityToCache(entity: Entity)

Manually adds entity to the tracking cache (spawns do this automatically).

Link copied to clipboard
fun addInteractHandler(click: EffectiveAbstractInteract.Click, callback: InteractCallback, cooldownData: EffectiveAbstractInteract.CooldownData<EffectiveEntityInteractable.EventsCallOptions>? = null)

Registers an interact handler for entities of this custom type (matched by key). To instead handle a plain vanilla EntityType, register through EffectiveEntityInteractable.addInteractHandler with a non-custom entity.

Link copied to clipboard
fun additionalKey(name: String): NamespacedKey

Resolves the persistent-data key for the declared additional arg name — use it to read the per-entity value via EffectiveDataContainerUtils. See getAdditionalArgs for the full flow.

Link copied to clipboard
fun createEntity(location: Location?): Entity

Builds (but does not add to the world) an entity of this type at location — null falls back to the first world's origin. Use spawnEntity to actually place it.

fun createEntity(location: Location?, additionalArgs: List<String>): Entity

createEntity variant that also applies additionalArgs to the new entity.

Link copied to clipboard
fun doEntityNearLookable(whoToLook: (Entity) -> Boolean = EffectiveEntityLookable.Look.TO_NEAR_PLAYER, lookDistance: Float = 5.0f)

Makes entities of this type turn to look at nearby targets.

Link copied to clipboard
abstract fun editEntity(entity: Entity)

Configures a freshly created entity (attributes, name, equipment, …). Called on every create.

Link copied to clipboard
open fun editSpawnEggMeta(meta: ItemMeta)

Customizes the spawn egg's meta (name, lore, model).

Link copied to clipboard

Declares extra, per-instance parameters this entity type accepts — values baked into an individual entity's persistent data at creation, so two entities of the same type can carry different settings.

Link copied to clipboard
fun getAdditionalArgsNamespacedKeys(): List<Pair<NamespacedKey, PersistentDataType<*, *>>>?

Namespaced keys backing this type's getAdditionalArgs (key → PDC type), or null if none.

Link copied to clipboard
fun getEntities(): ArrayList<Entity>

Currently tracked live entities of this type.

Link copied to clipboard

Convenience alias of getEntities for this type.

Link copied to clipboard
fun getEntitiesInBlock(block: Block): List<Entity>

Tracked entities of this type standing on the given block position.

Link copied to clipboard
abstract fun getEntityType(): EntityType

The base EntityType to spawn.

Link copied to clipboard
abstract fun getNamespacedData(): Pair<JavaPlugin, String>

Owning plugin and a plugin-unique id; together they form the getNamespacedKey.

Link copied to clipboard

Unique identity as "<plugin-name>/<id>", both lowercased.

Link copied to clipboard
fun getSpawnEggItem(): ItemStack

A single spawn-egg stack for this entity.

fun getSpawnEggItem(amount: Int): ItemStack

A spawn-egg stack of amount for this entity.

Link copied to clipboard
open fun getSpawnEggMaterial(): Material

Material used for the spawn egg (default: pig spawn egg).

Link copied to clipboard

How the entity is placed when the egg is used (default: vanilla placement).

Link copied to clipboard
fun removeEntityFromCache(entity: Entity)

Removes entity from the tracking cache (matched by UUID).

Link copied to clipboard
fun spawnEntity(location: Location): Entity

Creates and spawns an entity of this type at location, adding it to the tracking cache.

fun spawnEntity(location: Location, additionalArgs: List<String>): Entity

spawnEntity variant that also applies additionalArgs.