pub struct SectionPos(pub IVec3);Expand description
A chunk section position (16x16x16 region).
Tuple Fields§
§0: IVec3Implementations§
Source§impl SectionPos
impl SectionPos
const SECTION_BITS: i32 = 4
const SECTION_SIZE: i32
const SECTION_MASK: i32
Sourcepub const fn new(x: i32, y: i32, z: i32) -> Self
pub const fn new(x: i32, y: i32, z: i32) -> Self
Creates a new SectionPos from section coordinates.
Sourcepub const fn block_to_section_coord(block_coord: i32) -> i32
pub const fn block_to_section_coord(block_coord: i32) -> i32
Converts a block coordinate to a section coordinate.
Sourcepub const fn from_block_pos(pos: BlockPos) -> Self
pub const fn from_block_pos(pos: BlockPos) -> Self
Creates a SectionPos from a BlockPos.
Sourcepub fn from_entity_pos(pos: DVec3) -> Self
pub fn from_entity_pos(pos: DVec3) -> Self
Creates a SectionPos containing the given floating-point world position.
Sourcepub const fn relative_to_block_x(&self, relative: PackedSectionBlockPos) -> i32
pub const fn relative_to_block_x(&self, relative: PackedSectionBlockPos) -> i32
Converts section-relative coordinates to an absolute block X coordinate.
Sourcepub const fn relative_to_block_y(&self, relative: PackedSectionBlockPos) -> i32
pub const fn relative_to_block_y(&self, relative: PackedSectionBlockPos) -> i32
Converts section-relative coordinates to an absolute block Y coordinate.
Sourcepub const fn relative_to_block_z(&self, relative: PackedSectionBlockPos) -> i32
pub const fn relative_to_block_z(&self, relative: PackedSectionBlockPos) -> i32
Converts section-relative coordinates to an absolute block Z coordinate.
Sourcepub const fn section_relative_pos(pos: BlockPos) -> PackedSectionBlockPos
pub const fn section_relative_pos(pos: BlockPos) -> PackedSectionBlockPos
Packs a block position into a section-relative offset. Format: (x << 8) | (z << 4) | y (each coordinate masked to 4 bits)
Sourcepub const fn relative_to_block_pos(
&self,
relative: PackedSectionBlockPos,
) -> BlockPos
pub const fn relative_to_block_pos( &self, relative: PackedSectionBlockPos, ) -> BlockPos
Converts a section-relative packed position back to a block position.
Trait Implementations§
Source§impl Clone for SectionPos
impl Clone for SectionPos
Source§fn clone(&self) -> SectionPos
fn clone(&self) -> SectionPos
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SectionPos
Source§impl Debug for SectionPos
impl Debug for SectionPos
impl Eq for SectionPos
Source§impl From<PackedSectionPos> for SectionPos
impl From<PackedSectionPos> for SectionPos
Source§fn from(pos: PackedSectionPos) -> Self
fn from(pos: PackedSectionPos) -> Self
Converts to this type from the input type.
Source§impl From<SectionPos> for PackedSectionPos
impl From<SectionPos> for PackedSectionPos
Source§fn from(pos: SectionPos) -> Self
fn from(pos: SectionPos) -> Self
Converts to this type from the input type.
Source§impl Hash for SectionPos
impl Hash for SectionPos
Source§impl PartialEq for SectionPos
impl PartialEq for SectionPos
Source§fn eq(&self, other: &SectionPos) -> bool
fn eq(&self, other: &SectionPos) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl ReadFrom for SectionPos
impl ReadFrom for SectionPos
impl StructuralPartialEq for SectionPos
Auto Trait Implementations§
impl Freeze for SectionPos
impl RefUnwindSafe for SectionPos
impl Send for SectionPos
impl Sync for SectionPos
impl Unpin for SectionPos
impl UnsafeUnpin for SectionPos
impl UnwindSafe for SectionPos
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.