Skip to content

Commit 8e1c52a

Browse files
committed
feat: modern art feature flag
1 parent ca42e5e commit 8e1c52a

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ uuid = "1.11.0"
4848
default = []
4949
compression = []
5050
encryption = ["dep:cfb8", "dep:aes"]
51+
modern_art = []
5152
lan = []
5253

5354
full = ["compression", "encryption"]

src/protocol/packets/play/world.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,35 @@ impl ChunkSection {
195195
pub fn anvil_to_sec(value: &world::Section, block_states: &Blocks) -> Self {
196196
let mut blocks: [i16; 16 * 16 * 16] = [0; 16 * 16 * 16];
197197
let bit_length = (64 - (value.block_states.palette.len() as u64).leading_zeros()).max(4);
198+
199+
#[cfg(not(feature = "modern_art"))]
198200
let blocks_per_long = 64 / bit_length;
199201

202+
#[cfg(not(feature = "modern_art"))]
200203
let bit_mask = (1 << bit_length) - 1;
201204

202205
match value.block_states.data {
203206
None => blocks.fill(0),
204207
Some(ref data) => {
205208
let mut i = 0;
206209
for long in data.iter() {
207-
let long = *long as u64;
208-
for b in 0..blocks_per_long {
209-
blocks[i] = ((long >> (bit_length * b)) & bit_mask) as i16;
210-
i += 1;
210+
#[cfg(not(feature = "modern_art"))]
211+
{
212+
let long = *long as u64;
213+
for b in 0..blocks_per_long {
214+
blocks[i] = ((long >> (bit_length * b)) & bit_mask) as i16;
215+
i += 1;
216+
}
217+
}
218+
219+
#[cfg(feature = "modern_art")]
220+
{
221+
let mut long = *long as u64;
222+
while long != 0 {
223+
blocks[i] = (long & ((1 << bit_length) - 1)) as i16;
224+
long >>= bit_length;
225+
i += 1;
226+
}
211227
}
212228
}
213229
}

0 commit comments

Comments
 (0)