Skip to main content

LightData

Struct LightData 

Source
pub struct LightData {
    pub sky_light_mask: BitSet,
    pub block_light_mask: BitSet,
    pub empty_sky_light_mask: BitSet,
    pub empty_block_light_mask: BitSet,
    pub sky_light_arrays: PrefixedArray<LightArray>,
    pub block_light_arrays: PrefixedArray<LightArray>,
}
Expand description

Lighting masks and packed light arrays for a chunk column.

Mask bit zero addresses the section immediately below the world’s minimum height. Subsequent bits address chunk sections from bottom to top, ending with the section immediately above the world’s maximum height. Sky and block arrays are ordered by their corresponding set bits, least-significant bit first. The empty masks identify sections whose light data is all zero.

Encoding and decoding reject a sky or block array count that differs from the number of set bits in its data mask.

§Examples

use mcproto_types::{LightData, TypeCodec};

let light = LightData::default();
let mut encoded = Vec::new();
light.encode(&mut encoded)?;
assert_eq!(encoded, [0, 0, 0, 0, 0, 0]);

let mut input = encoded.as_slice();
assert_eq!(LightData::decode(&mut input)?, light);
assert!(input.is_empty());

See the official Light Data protocol documentation.

Fields§

§sky_light_mask: BitSet

Sections with entries in sky_light_arrays.

§block_light_mask: BitSet

Sections with entries in block_light_arrays.

§empty_sky_light_mask: BitSet

Sections whose sky light data consists entirely of zeroes.

§empty_block_light_mask: BitSet

Sections whose block light data consists entirely of zeroes.

§sky_light_arrays: PrefixedArray<LightArray>

One packed array for each set bit in sky_light_mask.

§block_light_arrays: PrefixedArray<LightArray>

One packed array for each set bit in block_light_mask.

Implementations§

Source§

impl LightData

Source

pub fn expected_sky_light_array_count(&self) -> usize

Returns the number of sky light arrays required by the sky mask.

Source

pub fn expected_block_light_array_count(&self) -> usize

Returns the number of block light arrays required by the block mask.

Trait Implementations§

Source§

impl Clone for LightData

Source§

fn clone(&self) -> LightData

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LightData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LightData

Source§

fn default() -> LightData

Returns the “default value” for a type. Read more
Source§

impl Eq for LightData

Source§

impl PartialEq for LightData

Source§

fn eq(&self, other: &LightData) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LightData

Source§

impl TypeCodec for LightData

Source§

fn encode(&self, writer: &mut impl Write) -> Result<(), CodecError>

Encodes this value to the writer.
Source§

fn decode(reader: &mut impl Read) -> Result<Self, CodecError>

Decodes this value from the reader.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ContextualCodec for T
where T: TypeCodec,

Source§

fn encode_with_context( &self, writer: &mut impl Write, _context: &Context, ) -> Result<(), CodecError>

Encodes this value using context supplied by its enclosing structure.
Source§

fn decode_with_context( reader: &mut impl Read, _context: &Context, ) -> Result<T, CodecError>
where T: Sized,

Decodes this value using context supplied by its enclosing structure.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.