Skip to content
On this page

Common

KattonEntityApi

top.katton.api.dpcallercommon/src/main/kotlin/top/katton/api/dpcaller/KattonEntityApi.kt
Get/Set the NBT data of an Entity.

nbt

CommonProperty
kotlin
var Entity.nbt: CompoundTag

Get/Set the NBT data of an Entity.

EntityEvent

CommonObject
kotlin
object EntityEvent

Event handlers for entity lifecycle events.

EntityEvent.EntityOnTickEvent

CommonClass
kotlin
class EntityOnTickEvent(entity: Entity): ContextEvent<Entity, Entity.(level: Level)-> Unit>(entity, onTickHandlers)

Context event for entity tick operations.

EntityEvent.onTick

CommonProperty
kotlin
val Entity.onTick: EntityOnTickEvent

Register a tick event for this entity.

EntityEvent.beginReload

CommonFunction
kotlin
fun beginReload()

Clear all script-owned entity handlers before scripts are reloaded.

EntityEvent.rebindLoadedEntities

CommonFunction
kotlin
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.

KattonServerEntityCollection

CommonClass
kotlin
class KattonServerEntityCollection( private val server: MinecraftServer )

Collection of all entities across all server levels.

Properties

PropertyDescription
serverThe MinecraftServer instance

KattonServerEntityCollection.all

CommonProperty
kotlin
val all

All entities across all levels.

KattonServerEntityCollection.get

CommonFunction
kotlin
operator fun get(level: ServerLevel): KattonLevelEntityCollection

Get entity collection for a specific level.

KattonServerEntityCollection.get

CommonFunction
kotlin
operator fun get(uuid: UUID): Entity?

Find an entity by UUID across all levels.

KattonLevelEntityCollection

CommonClass
kotlin
class KattonLevelEntityCollection( val level: ServerLevel ) : Iterable<Entity> by level.allEntities

Collection of entities within a specific level.

Properties

PropertyDescription
levelThe ServerLevel containing the entities

KattonLevelEntityCollection.get

CommonFunction
kotlin
operator fun <T : Entity> get(entityTypeTest: EntityTypeTest<Entity, T>, predicate: (T) -> Boolean = { true }): List<T>

Get entities matching a type test and predicate.

KattonLevelEntityCollection.get

CommonFunction
kotlin
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.

KattonLevelEntityCollection.get

CommonFunction
kotlin
operator fun get(selector: EntitySelector): List<Entity>

Get entities using an entity selector.

KattonLevelEntityCollection.get

CommonFunction
kotlin
operator fun get(uuid: UUID): Entity?

Find an entity by UUID in this level.

KattonEntityAttributeValueMap

CommonClass
kotlin
class KattonEntityAttributeValueMap( val entity: LivingEntity )

Map-like access to a living entity's attribute values.

Properties

PropertyDescription
entityThe LivingEntity whose attributes are being accessed

KattonEntityAttributeValueMap.contains

CommonFunction
kotlin
fun contains(holder: Holder<Attribute>): Boolean

Check if the entity has a given attribute.

KattonEntityAttributeValueMap.get

CommonFunction
kotlin
operator fun get(holder: Holder<Attribute>): Double?

Get the current value of an attribute.

KattonEntityAttributeValueMap.set

CommonFunction
kotlin
fun set(holder: Holder<Attribute>, value: Double, vararg modifiers: AttributeModifier)

Set the base value of an attribute and optionally add modifiers.

attributeValues

CommonProperty
kotlin
val LivingEntity.attributeValues

Access to a living entity's attribute values.

getAttribute

CommonFunction
kotlin
fun getAttribute(entity: LivingEntity, attribute: Holder<Attribute>): Double

Get an attribute value from a LivingEntity.

Parameters

ParameterDescription
entitythe entity
attributeattribute holder to read

Returns

current attribute value

hasAttribute

CommonFunction
kotlin
fun hasAttribute(entity: LivingEntity, attribute: Holder<Attribute>): Boolean

Check if a LivingEntity has a given attribute.

Parameters

ParameterDescription
entitythe entity
attributeattribute holder to check

Returns

true if attribute present

getBaseAttribute

CommonFunction
kotlin
fun getBaseAttribute(entity: LivingEntity, attribute: Holder<Attribute>): Double?

Get base attribute value from a LivingEntity.

Parameters

ParameterDescription
entitythe entity
attributeattribute holder to read

Returns

base value or null if attribute missing

setBaseAttribute

CommonFunction
kotlin
fun setBaseAttribute(entity: LivingEntity, attribute: Holder<Attribute>, value: Double): Boolean

Set the base attribute value for a LivingEntity.

Parameters

ParameterDescription
entitythe entity
attributeattribute holder to set
valuenew base value

Returns

true if changed, false otherwise

addAttributeModify

CommonFunction
kotlin
fun addAttributeModify(entity: LivingEntity, attribute: Holder<Attribute>, modifier: AttributeModifier)

Add a transient attribute modifier to an entity.

Parameters

ParameterDescription
entitythe entity
attributeattribute holder to modify
modifierAttributeModifier to add

removeAttributeModify

CommonFunction
kotlin
fun removeAttributeModify(entity: LivingEntity, attribute: Holder<Attribute>, modifier: AttributeModifier)

Remove an attribute modifier from an entity.

Parameters

ParameterDescription
entitythe entity
attributeattribute holder to modify
modifierAttributeModifier to remove

damage

CommonFunction
kotlin
fun damage(entity: Entity, amount: Float)

Damage an entity by an amount using generic damage.

Parameters

ParameterDescription
entitytarget entity
amountdamage amount

damage

CommonFunction
kotlin
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.

Parameters

ParameterDescription
targetthe entity to damage
amountdamage amount
attackerthe source entity causing damage
damageTyperesource key of the DamageType (default GENERIC)

damage

CommonFunction
kotlin
fun damage(target: Entity, amount: Float, attacker: Entity, damageType: DamageType)

Damage a target entity from an attacker using a DamageType instance.

Parameters

ParameterDescription
targetthe entity to damage
amountdamage amount
attackerthe source entity causing damage
damageTypeDamageType instance to apply

damage

CommonFunction
kotlin
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.

Parameters

ParameterDescription
targetentity to damage
amountdamage amount
posposition of damage source
damageTyperesource key of the DamageType (default GENERIC)

damage

CommonFunction
kotlin
fun damage(target: Entity, amount: Float, pos: Vec3, damageType: DamageType)

Damage a target entity from a position using a DamageType instance.

Parameters

ParameterDescription
targetentity to damage
amountdamage amount
posposition of damage source
damageTypeDamageType instance to apply

addEffect

CommonFunction
kotlin
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.

Parameters

ParameterDescription
entitytarget entity
effectholder of the MobEffect to apply
durationeffect duration in ticks (default 600)
amplifiereffect amplifier level (default 0)
showParticleswhether to show particles
ambientwhether effect is ambient

removeEffect

CommonFunction
kotlin
fun removeEffect(entity: LivingEntity, effect: Holder<MobEffect>)

Remove a specific effect from a LivingEntity.

Parameters

ParameterDescription
entitytarget entity
effectholder of the MobEffect to remove

clearEffects

CommonFunction
kotlin
fun clearEffects(entity: LivingEntity)

Clear all effects from a LivingEntity.

Parameters

ParameterDescription
entitytarget entity

mount

CommonFunction
kotlin
fun mount(passenger: Entity, vehicle: Entity): Boolean

Mount a passenger on a vehicle entity.

Parameters

ParameterDescription
passengerentity to mount
vehicleentity to be ridden

Returns

true if mounting succeeded, false otherwise

dismount

CommonFunction
kotlin
fun dismount(passenger: Entity): Boolean

Dismount a passenger from its vehicle.

Parameters

ParameterDescription
passengerentity to dismount

Returns

true if dismounted, false if not riding

rotate

CommonFunction
kotlin
fun rotate(target: Entity, rot: Vec2, relative: Boolean = false)

Rotate an entity by a Vec2 (pitch, yaw).

Parameters

ParameterDescription
targettarget entity
rotrotation vector (x=pitch, y=yaw)
relativewhether rotation is relative

rotate

CommonFunction
kotlin
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.

Parameters

ParameterDescription
targetentity to rotate
lookAtentity to look at
targetAnchoranchor point on the target
lookAtAnchoranchor point on lookAt entity

rotate

CommonFunction
kotlin
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.

Parameters

ParameterDescription
targetentity to rotate
lookAtposition to look at
targetAnchoranchor on target entity

spreadPlayers

CommonFunction
kotlin
fun spreadPlayers(level: ServerLevel, center: Vec2, spreadDistance: Float, maxRange: Float, maxHeight: Int, respectTeams: Boolean, targets: Collection<Entity>)

Spread players around a center point.

Parameters

ParameterDescription
levelserver level used for context
centercenter position vector (x=z, y ignored)
spreadDistanceminimum distance between players
maxRangemax spread radius
maxHeightmaximum height difference
respectTeamswhether to keep teams together
targetscollection of entities to spread

summon

CommonFunction
kotlin
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.

Parameters

ParameterDescription
levelserver level to spawn in
referencereference to the EntityType to summon
vec3spawn position
entityDataoptional NBT override for the entity

Returns

spawned Entity or null on failure

getTags

CommonFunction
kotlin
fun getTags(entity: Entity): MutableCollection<String>

Get tags attached to an entity.

Parameters

ParameterDescription
entitytarget entity

Returns

mutable collection of tag strings

addTag

CommonFunction
kotlin
fun addTag(entity: Entity, string: String): Boolean

Add a tag to an entity.

Parameters

ParameterDescription
entitytarget entity
stringtag to add

Returns

true if tag was added, false if already present

removeTag

CommonFunction
kotlin
fun removeTag(entity: Entity, string: String): Boolean

Remove a tag from an entity.

Parameters

ParameterDescription
entitytarget entity
stringtag to remove

Returns

true if the tag was removed