pub struct Position {
pub x: i32,
pub y: i32,
pub z: i32,
}Expand description
A packed block position encoded as a single 64-bit integer.
The Minecraft protocol packs three spatial coordinates into one i64
to minimize bandwidth for the most common spatial reference in the game.
Used in packets like block changes, player digging, block placement,
sign updates, and many more.
Bit layout (MSB to LSB):
- x: 26 bits (signed, range -33554432 to 33554431)
- z: 26 bits (signed, range -33554432 to 33554431)
- y: 12 bits (signed, range -2048 to 2047)
Encoding: (x & 0x3FFFFFF) << 38 | (z & 0x3FFFFFF) << 12 | (y & 0xFFF)
Fields§
§x: i32§y: i32§z: i32Implementations§
Trait Implementations§
Source§impl Decode for Position
Decodes a Position from a packed 64-bit big-endian integer.
impl Decode for Position
Decodes a Position from a packed 64-bit big-endian integer.
Reads 8 bytes as a big-endian i64, then unpacks x (26 bits),
z (26 bits), and y (12 bits) with proper sign extension for
negative coordinates.
Source§impl Encode for Position
Encodes a Position as a packed 64-bit big-endian integer.
impl Encode for Position
Encodes a Position as a packed 64-bit big-endian integer.
The three coordinates are packed into a single i64 using the bit
layout described on the type. The packed value is then written as
8 big-endian bytes, matching the Minecraft protocol wire format.
Source§impl EncodedSize for Position
A Position always occupies exactly 8 bytes on the wire (one packed i64).
impl EncodedSize for Position
A Position always occupies exactly 8 bytes on the wire (one packed i64).
fn encoded_size(&self) -> usize
Source§impl From<BlockPosition> for Position
Converts a BlockPosition into a Position for wire serialization.
impl From<BlockPosition> for Position
Converts a BlockPosition into a Position for wire serialization.
Coordinates outside the Position range (x/z: 26-bit signed, y: 12-bit signed) will be silently truncated during packing.
Source§fn from(pos: BlockPosition) -> Self
fn from(pos: BlockPosition) -> Self
Source§impl From<Position> for BlockPosition
Converts a Position (packed wire format) into a BlockPosition (full i32 coordinates).
impl From<Position> for BlockPosition
Converts a Position (packed wire format) into a BlockPosition (full i32 coordinates).
impl Copy for Position
impl Eq for Position
impl StructuralPartialEq for Position
Auto Trait Implementations§
impl Freeze for Position
impl RefUnwindSafe for Position
impl Send for Position
impl Sync for Position
impl Unpin for Position
impl UnsafeUnpin for Position
impl UnwindSafe for Position
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.