Skip to content

Commit ea86cda

Browse files
committed
feat: add 1.8-1.15 world support and fix legacy uuid/tab issues
1 parent 9944df6 commit ea86cda

21 files changed

Lines changed: 1106 additions & 36 deletions

File tree

crates/blocks_report/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use thiserror::Error;
33

44
pub use blocks_report_data::{
55
block_state_builder::BlockStateLookup,
6-
internal_mapping::{InternalId, InternalMapping, StateData},
6+
internal_mapping::{InternalId, InternalMapping, InternalProperties, StateData},
77
report_mapping::{BlocksReportId, ReportIdMapping},
88
};
99

crates/minecraft_packets/src/play/chunk_data_and_update_light_packet.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct ChunkDataAndUpdateLightPacket {
1515
full_chunk: bool,
1616

1717
/// If false, the client will recalculate lighting based on the old/new chunk data
18-
#[pvn(..751)]
18+
#[pvn(735..751)]
1919
ignore_old_data: bool,
2020

2121
/// BitSet with bits (world height in blocks / 16) set to 1 for every 16×16×16 chunk section whose data is included in Data. The least significant bit represents the chunk section at the bottom of the chunk column (from the lowest y to 15 blocks above).
@@ -39,7 +39,7 @@ pub struct ChunkDataAndUpdateLightPacket {
3939
}
4040

4141
impl ChunkDataAndUpdateLightPacket {
42-
pub fn void(context: VoidChunkContext) -> Self {
42+
pub fn void(context: VoidChunkContext, protocol_version: ProtocolVersion) -> Self {
4343
let dimension_height = context.dimension_height;
4444
Self {
4545
chunk_x: context.chunk_x,
@@ -48,7 +48,7 @@ impl ChunkDataAndUpdateLightPacket {
4848
primary_bit_mask: VarInt::default(),
4949
full_chunk: true,
5050
ignore_old_data: false,
51-
chunk_data: ChunkData::void(context),
51+
chunk_data: ChunkData::void(context, protocol_version),
5252
trust_edges: true,
5353
v1_18_light_data: LightData::new_void(dimension_height),
5454
}

crates/minecraft_packets/src/play/data/chunk_data.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn height_maps() -> Value {
1414

1515
#[derive(PacketOut)]
1616
pub struct ChunkData {
17-
#[pvn(..770)]
17+
#[pvn(477..770)]
1818
height_maps: Value,
1919

2020
#[pvn(770..)]
@@ -26,7 +26,7 @@ pub struct ChunkData {
2626
v1_16_2_biomes: LengthPaddedVec<VarInt>,
2727

2828
/// This array is always of length 1024
29-
#[pvn(..751)]
29+
#[pvn(393..751)]
3030
biomes: Vec<i32>,
3131

3232
data: EncodeAsBytes<Vec<ChunkSection>>,
@@ -41,10 +41,20 @@ pub struct ChunkData {
4141
}
4242

4343
impl ChunkData {
44-
pub fn void(context: VoidChunkContext) -> Self {
44+
pub fn void(context: VoidChunkContext, protocol_version: ProtocolVersion) -> Self {
4545
let root_tag = height_maps();
4646

4747
let section_count = context.dimension_height / ChunkSection::SECTION_SIZE;
48+
let biome_count = if protocol_version.is_after_inclusive(ProtocolVersion::V1_15) {
49+
1024
50+
} else {
51+
256
52+
};
53+
let chunk_sections = if protocol_version.is_after_inclusive(ProtocolVersion::V1_18) {
54+
vec![ChunkSection::void(context.biome_index); section_count as usize]
55+
} else {
56+
Vec::new()
57+
};
4858

4959
Self {
5060
height_maps: root_tag,
@@ -53,11 +63,8 @@ impl ChunkData {
5363
data: LengthPaddedVec::new(vec![0; 37]),
5464
}]),
5565
v1_16_2_biomes: LengthPaddedVec::new(vec![VarInt::new(context.biome_index); 1024]),
56-
biomes: vec![context.biome_index; 1024],
57-
data: EncodeAsBytes::new(vec![
58-
ChunkSection::void(context.biome_index);
59-
section_count as usize
60-
]),
66+
biomes: vec![context.biome_index; biome_count],
67+
data: EncodeAsBytes::new(chunk_sections),
6168
block_entities: LengthPaddedVec::default(),
6269
v1_18_block_entities: LengthPaddedVec::default(),
6370
}
@@ -70,6 +77,12 @@ impl ChunkData {
7077
) -> Self {
7178
let root_tag = height_maps();
7279

80+
let biome_count = if protocol_version.is_after_inclusive(ProtocolVersion::V1_15) {
81+
1024
82+
} else {
83+
256
84+
};
85+
7386
let mut data = Vec::new();
7487
let negative_section_count =
7588
chunk_context.dimension_min_y.abs() / ChunkSection::SECTION_SIZE;
@@ -107,7 +120,7 @@ impl ChunkData {
107120
VarInt::new(chunk_context.biome_index);
108121
1024
109122
]),
110-
biomes: vec![chunk_context.biome_index; 1024],
123+
biomes: vec![chunk_context.biome_index; biome_count],
111124
data: EncodeAsBytes::new(data),
112125
block_entities: LengthPaddedVec::new(block_entities_legacy),
113126
v1_18_block_entities: LengthPaddedVec::new(block_entities),

0 commit comments

Comments
 (0)