async animationUpdate(): Promise { if (this.needsUpdate || this.rotationLock) { return; } for (const component of this.components.values()) { if (!component.animated || !component.entity) { continue; } // Get current target rotation as the new begin rotation const beginRotation: Vector3 = new Vector3( (component.entity.getProperty("createbedrock:target_rotation_x") as number) % 360, (component.entity.getProperty("createbedrock:target_rotation_y") as number) % 360, (component.entity.getProperty("createbedrock:target_rotation_z") as number) % 360 ); // Calculate rotation delta based on RPM const rotationDelta: number = Math.abs(component.RPM) / 1200 * 360 * (component.RPM < 0 ? -1 : 1); // Calculate new target rotation based on facing direction let targetRotation: Vector3 = new Vector3(beginRotation.x, beginRotation.y, beginRotation.z); switch (component.block.permutation.getState("minecraft:facing_direction")) { case "north": case "south": targetRotation.z -= rotationDelta; break; case "east": case "west": targetRotation.y -= rotationDelta; break; case "up": case "down": targetRotation.y -= rotationDelta; break; } // Apply the rotation properties component.entity.setProperty("createbedrock:begin_rotation_x", beginRotation.x); component.entity.setProperty("createbedrock:begin_rotation_y", beginRotation.y); component.entity.setProperty("createbedrock:begin_rotation_z", beginRotation.z); component.entity.setProperty("createbedrock:target_rotation_x", targetRotation.x); component.entity.setProperty("createbedrock:target_rotation_y", targetRotation.y); component.entity.setProperty("createbedrock:target_rotation_z", targetRotation.z); } }