1
0
Mirror von https://github.com/Chaoscaot/schemsearch synchronisiert 2024-11-19 10:20:08 +01:00

Commits vergleichen

..

Keine gemeinsamen Commits. "582079c80dd52913b4fb5861404232b04fcc8baf" und "aee3a80267e087cc2d21d0bc0d16363774139fbf" haben vollständig unterschiedliche Historien.

5 geänderte Dateien mit 10 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
[package] [package]
name = "schemsearch-cli" name = "schemsearch-cli"
version = "0.1.5" version = "0.1.3"
edition = "2021" edition = "2021"
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"

Datei anzeigen

@ -1,6 +1,6 @@
[package] [package]
name = "schemsearch-files" name = "schemsearch-files"
version = "0.1.5" version = "0.1.3"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Datei anzeigen

@ -64,17 +64,7 @@ pub struct Entity {
impl SpongeSchematic { impl SpongeSchematic {
pub fn load_data<R>(data: &mut R) -> Result<SpongeSchematic, String> where R: Read { 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 nbt: CompoundTag = nbt::decode::read_gzip_compound_tag(data).map_err(|e| e.to_string())?;
let version = nbt.get_i32("Version").unwrap_or_else(|_| { let version = nbt.get_i32("Version").map_err(|e| e.to_string())?;
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 { match version {
1 => SpongeSchematic::from_nbt_1(nbt), 1 => SpongeSchematic::from_nbt_1(nbt),
@ -100,7 +90,7 @@ impl SpongeSchematic {
palette_max: nbt.get_i32("PaletteMax").map_err(|e| e.to_string())?, 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())?), 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_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").unwrap_or_else(|_| vec![]))?, block_entities: read_tile_entities(nbt.get_compound_tag_vec("TileEntities").map_err(|e| e.to_string())?)?,
entities: None, entities: None,
}) })
} }
@ -116,7 +106,7 @@ impl SpongeSchematic {
palette_max: nbt.get_i32("PaletteMax").map_err(|e| e.to_string())?, 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())?), 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_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").unwrap_or_else(|_| vec![]))?, block_entities: read_tile_entities(nbt.get_compound_tag_vec("BlockEntities").map_err(|e| e.to_string())?)?,
entities: None, entities: None,
}) })
} }
@ -133,7 +123,7 @@ impl SpongeSchematic {
palette_max: compute_palette_max(blocks.get_compound_tag("Palette").map_err(|e| e.to_string())?), 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())?), 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_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").unwrap_or_else(|_| vec![]))?, block_entities: read_tile_entities(blocks.get_compound_tag_vec("BlockEntities").map_err(|e| e.to_string())?)?,
entities: None, entities: None,
}) })
} }

Datei anzeigen

@ -1,6 +1,6 @@
[package] [package]
name = "schemsearch-lib" name = "schemsearch-lib"
version = "0.1.5" version = "0.1.3"
edition = "2021" edition = "2021"
license = "AGPL-3.0-or-later" license = "AGPL-3.0-or-later"

Datei anzeigen

@ -37,7 +37,7 @@ pub fn strip_data(schem: &SpongeSchematic) -> SpongeSchematic {
let reverse_palette = create_reverse_palette(schem); let reverse_palette = create_reverse_palette(schem);
for block in schem.block_data.iter() { for block in schem.block_data.iter() {
let block_name = reverse_palette[*block as usize]; let block_name = reverse_palette[*block as usize].clone();
let block_name = block_name.split('[').next().unwrap().to_string(); let block_name = block_name.split('[').next().unwrap().to_string();
let entry = palette.entry(block_name).or_insert_with(|| { let entry = palette.entry(block_name).or_insert_with(|| {
@ -61,6 +61,8 @@ pub fn strip_data(schem: &SpongeSchematic) -> SpongeSchematic {
offset: [0; 3], offset: [0; 3],
entities: None, entities: None,
} }
} }
pub fn match_palette_adapt(schem: &SpongeSchematic, matching_palette: &HashMap<String, i32>, ignore_data: bool) -> Vec<i32> { pub fn match_palette_adapt(schem: &SpongeSchematic, matching_palette: &HashMap<String, i32>, ignore_data: bool) -> Vec<i32> {