pub struct Angle(pub u8);Expand description
A rotation angle encoded as a single unsigned byte.
The Minecraft protocol represents rotations as a single byte where the
full 0-255 range maps to 0-360 degrees. This is used for entity head
rotation (Entity Head Look packet), entity look direction, and
similar rotation fields. The conversion formula is:
- Byte to degrees:
value / 256.0 * 360.0 - Degrees to byte:
degrees / 360.0 * 256.0
The mapping wraps naturally: 256 steps for a full rotation gives approximately 1.4° precision per step, which is sufficient for visual entity rotation in the game.
Tuple Fields§
§0: u8Implementations§
Source§impl Angle
impl Angle
Sourcepub fn from_degrees(degrees: f32) -> Self
pub fn from_degrees(degrees: f32) -> Self
Creates an Angle from a degree value.
The degree value is normalized to the 0-255 byte range. Values outside 0-360 wrap naturally (e.g., 720° wraps to the same byte as 360°, which is 0).
Sourcepub fn to_degrees(self) -> f32
pub fn to_degrees(self) -> f32
Converts the angle to degrees in the range 0.0 to ~359.0.
The result has approximately 1.4° precision due to the single-byte encoding. A byte value of 0 maps to 0°, 64 to 90°, 128 to 180°, and 192 to 270°.
Trait Implementations§
Source§impl Decode for Angle
Decodes an Angle from a single unsigned byte.
impl Decode for Angle
Decodes an Angle from a single unsigned byte.
Reads exactly one byte. Any byte value is valid — the full 0-255 range maps to 0-360 degrees.
Source§impl Encode for Angle
Encodes an Angle as a single unsigned byte.
impl Encode for Angle
Encodes an Angle as a single unsigned byte.
The angle is written directly as one byte with no transformation. This is the simplest encoding in the Minecraft protocol.
Source§impl EncodedSize for Angle
An Angle always occupies exactly 1 byte on the wire.
impl EncodedSize for Angle
An Angle always occupies exactly 1 byte on the wire.
fn encoded_size(&self) -> usize
impl Copy for Angle
impl Eq for Angle
impl StructuralPartialEq for Angle
Auto Trait Implementations§
impl Freeze for Angle
impl RefUnwindSafe for Angle
impl Send for Angle
impl Sync for Angle
impl Unpin for Angle
impl UnsafeUnpin for Angle
impl UnwindSafe for Angle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.