From 67841f9b2e7a693412ed90e764b9a14b6d12de88 Mon Sep 17 00:00:00 2001 From: ice_iix Date: Sat, 12 Jan 2019 10:40:57 -0800 Subject: [PATCH] Fix missing pre-flattening blocks (deadbush, etc.). Closes #89 Blocks not present after "the flattening" (1.13.2) were not registered for older versions (hierarchical, pre-1.13). This wasn't noticed when implementing #67 since almost all blocks pre-flattening also have flattened IDs. The exceptions are when the blocks were removed or moved, such as dead bush - hierarchical id 32, which is now a block state of tallgrass instead. But it is still needed pre-flattening, due a logic error these were skipped. Fix pre-flattening block ID registration by moving the conditional clause for vanilla_id outside of the offset conditional. --- blocks/src/lib.rs | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/blocks/src/lib.rs b/blocks/src/lib.rs index 53c0dd8..bdbc9cc 100644 --- a/blocks/src/lib.rs +++ b/blocks/src/lib.rs @@ -391,21 +391,27 @@ macro_rules! define_blocks { blocks_flat[id] ); } + } - if let Some(vanilla_id) = vanilla_id { - if blocks_hier.len() <= vanilla_id { - blocks_hier.resize(vanilla_id + 1, None); - } - if blocks_hier[vanilla_id].is_none() { - blocks_hier[vanilla_id] = Some(block); - } else { - panic!( - "Tried to register {:#?} to {} but {:#?} was already registered", - block, - id, - blocks_hier[vanilla_id] - ); - } + if let Some(vanilla_id) = vanilla_id { + /* + if offset.is_none() { + println!("(no flat) block state = {:?} hierarchical {}:{}", block, vanilla_id >> 4, vanilla_id & 0xF); + } + */ + + if blocks_hier.len() <= vanilla_id { + blocks_hier.resize(vanilla_id + 1, None); + } + if blocks_hier[vanilla_id].is_none() { + blocks_hier[vanilla_id] = Some(block); + } else { + panic!( + "Tried to register {:#?} to {} but {:#?} was already registered", + block, + vanilla_id, + blocks_hier[vanilla_id] + ); } } }