通用
KattonContextApi
决定返回的 [ExecutionContext] 使用哪个位置。
BonePositionMode
BoneOrientationMode
computeBoneWorldPos
kotlin
fun Entity.computeBoneWorldPos(bone: ModelPart, partialTick: Float = 1.0f): Vec3计算给定 [entity] 上 [ModelPart] 骨骼的世界空间位置。
骨骼偏移以像素为单位(1/16 方块),会按实体 yaw 旋转并加到实体的插值位置上。
请在动画应用之后调用([net.minecraft.client.animation.KeyframeAnimation.apply]), 这样 [ModelPart.x]/[ModelPart.y]/[ModelPart.z] 才能反映动画姿态。
createBoneExecution
kotlin
fun Entity.createBoneExecution(modelPart: ModelPart, positionMode: BonePositionMode = BonePositionMode.BONE, orientationMode: BoneOrientationMode = BoneOrientationMode.WORLD): ExecutionContextCreates 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.
参数
| 参数 | 说明 |
|---|---|
modelPart | 直接的 [ModelPart] 引用,例如 model.rightArm 或 model.head。 |
positionMode | [BonePositionMode.BONE] 或 [BonePositionMode.ENTITY]。 |
orientationMode | [BoneOrientationMode.BONE]、[BoneOrientationMode.ENTITY] 或 [BoneOrientationMode.WORLD]。 |
