pub struct PalettedContainer {
pub bits_per_entry: u8,
pub palette: Palette,
pub storage: BitStorage,
pub container_type: PalettedContainerKind,
}
Fields§
§bits_per_entry: u8
§palette: Palette
This is usually a list of unique values that appear in the container so they can be indexed by the bit storage.
Sometimes it doesn’t contain anything if there’s too many unique items in the bit storage, though.
storage: BitStorage
Compacted list of indices pointing to entry IDs in the Palette.
container_type: PalettedContainerKind
Implementations§
Source§impl PalettedContainer
impl PalettedContainer
pub fn new(container_type: PalettedContainerKind) -> Self
pub fn read_with_type( buf: &mut Cursor<&[u8]>, container_type: &'static PalettedContainerKind, ) -> Result<Self, BufReadError>
Sourcepub fn index_from_coords(&self, x: usize, y: usize, z: usize) -> usize
pub fn index_from_coords(&self, x: usize, y: usize, z: usize) -> usize
Calculates the index of the given coordinates.
pub fn coords_from_index(&self, index: usize) -> (usize, usize, usize)
Sourcepub fn get_at_index(&self, index: usize) -> u32
pub fn get_at_index(&self, index: usize) -> u32
Returns the value at the given index.
§Panics
This function panics if the index is greater than or equal to the number of things in the storage. (So for block states, it must be less than 4096).
Sourcepub fn get(&self, x: usize, y: usize, z: usize) -> u32
pub fn get(&self, x: usize, y: usize, z: usize) -> u32
Returns the value at the given coordinates.
Sourcepub fn get_and_set(&mut self, x: usize, y: usize, z: usize, value: u32) -> u32
pub fn get_and_set(&mut self, x: usize, y: usize, z: usize, value: u32) -> u32
Sets the id at the given coordinates and return the previous id
Sourcepub fn set_at_index(&mut self, index: usize, value: u32)
pub fn set_at_index(&mut self, index: usize, value: u32)
Sets the id at the given index and return the previous id. You probably
want .set
instead.
Sourcepub fn set(&mut self, x: usize, y: usize, z: usize, value: u32)
pub fn set(&mut self, x: usize, y: usize, z: usize, value: u32)
Sets the id at the given coordinates and return the previous id
pub fn id_for(&mut self, value: u32) -> usize
Trait Implementations§
Source§impl Clone for PalettedContainer
impl Clone for PalettedContainer
Source§fn clone(&self) -> PalettedContainer
fn clone(&self) -> PalettedContainer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PalettedContainer
impl Debug for PalettedContainer
Source§impl McBufWritable for PalettedContainer
impl McBufWritable for PalettedContainer
Auto Trait Implementations§
impl Freeze for PalettedContainer
impl RefUnwindSafe for PalettedContainer
impl Send for PalettedContainer
impl Sync for PalettedContainer
impl Unpin for PalettedContainer
impl UnwindSafe for PalettedContainer
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.