chunkedge_protocol/packets/play/
level_chunk_with_light_s2c.rs

1use std::borrow::Cow;
2
3use chunkedge_binary::array::FixedArray;
4use chunkedge_binary::{Decode, Encode};
5use chunkedge_generated::block::BlockEntityKind;
6use chunkedge_nbt::Compound;
7
8use crate::{ChunkPos, Packet, VariableBitSet};
9
10#[derive(Clone, Debug, Encode, Decode, Packet)]
11pub struct LevelChunkWithLightS2c<'a> {
12    pub pos: ChunkPos,
13    pub heightmaps: Cow<'a, [HeightMap]>,
14    pub blocks_and_biomes: &'a [u8],
15    pub block_entities: Cow<'a, [ChunkDataBlockEntity<'a>]>,
16    pub sky_light_mask: Cow<'a, VariableBitSet>,
17    pub block_light_mask: Cow<'a, VariableBitSet>,
18    pub empty_sky_light_mask: Cow<'a, VariableBitSet>,
19    pub empty_block_light_mask: Cow<'a, VariableBitSet>,
20    pub sky_light_arrays: Cow<'a, [FixedArray<u8, 2048>]>,
21    pub block_light_arrays: Cow<'a, [FixedArray<u8, 2048>]>,
22}
23
24#[derive(Clone, PartialEq, Debug, Encode, Decode)]
25pub struct HeightMap {
26    pub kind: HeightMapKind,
27    pub data: Vec<i64>,
28}
29
30#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode)]
31pub enum HeightMapKind {
32    /// All blocks other than air, cave air and void air.
33    #[packet(tag = 1)]
34    WorldSurface,
35    /// "Solid" blocks, except bamboo saplings and cactuses; fluids.
36    #[packet(tag = 4)]
37    MotionBlocking,
38    /// Same as `MOTION_BLOCKING`, excluding leaf blocks.
39    #[packet(tag = 5)]
40    MotionBlockingNoLeaves,
41}
42
43#[derive(Clone, PartialEq, Debug, Encode, Decode)]
44pub struct ChunkDataBlockEntity<'a> {
45    pub packed_xz: i8,
46    pub y: i16,
47    pub kind: BlockEntityKind,
48    pub data: Cow<'a, Compound>,
49}