Skip to content

Commit

Permalink
Continue working
Browse files Browse the repository at this point in the history
  • Loading branch information
Asurar0 committed Sep 17, 2024
1 parent 31b83f5 commit b61c478
Showing 1 changed file with 42 additions and 27 deletions.
69 changes: 42 additions & 27 deletions pumpkin-world/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ const CHUNK_AREA: usize = 16 * 16;
const SUBCHUNK_VOLUME: usize = CHUNK_AREA * 16;
const CHUNK_VOLUME: usize = CHUNK_AREA * WORLD_HEIGHT;

// ======================== Structure ========================
// ======================== NBT Structure ========================
// This section defines some data structure designed and used by Minecraft
// java implementation. They might not be used as defined by Pumpkin for
// its core working.
//

#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
struct ChunkNbt {
#[expect(dead_code)]
/// `ChunkNbt`
///
/// This data structure stores a chunk information as described by a regional
/// Minecraft Anvil file. They are stored in NBT format and have been updated
/// for Minecraft 1.18.
pub struct ChunkNbt {
/// Version of the chunk NBT structure.
data_version: i32,
/// X position of the chunk (in chunks, from the origin, not relative to region).
Expand All @@ -54,16 +62,17 @@ struct ChunkNbt {
#[serde(rename = "sections")]
sections: Vec<ChunkSection>,
/// Each TAG_Compound in this list defines a block entity in the chunk. If this list is empty, it becomes a list of End tags.
#[serde(rename = "block_entities")]
#[serde(skip)]
block_entities: Vec<BlockEntity>,
block_entities: Vec<BlockNbtEntity>,
/// Several different heightmaps corresponding to 256 values compacted at 9 bits per value
heightmaps: ChunkHeightmaps,
/// A List of 16 lists that store positions of light sources per chunk section as shorts, only for proto-chunks
#[serde(skip)]
lights: Vec<ChunkLight>,
lights: Vec<ChunkNbtLight>,
/// A list of entities in the proto-chunks, used when generating. As of 1.17, this list is not present for fully generated chunks and entities are moved to a separated region files once the chunk is generated.
#[serde(skip)]
entities: Vec<ChunkEntity>,
entities: Vec<ChunkNbtEntity>,
/// TODO
#[serde(rename = "fluid_ticks")]
#[serde(skip)]
Expand All @@ -78,7 +87,7 @@ struct ChunkNbt {
/// TODO
#[serde(rename = "blending_data")]
#[serde(skip)]
blending_data: ChunkBlendingData,
blending_data: ChunkNbtBlendingData,
/// TODO
#[serde(skip)]
post_processing: (),
Expand All @@ -88,29 +97,34 @@ struct ChunkNbt {
}

#[derive(Serialize, Deserialize, Debug)]
pub struct BlockEntity {
/// A block entity (not related to entity) is used by Minecraft to store information
/// about a block that can't be stored in the block's block states. Also known as
/// *"tile entities"* in prior versions of the game.
pub enum BlockNbtEntity {
// TODO
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChunkLight {
pub struct ChunkNbtLight {
// TODO
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ChunkEntity {
pub struct ChunkNbtEntity {
// TODO
}

#[derive(Serialize, Deserialize, Default, Debug)]
pub struct ChunkBlendingData {
/// Biome blending data
pub struct ChunkNbtBlendingData {
min_section: i32,
max_section: i32,
}




// ======================== Pumpkin Structure ========================
// This section defines structures that are used by
//
//

pub struct ChunkData {
pub blocks: ChunkBlocks,
Expand Down Expand Up @@ -158,33 +172,34 @@ struct ChunkSection {

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
#[serde(tag = "Status")]
#[repr(u32)]
enum ChunkStatus {
#[serde(rename = "minecraft:empty")]
Empty,
Empty = 0,
#[serde(rename = "minecraft:structure_starts")]
StructureStarts,
StructureStarts = 1,
#[serde(rename = "minecraft:structure_references")]
StructureReferences,
StructureReferences = 2,
#[serde(rename = "minecraft:biomes")]
Biomes,
Biomes = 3,
#[serde(rename = "minecraft:noise")]
Noise,
Noise = 4,
#[serde(rename = "minecraft:surface")]
Surface,
Surface = 5,
#[serde(rename = "minecraft:carvers")]
Carvers,
Carvers = 6,
#[serde(rename = "minecraft:liquid_carvers")]
LiquidCarvers,
LiquidCarvers = 7,
#[serde(rename = "minecraft:features")]
Features,
Features = 8,
#[serde(rename = "minecraft:initialize_light")]
Light,
Light = 9,
#[serde(rename = "minecraft:spawn")]
Spawn,
Spawn = 10,
#[serde(rename = "minecraft:heightmaps")]
Heightmaps,
Heightmaps = 11,
#[serde(rename = "minecraft:full")]
Full,
Full = 12,
}

/// The Heightmap for a completely empty chunk
Expand Down

0 comments on commit b61c478

Please sign in to comment.