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: BitSetSections with entries in sky_light_arrays.
block_light_mask: BitSetSections with entries in block_light_arrays.
empty_sky_light_mask: BitSetSections whose sky light data consists entirely of zeroes.
empty_block_light_mask: BitSetSections 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
impl LightData
Sourcepub fn expected_sky_light_array_count(&self) -> usize
pub fn expected_sky_light_array_count(&self) -> usize
Returns the number of sky light arrays required by the sky mask.
Sourcepub fn expected_block_light_array_count(&self) -> usize
pub fn expected_block_light_array_count(&self) -> usize
Returns the number of block light arrays required by the block mask.