Mineuniverse
Rotation

Rotation

Rotation (also known as perspective, viewpoint or viewing angle) is the direction an entity is facing. Rotation in Minecraft consists of Y-rotation or yaw…

9 min read Updated 1 views
Gameplay
Advertisement Remove ads with Premium →
Contents (19)
  1. Representation
  2. Entity hitbox
  3. Entity format
  4. Debug screen
  5. Y-rotation (Yaw Angle)
  6. Algorithm for the Y-rotation angle
  7. Explanation
  8. Wrapping back
  9. The final code
  10. Place blocks
  11. Target selection
  12. Save perspective
  13. Set perspective
  14. Viewpoint coordinates
  15. History
  16. Java Edition
  17. Bedrock Edition
  18. Data History
  19. References
Perspectives

Rotation (also known as perspective, viewpoint or viewing angle) is the direction an entity is facing. Rotation in Minecraft consists of Y-rotation or yaw and X-rotation, declination or pitch, each affecting the directions of the body and the head of the entity. For entities without heads, they can sometimes rotate entirely around the X-axis. The "X" and "Y" refers to the axis about which they rotate. Rotation can limit what a mob or player can see, but other entities (e.g. boats and item frames) also have a rotation.

Representation

Entity hitbox

A frog's perspective can be seen as a blue line in the debug renderer.

Rotation is visualized by entity_hitboxes debug renderer as a long blue tint placed in-line with the (red) eye height hitbox and shows which direction the entities are looking.

Entity format

Main article: Entity format

Rotation is internally represented with two float values in degrees.

  • Y-rotation varies from -180° (facing due north) to -90° (facing due east) to 0° (facing due south) to +90° (facing due west) to +180° (facing due north again).
  • For X-rotation, horizontal is 0°, with positive values looking downward and negative values looking upward. It does not exceed positive or negative 90°.

Debug screen

Main article: Debug screen
Facing in the Debug screen

The player's own rotation can be seen in the debug screen under Facing. This can be toggled in the debug options menu under player_position. First the nearest cardinal direction and horizontal axis are specified, followed by the player's yaw and pitch in the brackets to one digit of precision.

When entity hitboxes are shown using F3 + B, their rotation is also visualized as a blue line pointing in their facing direction starting from the center of their hitbox at eye level.

Y-rotation (Yaw Angle)

An entity turning to the right or left corresponds to a positive or negative change in their Y-rotation.

Here, "anticlockwise angle from +X in a 2D system" denotes the angle measured counterclockwise starting from the positive X-axis. These angles also have values from the interval (-180°, 180°].

Y-rotation angle ranges assigned to the cardinal directions
Cardinal

Direction

Corresponding axis Y-rotation angle range (ranges inclusive and following anticlockwise direction) Range of anticlockwise angles from +X in a 2D system (ranges inclusive and following anticlockwise direction)
North negative Z 135.0° to -135.1° (135.0° to 180.0° and -179.9° to -135.1°) 45.1° to 135.0°
South positive Z -45.0° to 44.9° -134.9° to -45.0°
East positive X -135.0° to -45.1° -44.9° to 45.0°
West negative X 45.0° to 134.9° 135.1° to -135.0°
Diagram of a clock mapping yaw angles on a clock, highlighting the different cardinal directions in alternating black and white colours. The bounding angles are written on a white box in a black background.
A diagram mapping Y-rotation angles to clock positions and cardinal directions, along with the bounding angles (all inclusive) for each cardinal direction. This diagram has been referred to as the "yaw table" in this article.
Y-rotation angles based on the clock positions
Clock

Positions

Y-rotation angle Anticlockwise angle from +X in a 2D system
1 o'clock -150.0° 60.0°
2 o'clock -120.0° 30.0°
3 o'clock -90.0° 0.0°
4 o'clock -60.0° -30.0°
5 o'clock -30.0° -60.0°
6 o'clock -0.0° -90.0°
7 o'clock 30.0° -120.0°
8 o'clock 60.0° -150.0°
9 o'clock 90.0° 180.0°
10 o'clock 120.0° 150.0°
11 o'clock 150.0° 120.0°
12 o'clock 180.0° 90.0°

Algorithm for the Y-rotation angle

Explanation

The angle transformation to get the correct Y-rotation angle not only requires rotating the Y-rotation circle, but also reflecting the yaw table horizontally or vertically through the diameter.

Initial and Desired

A semicircle in Minecraft, placed in a valley using spruce logs and jungle place. Orientation is like a dome.
This is the upper half of a normal circle with the actual angles written. This picture can be compared with the one given above. We want to get the corresponding Y-rotation angles.

This part can be thought of as the top half of a semicircle standing on the +X axis. The circle is to be rotated for getting the outputs as in the yaw table. It is also checked whether reflecting the circle along the diameter (or flipping the circle) is necessary.

A semicircle in Minecraft, placed in a valley using spruce logs and jungle planks. Orientation is towards the left. Mirror of the "Semicircle rotated by minus 90 degrees" image.
The desired angles. The 180 degree part is above the 0 degree part, and the semicircle is in a C-like orientation.
What we want
Initial angle

(+X axis, anticlockwise)

Desired angle

(Corresponding Y-rotation angle)

Orientation Desired position in the semicircle
0° -90° Towards the left Bottom
90° 180° Left
180° 90° Top
Semicircle rotated by plus 90 degrees, orientation of the semicircle is towards the left.
Semicircle rotated by +90°.

Adding 90°

Initial angle

(+X axis, anticlockwise)

Final angle

(Corresponding Y-rotation angle)

Orientation Final position in the semicircle
0° 90° Towards the left Top
90° 180° Left
180° -90° Bottom

Reflecting the semicircle along the (imaginary) horizontal diameter produces the desired angles (Top changes to bottom and vice-versa).

Semicircle rotated by minus 90 degrees, orientation of the semicircle is towards the right.
Semicircle rotated by -90°.

Subtracting 90°

Initial angle

(+X axis, anticlockwise)

Final angle

(Corresponding Y-rotation angle)

Orientation Final position in the semicircle
0° -90° Towards the right Bottom
90° 0° Right
180° 90° Top

Reflecting the semicircle along the vertical diameter produces the desired angles (Right changes to left and vice-versa).

Wrapping back

For the yaw, the range is (-180°, 180°], which means that anything greater than the absolute value of 180 degrees must be wrapped back inside the yaw table. However, after the angle transformations, all the angles beyond the range are to be wrapped.

There can be many more approaches for wrapping other than the ones stated below.

Approach 1: Using the modulus

Required: the size and the minimum and the maximum values.

The size is 360° because the whole circle is being considered.

Therefore,

In various programming languages, the mod(a, n) operator is used. When exactly one of the operands is negative, the basic definition breaks down, and programming languages differ in how these values are defined.[1] Here, n = 360. Therefore, 'a' should be changed to a positive value before performing the modulo operation.

Approach 2: Adding or subtracting by 360 degrees

360 degrees is a full revolution. Moving by positive or negative 360 degrees is the same thing as not moving inside the orbit.

Thus, the following method can be used:

This has been achieved through the following code in JavaScript:

angle = -360 * Math.sign(angle) + angle;
if (angle === -180)
    return "180.0";
return angle;

Here, angle is the variable x.

The final code

The final code in JavaScript is as follows. Two coordinates are used, namely (xcurrent, zcurrent) and (xdest, zdest).[2]

function getYawAngle(xcurrent, zcurrent, xdest, zdest) {

  // z is negated here (equivalent to -(zdest - zcurrent))
  let slope = Math.atan2(zcurrent - zdest, xdest - xcurrent) * (180 / Math.PI);

  slope += 90;   // Adding 90 degrees
  slope *= -1;   // Reflecting along the horizontal diameter

  // Wraps into the (-180, 180] range (Approach 2)
  if (Math.abs(slope) > 180) {
    slope = -360 * Math.sign(slope) + slope;
  }

  // Rounding to a single decimal place
  slope = Math.round(slope * 10) / 10;

  // Mimicking the Java special‑case string outputs
  if (slope === 0)       return "-0.0";
  if (slope === -180)    return "180.0";

  // Default path – always keeping one decimal digit like Java’s “‑123.4”
  return slope.toFixed(1);
}

The function in Approach 2 has not been replicated one-to-one.

Place blocks

The viewing angle affects the placement of some blocks: depending on how the player look, for example, a banner or a sign rotated accordingly. The viewing angle also plays a role when placing stairs or scaffolding.

Target selection

Target selection properties allow entities to be selected that have a specific viewing angle:

y_rotation Viewing angle
x_rotation Head tilt angle

Angle ranges are specified with two points, e.g. B. 43..47.

/title @a[y_rotation=<view angle>] actionbar {"text":"View direction (compass direction)"}
/title @a[x_rotation=<head tilt angle>] actionbar {"text":"head tilt (up)"}

Examples of the cardinal directions:

/execute if entity @p[y_rotation=135..-135] run say North
/execute if entity @p[y_rotation=-135..-45] run say East
/execute if entity @p[y_rotation=-45..45] run say South
/execute if entity @p[y_rotation=45..135] run say West

Save perspective

Blinking angles can be read out and saved in a score: This is done by creating a score target for the direction and the inclination.

/scoreboard objectives add direction dummy "viewing angle direction" 
/scoreboard objectives add tilt dummy "viewing angle inclination"

The direction and inclination are then read out using the command /data and save them in the respective score.

/execute as @a store result score @s direction run data get entity @s Rotation[0]
/execute as @a store result score @s tilt run data get entity @s Rotation[1]

Set perspective

The commands /teleport and /rotate can be used to set the perspective of entities. The entities can move freely after teleportation if they have AI, but they start with the fixed viewing angle.

Additionally, all entities except players can be realigned using the command /data via the property Rotation

Viewpoint coordinates

Circumflexes (^) allow the position to be determined depending on the rotation of an entity.

History

Java Edition

Java Edition
1.0.0Beta 1.9 Prerelease Added the rotation nbt tag for entities.
Beta 1.9 Prerelease 2 Fixed inconsistent rotation behavior for certain entities.
1.814w02a Added rotation arguments (<y-rot> <x-rot>) to the /tp command, allowing direct setting of yaw and pitch during teleportation.
14w07a Introduced the x_rotation and y_rotation target selector arguments for filtering entities by facing direction.
14w08a Fixed an issue where the client failed to clamp yaw rotation to the -180 to 180 range.[3]
1.1317w45b Overhauled the command system; the x_rotation and y_rotation selector arguments were temporarily swapped in functionality (x_rotation returned pitch, y_rotation returned yaw).[4]
17w47a Resolved the swapped selector argument bug.[5]
1.15.2pre1 Fixed a bug where modifying an entity's NBT data would reset its rotation.[6]
1.19.322w43a Fixed visual stuttering of minecarts and boats.[7]
1.20.624w13a Fixed a bug where mobs' yaw rotation would not update when standing still (pitch updated correctly).[8]
1.21Pre-release 1 Fixed incorrect entity rotations after loading or reloading a world.[9]
Pre-release 2 Fixed an issue where summoning any entity with a {Rotation:[]} NBT tag would rotate it incorrectly.[10]
1.21.224w33a Added the /rotate command, enabling direct rotation changes without altering position.
24w34a Fixed jittery camera movement when constantly rotating a player to their current rotation.[11]

Bedrock Edition

Bedrock Edition
1.14.0 Fixed incorrect rotation for certain items.
1.20.15 Fixed the getRotation() scripting method not returning the proper entity rotation.
1.21.21 Fixed players experiencing the wrong perspective after going through Nether portals.
1.21.22 Fixed a bug where all custom blocks were rotated 180 degrees in the UI.

Data History

Java Edition

Java Edition
1.1317w47a The numeric ID for the Rotation NBT tag was removed as part of The Flattening.

References

Advertisement Remove ads with Premium →

More in Gameplay

View all 133 →
Redstone mechanicsRedstone mechanics describe the general concepts of redstone power, and how redstone-related blocks interact with one another. This article describes…RenewabilityRenewability refers to the possibility of an item or block or entity to be obtained continuously without exploring new areas or having additional players…Renewable resourceA renewable resource (as opposed to a non-renewable resource, or finite resource) is a resource that can be obtained in unlimited quantities in Survival…RidingRidingRiding, also known as mounting, is the behavior that allows an entity to mount another entity.Saved HotbarsSaved HotbarsThe Saved Hotbars menu is a feature in Java Edition that allows the Creative mode player to save selectable hotbar slots.ScoreboardScoreboardThe scoreboard system is a complex gameplay mechanic utilized through commands. Mainly intended for mapmakers and server operators, scoreboards are used…ServerServerA server provides a world for players to play multiplayer with others over the Internet or a local area network without the requirement for one player to…Server listServer listThe server list is a menu screen where players can join and manage the servers they visit. Players can see if a server is online, check how many player…

Related mods

Better minecart rotation (Forge) Better minecart rotation (Forge) Mod · 58.1K downloads Better minecart rotation (Fabric) Better minecart rotation (Fabric) Mod · 13.8K downloads Player Animation Library More Rotation Player Animation Library More Rotation Mod · 7.5K downloads RotationalWrench RotationalWrench Plugin · 4.9K downloads
Explore the Minecraft Wiki
Blocks, items, mobs, biomes and game mechanics — all in one place.
Wiki home