Skip to content

TransformComponent

Position and rotation of an entity in the world.

TransformComponent transform = store.getComponent(ref, TransformComponent.getComponentType());
// read position
Vector3d pos = transform.getPosition();
double x = pos.getX();
double y = pos.getY();
double z = pos.getZ();
// modify (Vector3d is mutable)
pos.assign(newX, newY, newZ);
// teleport (handles chunk transitions gracefully)
transform.teleportPosition(new Vector3d(x, y, z));
// read rotation (pitch, yaw, roll)
Vector3f rot = transform.getRotation();
float pitch = rot.getPitch(); // X
float yaw = rot.getYaw(); // Y
float roll = rot.getRoll(); // Z
// modify
rot.setYaw(newYaw);
rot.setPitch(newPitch);
// teleport rotation
transform.teleportRotation(new Vector3f(pitch, yaw, roll));

teleportPosition() / teleportRotation() are low-level methods for repositioning entities. They handle chunk boundary transitions but do NOT send client packets or record teleport history. Use these only for non-player entities or internal ECS systems.

// move a non-player entity
transform.teleportPosition(targetPosition);
transform.teleportRotation(targetRotation);