pub struct BlockPos {
pub x: i32,
pub y: i32,
pub z: i32,
}Expand description
A block position. x/z must fit 26 signed bits, y 12 signed bits to be encodable.
Fields§
§x: i32X coordinate.
y: i32Y coordinate.
z: i32Z coordinate.
Implementations§
Source§impl BlockPos
impl BlockPos
Sourcepub const fn unpack(v: u64, layout: PositionLayout) -> BlockPos
pub const fn unpack(v: u64, layout: PositionLayout) -> BlockPos
Unpacks a 64-bit value with the given layout.
Sourcepub const fn is_packable(&self) -> bool
pub const fn is_packable(&self) -> bool
Whether the coordinates fit the packed representation.
Sourcepub fn pack(&self, layout: PositionLayout) -> Result<u64, EncodeError>
pub fn pack(&self, layout: PositionLayout) -> Result<u64, EncodeError>
Packs into 64 bits; fails if a coordinate does not fit.
Sourcepub fn read(
r: &mut Reader<'_>,
layout: PositionLayout,
) -> Result<BlockPos, DecodeError>
pub fn read( r: &mut Reader<'_>, layout: PositionLayout, ) -> Result<BlockPos, DecodeError>
Reads a packed position with the given layout.
Sourcepub fn write(
&self,
w: &mut BytesMut,
layout: PositionLayout,
) -> Result<(), EncodeError>
pub fn write( &self, w: &mut BytesMut, layout: PositionLayout, ) -> Result<(), EncodeError>
Writes a packed position with the given layout.
Trait Implementations§
impl Copy for BlockPos
impl Eq for BlockPos
Source§impl Ord for BlockPos
impl Ord for BlockPos
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for BlockPos
impl PartialOrd for BlockPos
impl StructuralPartialEq for BlockPos
Auto Trait Implementations§
impl Freeze for BlockPos
impl RefUnwindSafe for BlockPos
impl Send for BlockPos
impl Sync for BlockPos
impl Unpin for BlockPos
impl UnsafeUnpin for BlockPos
impl UnwindSafe for BlockPos
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
Mutably borrows from an owned value. Read more