Skip to content
On this page
Common

KattonContextApi

top.katton.apicommon/src/main/kotlin/top/katton/api/KattonContextApi.kt
Determines which position the returned [ExecutionContext] uses.

BonePositionMode

BonePositionModeCommonEnum Class
kotlin
enum class BonePositionMode

Determines which position the returned [ExecutionContext] uses.

BonePositionMode.BONE

BonePositionMode.BONECommonClass
kotlin
BONE,

Bone world-space position (entity position + bone offset, rotated by yaw).

BonePositionMode.ENTITY

BonePositionMode.ENTITYCommonClass
kotlin
ENTITY

Entity world-space position (ignoring the bone).

BoneOrientationMode

BoneOrientationModeCommonEnum Class
kotlin
enum class BoneOrientationMode

Determines which facing direction the returned [ExecutionContext] uses.

BoneOrientationMode.BONE

BoneOrientationMode.BONECommonClass
kotlin
BONE,

Bone's local rotation + entity rotation (approximate world-space facing).

BoneOrientationMode.ENTITY

BoneOrientationMode.ENTITYCommonClass
kotlin
ENTITY,

Entity's natural yaw/pitch.

BoneOrientationMode.WORLD

BoneOrientationMode.WORLDCommonClass
kotlin
WORLD

Default — [Vec2.ZERO] (no rotation).

computeBoneWorldPos

computeBoneWorldPosCommonFunction
kotlin
fun Entity.computeBoneWorldPos(bone: ModelPart, partialTick: Float = 1.0f): Vec3

Computes the world-space position of a [ModelPart] bone on the given [entity].

The bone offset (pixels, 1/16 block) is rotated by the entity's yaw and added to the entity's interpolated position.

Call AFTER animations have been applied ([net.minecraft.client.animation.KeyframeAnimation.apply]), so that [ModelPart.x]/[ModelPart.y]/[ModelPart.z] reflect the animated pose.

createBoneExecution

createBoneExecutionCommonFunction
kotlin
fun Entity.createBoneExecution(modelPart: ModelPart, positionMode: BonePositionMode = BonePositionMode.BONE, orientationMode: BoneOrientationMode = BoneOrientationMode.WORLD): ExecutionContext

Creates an [ExecutionContext] positioned at a [ModelPart] bone on an [entity].

Combines [BonePositionMode] and [BoneOrientationMode] to set the context's pos and rotation. Use the returned [ExecutionContext] to execute commands at the bone's world position, or read pos / rotation directly for custom effects.

On a dedicated client (multiplayer), the server reference may be unavailable — in that case the returned context has position/rotation set but no command execution capability.

Parameters

ParameterDescription
modelPartdirect [ModelPart] reference (e.g. model.rightArm, model.head)
positionMode[BonePositionMode.BONE] or [BonePositionMode.ENTITY]
orientationMode[BoneOrientationMode.BONE], [BoneOrientationMode.ENTITY], or [BoneOrientationMode.WORLD]