var Entity.nbt: CompoundTagGet/Set the NBT data of an Entity.
Common
var Entity.nbt: CompoundTagGet/Set the NBT data of an Entity.
object EntityEventEvent handlers for entity lifecycle events.
class EntityOnTickEvent(entity: Entity): ContextEvent<Entity, Entity.(level: Level)-> Unit>(entity, onTickHandlers)Context event for entity tick operations.
val Entity.onTick: EntityOnTickEventRegister a tick event for this entity.
fun beginReload()Clear all script-owned entity handlers before scripts are reloaded.
fun rebindLoadedEntities(server: MinecraftServer)Re-apply handlers for entities that are already loaded.
This makes behavior changes effective immediately after reload, without requiring entities to be reloaded from chunks.
class KattonServerEntityCollection( private val server: MinecraftServer )Collection of all entities across all server levels.
| Property | Description |
|---|---|
server | The MinecraftServer instance |
val allAll entities across all levels.
operator fun get(level: ServerLevel): KattonLevelEntityCollectionGet entity collection for a specific level.
operator fun get(uuid: UUID): Entity?Find an entity by UUID across all levels.
class KattonLevelEntityCollection( val level: ServerLevel ) : Iterable<Entity> by level.allEntitiesCollection of entities within a specific level.
| Property | Description |
|---|---|
level | The ServerLevel containing the entities |
operator fun <T : Entity> get(entityTypeTest: EntityTypeTest<Entity, T>, predicate: (T) -> Boolean = { true }): List<T>Get entities matching a type test and predicate.
operator fun <T : Entity> get(entityTypeTest: EntityTypeTest<Entity, T>, aabb: AABB, predicate: (T) -> Boolean = { true }): List<T>Get entities within an AABB matching a type test and predicate.
operator fun get(selector: EntitySelector): List<Entity>Get entities using an entity selector.
operator fun get(uuid: UUID): Entity?Find an entity by UUID in this level.
class KattonEntityAttributeValueMap( val entity: LivingEntity )Map-like access to a living entity's attribute values.
| Property | Description |
|---|---|
entity | The LivingEntity whose attributes are being accessed |
fun contains(holder: Holder<Attribute>): BooleanCheck if the entity has a given attribute.
operator fun get(holder: Holder<Attribute>): Double?Get the current value of an attribute.
fun set(holder: Holder<Attribute>, value: Double, vararg modifiers: AttributeModifier)Set the base value of an attribute and optionally add modifiers.
val LivingEntity.attributeValuesAccess to a living entity's attribute values.
fun addAttributeModify(entity: LivingEntity, attribute: Holder<Attribute>, modifier: AttributeModifier)Add a transient attribute modifier to an entity.
| Parameter | Description |
|---|---|
entity | the entity |
attribute | attribute holder to modify |
modifier | AttributeModifier to add |
fun removeAttributeModify(entity: LivingEntity, attribute: Holder<Attribute>, modifier: AttributeModifier)Remove an attribute modifier from an entity.
| Parameter | Description |
|---|---|
entity | the entity |
attribute | attribute holder to modify |
modifier | AttributeModifier to remove |
fun damage(entity: Entity, amount: Float)Damage an entity by an amount using generic damage.
| Parameter | Description |
|---|---|
entity | target entity |
amount | damage amount |
fun damage(target: Entity, amount: Float, attacker: Entity, damageType: ResourceKey<DamageType> = DamageTypes.GENERIC)Damage a target entity from an attacker using a damage type key.
| Parameter | Description |
|---|---|
target | the entity to damage |
amount | damage amount |
attacker | the source entity causing damage |
damageType | resource key of the DamageType (default GENERIC) |
fun damage(target: Entity, amount: Float, attacker: Entity, damageType: DamageType)Damage a target entity from an attacker using a DamageType instance.
| Parameter | Description |
|---|---|
target | the entity to damage |
amount | damage amount |
attacker | the source entity causing damage |
damageType | DamageType instance to apply |
fun damage(target: Entity, amount: Float, pos: Vec3, damageType: ResourceKey<DamageType> = DamageTypes.GENERIC)Damage a target entity from a position using a damage type key.
| Parameter | Description |
|---|---|
target | entity to damage |
amount | damage amount |
pos | position of damage source |
damageType | resource key of the DamageType (default GENERIC) |
fun damage(target: Entity, amount: Float, pos: Vec3, damageType: DamageType)Damage a target entity from a position using a DamageType instance.
| Parameter | Description |
|---|---|
target | entity to damage |
amount | damage amount |
pos | position of damage source |
damageType | DamageType instance to apply |
fun addEffect(entity: LivingEntity, effect: Holder<MobEffect>, duration: Int = 600, amplifier: Int = 0, showParticles: Boolean = true, ambient: Boolean = false)Add a mob effect to a LivingEntity.
| Parameter | Description |
|---|---|
entity | target entity |
effect | holder of the MobEffect to apply |
duration | effect duration in ticks (default 600) |
amplifier | effect amplifier level (default 0) |
showParticles | whether to show particles |
ambient | whether effect is ambient |
fun removeEffect(entity: LivingEntity, effect: Holder<MobEffect>)Remove a specific effect from a LivingEntity.
| Parameter | Description |
|---|---|
entity | target entity |
effect | holder of the MobEffect to remove |
fun clearEffects(entity: LivingEntity)Clear all effects from a LivingEntity.
| Parameter | Description |
|---|---|
entity | target entity |
fun rotate(target: Entity, rot: Vec2, relative: Boolean = false)Rotate an entity by a Vec2 (pitch, yaw).
| Parameter | Description |
|---|---|
target | target entity |
rot | rotation vector (x=pitch, y=yaw) |
relative | whether rotation is relative |
fun rotate(target: Entity, lookAt: Entity, targetAnchor: EntityAnchorArgument.Anchor = EntityAnchorArgument.Anchor.FEET, lookAtAnchor: EntityAnchorArgument.Anchor = EntityAnchorArgument.Anchor.FEET)Rotate an entity to look at another entity.
| Parameter | Description |
|---|---|
target | entity to rotate |
lookAt | entity to look at |
targetAnchor | anchor point on the target |
lookAtAnchor | anchor point on lookAt entity |
fun rotate(target: Entity, lookAt: Vec3, targetAnchor: EntityAnchorArgument.Anchor = EntityAnchorArgument.Anchor.FEET, lookAtAnchor: EntityAnchorArgument.Anchor = EntityAnchorArgument.Anchor.FEET)Rotate an entity to look at a position.
| Parameter | Description |
|---|---|
target | entity to rotate |
lookAt | position to look at |
targetAnchor | anchor on target entity |
fun spreadPlayers(level: ServerLevel, center: Vec2, spreadDistance: Float, maxRange: Float, maxHeight: Int, respectTeams: Boolean, targets: Collection<Entity>)Spread players around a center point.
| Parameter | Description |
|---|---|
level | server level used for context |
center | center position vector (x=z, y ignored) |
spreadDistance | minimum distance between players |
maxRange | max spread radius |
maxHeight | maximum height difference |
respectTeams | whether to keep teams together |
targets | collection of entities to spread |
fun summon(level: ServerLevel, reference: Holder.Reference<EntityType<*>>, vec3: Vec3, entityData: CompoundTag? = null): Entity?Summon an entity of a given type at a position with optional NBT.
| Parameter | Description |
|---|---|
level | server level to spawn in |
reference | reference to the EntityType to summon |
vec3 | spawn position |
entityData | optional NBT override for the entity |
spawned Entity or null on failure