Mirror von
https://github.com/Chaoscaot/schemsearch
synchronisiert 2024-12-17 15:30:06 +01:00
Fix Broken Schematics Loading
Dieser Commit ist enthalten in:
Ursprung
aee3a80267
Commit
e25aeab065
@ -64,7 +64,17 @@ pub struct Entity {
|
||||
impl SpongeSchematic {
|
||||
pub fn load_data<R>(data: &mut R) -> Result<SpongeSchematic, String> where R: Read {
|
||||
let nbt: CompoundTag = nbt::decode::read_gzip_compound_tag(data).map_err(|e| e.to_string())?;
|
||||
let version = nbt.get_i32("Version").map_err(|e| e.to_string())?;
|
||||
let version = nbt.get_i32("Version").unwrap_or_else(|_| {
|
||||
return if nbt.contains_key("Blocks") {
|
||||
3
|
||||
} else if nbt.contains_key("BlockEntities") {
|
||||
2
|
||||
} else if nbt.contains_key("TileEntities") {
|
||||
1
|
||||
} else {
|
||||
-1
|
||||
};
|
||||
});
|
||||
|
||||
match version {
|
||||
1 => SpongeSchematic::from_nbt_1(nbt),
|
||||
@ -90,7 +100,7 @@ impl SpongeSchematic {
|
||||
palette_max: nbt.get_i32("PaletteMax").map_err(|e| e.to_string())?,
|
||||
palette: read_palette(nbt.get_compound_tag("Palette").map_err(|e| e.to_string())?),
|
||||
block_data: read_blocks(nbt.get_i8_vec("BlockData").map_err(|e| e.to_string())?),
|
||||
block_entities: read_tile_entities(nbt.get_compound_tag_vec("TileEntities").map_err(|e| e.to_string())?)?,
|
||||
block_entities: read_tile_entities(nbt.get_compound_tag_vec("TileEntities").unwrap_or_else(|_| vec![]))?,
|
||||
entities: None,
|
||||
})
|
||||
}
|
||||
@ -106,7 +116,7 @@ impl SpongeSchematic {
|
||||
palette_max: nbt.get_i32("PaletteMax").map_err(|e| e.to_string())?,
|
||||
palette: read_palette(nbt.get_compound_tag("Palette").map_err(|e| e.to_string())?),
|
||||
block_data: read_blocks(nbt.get_i8_vec("BlockData").map_err(|e| e.to_string())?),
|
||||
block_entities: read_tile_entities(nbt.get_compound_tag_vec("BlockEntities").map_err(|e| e.to_string())?)?,
|
||||
block_entities: read_tile_entities(nbt.get_compound_tag_vec("BlockEntities").unwrap_or_else(|_| vec![]))?,
|
||||
entities: None,
|
||||
})
|
||||
}
|
||||
@ -123,7 +133,7 @@ impl SpongeSchematic {
|
||||
palette_max: compute_palette_max(blocks.get_compound_tag("Palette").map_err(|e| e.to_string())?),
|
||||
palette: read_palette(blocks.get_compound_tag("Palette").map_err(|e| e.to_string())?),
|
||||
block_data: read_blocks(blocks.get_i8_vec("BlockData").map_err(|e| e.to_string())?),
|
||||
block_entities: read_tile_entities(blocks.get_compound_tag_vec("BlockEntities").map_err(|e| e.to_string())?)?,
|
||||
block_entities: read_tile_entities(blocks.get_compound_tag_vec("BlockEntities").unwrap_or_else(|_| vec![]))?,
|
||||
entities: None,
|
||||
})
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ pub fn strip_data(schem: &SpongeSchematic) -> SpongeSchematic {
|
||||
let reverse_palette = create_reverse_palette(schem);
|
||||
|
||||
for block in schem.block_data.iter() {
|
||||
let block_name = reverse_palette[*block as usize].clone();
|
||||
let block_name = reverse_palette[*block as usize];
|
||||
let block_name = block_name.split('[').next().unwrap().to_string();
|
||||
|
||||
let entry = palette.entry(block_name).or_insert_with(|| {
|
||||
@ -61,8 +61,6 @@ pub fn strip_data(schem: &SpongeSchematic) -> SpongeSchematic {
|
||||
offset: [0; 3],
|
||||
entities: None,
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
pub fn match_palette_adapt(schem: &SpongeSchematic, matching_palette: &HashMap<String, i32>, ignore_data: bool) -> Vec<i32> {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren