From d7fc95c950e4f211785bdbfcd6364f60e9085763 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 11 Jan 2025 02:10:00 +0100 Subject: [PATCH 01/55] README.md: fix size reduction estimate for WebP tiles I accidentally measured the output size including the `processed` directory for the previous numbers. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ea4856..7d60f78 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ updates more quickly. ### Image formats MinedMap renders map tiles as PNG by default. Pass `--image-format webp` to select -WebP instead. For typical Minecraft worlds, using WebP reduces file sizes by 10-15% +WebP instead. For typical Minecraft worlds, using WebP reduces file sizes by 20-25% without increasing processing time. MinedMap always uses lossless compression for tile images, regardless of the From a10151a4f37775d76150f03cc94dd32bd4c4705c Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 11 Feb 2025 22:39:11 +0100 Subject: [PATCH 02/55] resource, world: implement fallback to plains for unknown biomes Closes #63 --- CHANGELOG.md | 6 ++++++ crates/resource/src/lib.rs | 11 +++++++++++ src/core/common.rs | 2 +- src/world/layer.rs | 16 ++++++++-------- src/world/section.rs | 20 +++++++++++--------- 5 files changed, 37 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e75a75b..7745ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] - ReleaseDate +### Changed + +- Unknown biome types (from not yet supported or modded versions of Minecraft) + will now use plains biome colors as a fallback instead of resulting in water, + grass and foliage blocks to be rendered as transparent pixels + ## [2.4.0] - 2025-01-11 ### Added diff --git a/crates/resource/src/lib.rs b/crates/resource/src/lib.rs index fed9514..a633d06 100644 --- a/crates/resource/src/lib.rs +++ b/crates/resource/src/lib.rs @@ -247,6 +247,8 @@ pub struct BiomeTypes { biome_map: HashMap, /// Array used to look up old numeric biome IDs legacy_biomes: Box<[&'static Biome; 256]>, + /// Fallback for unknown (new/modded) biomes + fallback_biome: &'static Biome, } impl Default for BiomeTypes { @@ -273,9 +275,12 @@ impl Default for BiomeTypes { .try_into() .unwrap(); + let fallback_biome = *biome_map.get("plains").expect("Plains biome undefined"); + Self { biome_map, legacy_biomes, + fallback_biome, } } } @@ -293,4 +298,10 @@ impl BiomeTypes { pub fn get_legacy(&self, id: u8) -> Option<&Biome> { Some(self.legacy_biomes[id as usize]) } + + /// Returns the fallback for unknown (new/modded) biomes + #[inline] + pub fn get_fallback(&self) -> &Biome { + self.fallback_biome + } } diff --git a/src/core/common.rs b/src/core/common.rs index b933dcd..edefcb3 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -25,7 +25,7 @@ use crate::{ /// /// Increase when the generation of processed regions from region data changes /// (usually because of updated resource data) -pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(3); +pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(4); /// MinedMap map tile data version number /// diff --git a/src/world/layer.rs b/src/world/layer.rs index 0764711..e59593c 100644 --- a/src/world/layer.rs +++ b/src/world/layer.rs @@ -97,14 +97,14 @@ impl LayerEntry<'_> { if self.is_empty() { *self.block = Some(block_type.block_color); - if let Some(biome) = section.biomes.biome_at(section.y, coords)? { - let (biome_index, _) = biome_list.insert_full(*biome); - *self.biome = NonZeroU16::new( - (biome_index + 1) - .try_into() - .expect("biome index not in range"), - ); - } + + let biome = section.biomes.biome_at(section.y, coords)?; + let (biome_index, _) = biome_list.insert_full(*biome); + *self.biome = NonZeroU16::new( + (biome_index + 1) + .try_into() + .expect("biome index not in range"), + ); } if block_type.block_color.is(BlockFlag::Water) { diff --git a/src/world/section.rs b/src/world/section.rs index 7988fd5..845ddae 100644 --- a/src/world/section.rs +++ b/src/world/section.rs @@ -208,7 +208,7 @@ impl Section for SectionV0<'_> { /// Trait for common functions of [BiomesV1_18] and [BiomesV0] pub trait Biomes: Debug { /// Returns the [Biome] at a coordinate tuple inside the chunk - fn biome_at(&self, section: SectionY, coords: SectionBlockCoords) -> Result>; + fn biome_at(&self, section: SectionY, coords: SectionBlockCoords) -> Result<&Biome>; } /// Minecraft v1.18+ section biome data @@ -226,7 +226,7 @@ pub struct BiomesV1_18<'a> { /// to whole i64 values. biomes: Option<&'a [i64]>, /// Biome palette indexed by entries encoded in *biomes* - palette: Vec>, + palette: Vec<&'a Biome>, /// Number of bits used for each entry in *biomes* bits: u8, } @@ -253,12 +253,11 @@ impl<'a> BiomesV1_18<'a> { let palette_types = palette .iter() .map(|entry| { - let biome_type = biome_types.get(entry); - if biome_type.is_none() { + biome_types.get(entry).unwrap_or_else(|| { debug!("Unknown biome type: {}", entry); has_unknown = true; - } - biome_type + biome_types.get_fallback() + }) }) .collect(); @@ -295,7 +294,7 @@ impl<'a> BiomesV1_18<'a> { } impl Biomes for BiomesV1_18<'_> { - fn biome_at(&self, _section: SectionY, coords: SectionBlockCoords) -> Result> { + fn biome_at(&self, _section: SectionY, coords: SectionBlockCoords) -> Result<&Biome> { let index = self.palette_index_at(coords); Ok(*self .palette @@ -350,7 +349,7 @@ impl<'a> BiomesV0<'a> { } impl Biomes for BiomesV0<'_> { - fn biome_at(&self, section: SectionY, coords: SectionBlockCoords) -> Result> { + fn biome_at(&self, section: SectionY, coords: SectionBlockCoords) -> Result<&Biome> { let id = match self.data { BiomesV0Data::IntArrayV15(data) => { let LayerBlockCoords { x, z } = coords.xz; @@ -370,7 +369,10 @@ impl Biomes for BiomesV0<'_> { } BiomesV0Data::ByteArray(data) => data[coords.xz.offset()] as u8, }; - Ok(self.biome_types.get_legacy(id)) + Ok(self + .biome_types + .get_legacy(id) + .unwrap_or(self.biome_types.get_fallback())) } } From 0dd36a409a84438afd1e7bc768d5619ae3ff6053 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 11 Feb 2025 23:03:33 +0100 Subject: [PATCH 03/55] Update dependencies Signed-off-by: Matthias Schiffer --- Cargo.lock | 239 +++++++++++------------------------------------------ Cargo.toml | 2 +- 2 files changed, 50 insertions(+), 191 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b6de78..317eb46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,11 +73,12 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "3.0.6" +version = "3.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", + "once_cell", "windows-sys", ] @@ -125,9 +126,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" [[package]] name = "bytemuck" @@ -149,9 +150,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cc" -version = "1.2.7" +version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7" +checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" dependencies = [ "jobserver", "libc", @@ -172,9 +173,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.26" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" dependencies = [ "clap_builder", "clap_derive", @@ -182,9 +183,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.26" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" dependencies = [ "anstream", "anstyle", @@ -195,9 +196,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck", "proc-macro2", @@ -213,9 +214,9 @@ checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" [[package]] name = "cmake" -version = "0.1.52" +version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c682c223677e0e5b6b7f63a64b9351844c3f1b1678a68b7ee617e30fb082620e" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" dependencies = [ "cc", ] @@ -288,9 +289,9 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" +checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" dependencies = [ "enumflags2_derive", "serde", @@ -298,9 +299,9 @@ dependencies = [ [[package]] name = "enumflags2_derive" -version = "0.7.10" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" +checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" dependencies = [ "proc-macro2", "quote", @@ -313,16 +314,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" -[[package]] -name = "erased-serde" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" -dependencies = [ - "serde", - "typeid", -] - [[package]] name = "errno" version = "0.3.10" @@ -478,9 +469,9 @@ dependencies = [ [[package]] name = "image-webp" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e031e8e3d94711a9ccb5d6ea357439ef3dcbed361798bd4071dc4d9793fbe22f" +checksum = "b77d01e822461baa8409e156015a1d91735549f0f2c17691bd2d996bef238f7f" dependencies = [ "byteorder-lite", "quick-error", @@ -488,9 +479,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -567,18 +558,15 @@ dependencies = [ [[package]] name = "log" -version = "0.4.24" +version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6ea2a48c204030ee31a7d7fc72c93294c92fe87ecb1789881c9543516e1a0d" -dependencies = [ - "value-bag", -] +checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" [[package]] name = "lru" -version = "0.12.5" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" dependencies = [ "hashbrown", ] @@ -652,9 +640,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" +checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", "simd-adler32", @@ -709,9 +697,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "overload" @@ -817,9 +805,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.92" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" dependencies = [ "unicode-ident", ] @@ -880,7 +868,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", ] [[package]] @@ -920,17 +908,17 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.7.0", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -939,9 +927,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.18" +version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" [[package]] name = "scopeguard" @@ -978,20 +966,11 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_fmt" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d4ddca14104cd60529e8c7f7ba71a2c8acd8f7f5cfcdc2faf97eeb7c3010a4" -dependencies = [ - "serde", -] - [[package]] name = "serde_json" -version = "1.0.135" +version = "1.0.138" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" +checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" dependencies = [ "itoa", "memchr", @@ -1047,89 +1026,11 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "sval" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6dc0f9830c49db20e73273ffae9b5240f63c42e515af1da1fceefb69fceafd8" - -[[package]] -name = "sval_buffer" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "429922f7ad43c0ef8fd7309e14d750e38899e32eb7e8da656ea169dd28ee212f" -dependencies = [ - "sval", - "sval_ref", -] - -[[package]] -name = "sval_dynamic" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f16ff5d839396c11a30019b659b0976348f3803db0626f736764c473b50ff4" -dependencies = [ - "sval", -] - -[[package]] -name = "sval_fmt" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c01c27a80b6151b0557f9ccbe89c11db571dc5f68113690c1e028d7e974bae94" -dependencies = [ - "itoa", - "ryu", - "sval", -] - -[[package]] -name = "sval_json" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0deef63c70da622b2a8069d8600cf4b05396459e665862e7bdb290fd6cf3f155" -dependencies = [ - "itoa", - "ryu", - "sval", -] - -[[package]] -name = "sval_nested" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a39ce5976ae1feb814c35d290cf7cf8cd4f045782fe1548d6bc32e21f6156e9f" -dependencies = [ - "sval", - "sval_buffer", - "sval_ref", -] - -[[package]] -name = "sval_ref" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7c6ee3751795a728bc9316a092023529ffea1783499afbc5c66f5fabebb1fa" -dependencies = [ - "sval", -] - -[[package]] -name = "sval_serde" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5572d0321b68109a343634e3a5d576bf131b82180c6c442dee06349dfc652a" -dependencies = [ - "serde", - "sval", - "sval_nested", -] - [[package]] name = "syn" -version = "2.0.96" +version = "2.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" dependencies = [ "proc-macro2", "quote", @@ -1224,17 +1125,11 @@ dependencies = [ "tracing-log", ] -[[package]] -name = "typeid" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" - [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" [[package]] name = "utf8parse" @@ -1244,45 +1139,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "valuable" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "value-bag" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef4c4aa54d5d05a279399bfa921ec387b7aba77caf7a682ae8d86785b8fdad2" -dependencies = [ - "value-bag-serde1", - "value-bag-sval2", -] - -[[package]] -name = "value-bag-serde1" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bb773bd36fd59c7ca6e336c94454d9c66386416734817927ac93d81cb3c5b0b" -dependencies = [ - "erased-serde", - "serde", - "serde_fmt", -] - -[[package]] -name = "value-bag-sval2" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a916a702cac43a88694c97657d449775667bcd14b70419441d05b7fea4a83a" -dependencies = [ - "sval", - "sval_buffer", - "sval_dynamic", - "sval_fmt", - "sval_json", - "sval_ref", - "sval_serde", -] +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" [[package]] name = "winapi" diff --git a/Cargo.toml b/Cargo.toml index 2412edb..b821d83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ futures-util = "0.3.28" git-version = "0.3.5" image = { version = "0.25.1", default-features = false, features = ["png", "webp"] } indexmap = { version = "2.0.0", features = ["serde"] } -lru = "0.12.0" +lru = "0.13.0" minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } minedmap-resource = { version = "0.6.0", path = "crates/resource" } minedmap-types = { version = "0.1.4", path = "crates/types" } From d96bb727f72ed6536c183782dc8eb22df82ea7d3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 11 Feb 2025 23:04:08 +0100 Subject: [PATCH 04/55] ci: upgrade to upload-artifact v4 --- .github/workflows/MinedMap.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index c2e9961..cf75b68 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -27,7 +27,7 @@ jobs: cp -r viewer/* "$pkgdir"/ - name: 'Archive' - uses: 'actions/upload-artifact@v3' + uses: 'actions/upload-artifact@v4' with: name: 'MinedMap-${{ steps.tag.outputs.tag }}-viewer' path: 'build/pkg' @@ -134,7 +134,7 @@ jobs: cp target/${{ matrix.target }}/release/minedmap${{ matrix.ext }} "$pkgdir"/ - name: 'Archive' - uses: 'actions/upload-artifact@v3' + uses: 'actions/upload-artifact@v4' with: name: 'MinedMap-${{ steps.tag.outputs.tag }}-${{ matrix.target }}' path: 'target/pkg' From 1d9be9a41cbfd665c41dbf5d7bfc2ba16584a224 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 12 Feb 2025 20:22:26 +0100 Subject: [PATCH 05/55] Add jemalloc and jemalloc-auto features Introduce the new features jemalloc (set jemalloc global allocator unconditionally) and jemalloc-auto (set jemalloc global allocator on musl-based targets to fix multithreaded performance, see [1]). Because cargo does not support target-specific features or feature defaults, the default is handled using a helper crate minedmap-default-alloc. [1] https://nickb.dev/blog/default-musl-allocator-considered-harmful-to-performance/ --- CHANGELOG.md | 22 ++++++++++++++++++++++ Cargo.lock | 28 ++++++++++++++++++++++++++++ Cargo.toml | 5 ++++- crates/default-alloc/Cargo.toml | 17 +++++++++++++++++ crates/default-alloc/src/lib.rs | 3 +++ src/main.rs | 3 +++ 6 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 crates/default-alloc/Cargo.toml create mode 100644 crates/default-alloc/src/lib.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 7745ced..bec566e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ ## [Unreleased] - ReleaseDate +### Added + +- Added jemalloc support to fix performace on musl targets + + The global allocator can be switched to jemalloc by enabling the `jemalloc` + cargo feature now. This is not the default because it is not always faster + than the default system allocator; in particular, the glibc allocator has + slightly better performance in multithreaded mode. In addition, jemalloc + uses a bit more memory. + + In addition, the `jemalloc-auto` feature has been introduced, which is enabled + by default and sets the global allocator to jemalloc on platforms where it is + clearly advantageous. For now, this is only done on musl-based targets, as + musl's default allocator is very slow in multithreaded operation (which was + making higher thread counts like `-j8` basically useless due to 7-8x + slowdowns). With the new default, performance on musl is basically identical + to glibc. + + Note that some platforms like `msvc` are unsupported by jemalloc, and trying + to enable the `jemalloc` feature on these platforms may break the MinedMap + build or cause issues at runtime. + ### Changed - Unknown biome types (from not yet supported or modded versions of Minecraft) diff --git a/Cargo.lock b/Cargo.lock index 317eb46..eeaede2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -591,6 +591,7 @@ dependencies = [ "image", "indexmap", "lru", + "minedmap-default-alloc", "minedmap-nbt", "minedmap-resource", "minedmap-types", @@ -608,6 +609,13 @@ dependencies = [ "zstd", ] +[[package]] +name = "minedmap-default-alloc" +version = "0.1.0" +dependencies = [ + "tikv-jemallocator", +] + [[package]] name = "minedmap-nbt" version = "0.1.1" @@ -1057,6 +1065,26 @@ dependencies = [ "once_cell", ] +[[package]] +name = "tikv-jemalloc-sys" +version = "0.6.0+5.3.0-1-ge13ca993e8ccb9ba9847cc330696e02839f328f7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd3c60906412afa9c2b5b5a48ca6a5abe5736aec9eb48ad05037a677e52e4e2d" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "tikv-jemallocator" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cec5ff18518d81584f477e9bfdf957f5bb0979b0bac3af4ca30b5b3ae2d2865" +dependencies = [ + "libc", + "tikv-jemalloc-sys", +] + [[package]] name = "tokio" version = "1.43.0" diff --git a/Cargo.toml b/Cargo.toml index b821d83..998de6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ git-version = "0.3.5" image = { version = "0.25.1", default-features = false, features = ["png", "webp"] } indexmap = { version = "2.0.0", features = ["serde"] } lru = "0.13.0" +minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } minedmap-resource = { version = "0.6.0", path = "crates/resource" } minedmap-types = { version = "0.1.4", path = "crates/types" } @@ -64,5 +65,7 @@ tracing-subscriber = "0.3.17" zstd = "0.13.0" [features] -default = ["zlib-ng"] +default = ["jemalloc-auto", "zlib-ng"] +jemalloc-auto = ["dep:minedmap-default-alloc"] +jemalloc = ["jemalloc-auto", "minedmap-default-alloc/jemalloc"] zlib-ng = ["minedmap-nbt/zlib-ng"] diff --git a/crates/default-alloc/Cargo.toml b/crates/default-alloc/Cargo.toml new file mode 100644 index 0000000..40f9e7e --- /dev/null +++ b/crates/default-alloc/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "minedmap-default-alloc" +version = "0.1.0" +description = "Helper crate for target-specific selection of global allocator default" +edition.workspace = true +license.workspace = true +readme.workspace = true +repository.workspace = true + +[dependencies] +tikv-jemallocator = { version = "0.6.0", optional = true } + +[target.'cfg(target_env = "musl")'.dependencies] +tikv-jemallocator = "*" + +[features] +jemalloc = ["dep:tikv-jemallocator"] diff --git a/crates/default-alloc/src/lib.rs b/crates/default-alloc/src/lib.rs new file mode 100644 index 0000000..0797a5f --- /dev/null +++ b/crates/default-alloc/src/lib.rs @@ -0,0 +1,3 @@ +#[cfg(any(target_env = "musl", feature = "jemalloc"))] +#[global_allocator] +static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; diff --git a/src/main.rs b/src/main.rs index 31f2889..1f19a41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,9 @@ #![warn(missing_docs)] #![warn(clippy::missing_docs_in_private_items)] +#[cfg(feature = "jemalloc-auto")] +extern crate minedmap_default_alloc; + mod core; mod io; mod util; From 971afea727210f9745a82b27a56d0c7fac2725d8 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 21 Feb 2025 10:55:36 +0100 Subject: [PATCH 06/55] Fix new clippy warnings --- src/core/tile_renderer.rs | 2 +- src/util.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/tile_renderer.rs b/src/core/tile_renderer.rs index a972b78..24af234 100644 --- a/src/core/tile_renderer.rs +++ b/src/core/tile_renderer.rs @@ -134,7 +134,7 @@ impl<'a> TileRenderer<'a> { /// Hashing the value as a single u32 is more efficient than hashing /// the tuple elements separately. fn biome_key((dx, dz, index): (i8, i8, u16)) -> u32 { - (dx as u8 as u32) | (dz as u8 as u32) << 8 | (index as u32) << 16 + (dx as u8 as u32) | ((dz as u8 as u32) << 8) | ((index as u32) << 16) } /// One quadrant of the kernel used to smooth biome edges diff --git a/src/util.rs b/src/util.rs index a128ef9..ed07ba5 100644 --- a/src/util.rs +++ b/src/util.rs @@ -39,7 +39,9 @@ pub fn to_flat_coord( chunk: ChunkCoord, block: BlockCoord, ) -> i32 { - (region as i32) << (BLOCK_BITS + CHUNK_BITS) | ((chunk.0 as i32) << BLOCK_BITS | block.0 as i32) + ((region as i32) << (BLOCK_BITS + CHUNK_BITS)) + | ((chunk.0 as i32) << BLOCK_BITS) + | (block.0 as i32) } /// Splits a flat (linear) coordinate into region, chunk and block numbers From 37126f69fcb9d6d5bbd31ad0a0b34fd522a733bb Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Feb 2025 20:10:50 +0100 Subject: [PATCH 07/55] MetadataWriter: add fallback to level.dat_old Looking at inotify dumps, it appears like because of bad implementation choices, Minecraft's level.dat may not exist for a brief moment between moving the old file to level.dat_old and moving a new version into place. Add a fallback to level.dat_old, so generation will not fail if were unlucky enough to hit this moment. --- src/core/common.rs | 6 ++++++ src/core/metadata_writer.rs | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/common.rs b/src/core/common.rs index edefcb3..d311773 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -139,6 +139,8 @@ pub struct Config { pub region_dir: PathBuf, /// Path of input `level.dat` file pub level_dat_path: PathBuf, + /// Path of input `level.dat_old` file + pub level_dat_old_path: PathBuf, /// Base path for storage of rendered tile data pub output_dir: PathBuf, /// Path for storage of intermediate processed data files @@ -170,6 +172,9 @@ impl Config { let region_dir = [&args.input_dir, Path::new("region")].iter().collect(); let level_dat_path = [&args.input_dir, Path::new("level.dat")].iter().collect(); + let level_dat_old_path = [&args.input_dir, Path::new("level.dat_old")] + .iter() + .collect(); let processed_dir: PathBuf = [&args.output_dir, Path::new("processed")].iter().collect(); let entities_dir: PathBuf = [&processed_dir, Path::new("entities")].iter().collect(); let entities_path_final = [&entities_dir, Path::new("entities.bin")].iter().collect(); @@ -186,6 +191,7 @@ impl Config { num_threads, region_dir, level_dat_path, + level_dat_old_path, output_dir: args.output_dir.clone(), processed_dir, entities_dir, diff --git a/src/core/metadata_writer.rs b/src/core/metadata_writer.rs index 92d8566..eb5f59f 100644 --- a/src/core/metadata_writer.rs +++ b/src/core/metadata_writer.rs @@ -124,7 +124,14 @@ impl<'a> MetadataWriter<'a> { /// Reads and deserializes the `level.dat` of the Minecraft save data fn read_level_dat(&self) -> Result { - crate::nbt::data::from_file(&self.config.level_dat_path).context("Failed to read level.dat") + let res = crate::nbt::data::from_file(&self.config.level_dat_path); + if res.is_err() { + if let Ok(level_dat_old) = crate::nbt::data::from_file(&self.config.level_dat_old_path) + { + return Ok(level_dat_old); + } + } + res.context("Failed to read level.dat") } /// Generates [Spawn] data from a [de::LevelDat] From c10e9e490203356633aa6fccc9240bf925147776 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Feb 2025 19:56:19 +0100 Subject: [PATCH 08/55] Implement watch mode --- CHANGELOG.md | 16 +++++ Cargo.lock | 170 +++++++++++++++++++++++++++++++++++++++++++-- Cargo.toml | 2 + src/core/common.rs | 4 ++ src/core/mod.rs | 116 ++++++++++++++++++++++++++++--- 5 files changed, 292 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bec566e..e8fd052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ ### Added +- Added experimental watch mode + + Passing `--watch` will cause MinedMap to run continuously instead of exiting + after map generation, regenerating tiles whenever they change. + + `--watch-delay` can be used to configure the delay between detecting a change + and runing the map generation, also limiting how often the regeneration + happens. This defaults to `30s`; significantly smaller values probably don't + make sense because Minecraft writes out changes in batches anyways. + + Finally, `--jobs-initial` can be used to configure the number of parallel + generation threads for the initial cycle separately from the value used for + subsequent cycles after a change is detected (`-j`/`--jobs`). Subsequent + cycles usually need to regenerate only a small number of tiles, so setting + `--jobs` to a smaller value than `--jobs-initial` may be advantageous. + - Added jemalloc support to fix performace on musl targets The global allocator can be switched to jemalloc by enabling the `jemalloc` diff --git a/Cargo.lock b/Cargo.lock index eeaede2..039e940 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,7 +68,7 @@ version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -79,7 +79,7 @@ checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" dependencies = [ "anstyle", "once_cell", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -321,7 +321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -345,6 +345,18 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + [[package]] name = "flate2" version = "1.0.35" @@ -362,6 +374,15 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +[[package]] +name = "fsevent-sys" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" +dependencies = [ + "libc", +] + [[package]] name = "futures-core" version = "0.3.31" @@ -454,6 +475,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "image" version = "0.25.5" @@ -488,6 +515,26 @@ dependencies = [ "serde", ] +[[package]] +name = "inotify" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" +dependencies = [ + "bitflags 2.8.0", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" +dependencies = [ + "libc", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -518,6 +565,26 @@ dependencies = [ "libc", ] +[[package]] +name = "kqueue" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" +dependencies = [ + "bitflags 1.3.2", + "libc", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -530,6 +597,17 @@ version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.8.0", + "libc", + "redox_syscall", +] + [[package]] name = "libz-ng-sys" version = "1.1.21" @@ -588,6 +666,7 @@ dependencies = [ "fastnbt", "futures-util", "git-version", + "humantime", "image", "indexmap", "lru", @@ -595,6 +674,7 @@ dependencies = [ "minedmap-nbt", "minedmap-resource", "minedmap-types", + "notify", "num-integer", "num_cpus", "phf", @@ -656,6 +736,43 @@ dependencies = [ "simd-adler32", ] +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.52.0", +] + +[[package]] +name = "notify" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" +dependencies = [ + "bitflags 2.8.0", + "filetime", + "fsevent-sys", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "notify-types", + "walkdir", + "windows-sys 0.59.0", +] + +[[package]] +name = "notify-types" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e0826a989adedc2a244799e823aece04662b66609d96af8dff7ac6df9a8925d" + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -930,7 +1047,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -939,6 +1056,15 @@ version = "1.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1052,7 +1178,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" dependencies = [ "rustix", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -1171,6 +1297,22 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "winapi" version = "0.3.9" @@ -1187,12 +1329,30 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-sys" version = "0.59.0" diff --git a/Cargo.toml b/Cargo.toml index 998de6c..d213a56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ enum-map = "2.7.3" fastnbt = "2.3.2" futures-util = "0.3.28" git-version = "0.3.5" +humantime = "2.1.0" image = { version = "0.25.1", default-features = false, features = ["png", "webp"] } indexmap = { version = "2.0.0", features = ["serde"] } lru = "0.13.0" @@ -51,6 +52,7 @@ minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", opt minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } minedmap-resource = { version = "0.6.0", path = "crates/resource" } minedmap-types = { version = "0.1.4", path = "crates/types" } +notify = "8.0.0" num-integer = "0.1.45" num_cpus = "1.16.0" phf = { version = "0.11.2", features = ["macros"] } diff --git a/src/core/common.rs b/src/core/common.rs index d311773..a81dbf2 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -135,6 +135,8 @@ pub enum TileKind { pub struct Config { /// Number of threads for parallel processing pub num_threads: usize, + /// Number of threads for initial parallel processing + pub num_threads_initial: usize, /// Path of input region directory pub region_dir: PathBuf, /// Path of input `level.dat` file @@ -169,6 +171,7 @@ impl Config { Some(threads) => threads, None => 1, }; + let num_threads_initial = args.jobs_initial.unwrap_or(num_threads); let region_dir = [&args.input_dir, Path::new("region")].iter().collect(); let level_dat_path = [&args.input_dir, Path::new("level.dat")].iter().collect(); @@ -189,6 +192,7 @@ impl Config { Ok(Config { num_threads, + num_threads_initial, region_dir, level_dat_path, level_dat_old_path, diff --git a/src/core/mod.rs b/src/core/mod.rs index 5832379..202d017 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -10,7 +10,12 @@ mod tile_merger; mod tile_mipmapper; mod tile_renderer; -use std::path::PathBuf; +use std::{ + path::PathBuf, + sync::mpsc::{self, Receiver}, + thread, + time::Duration, +}; use anyhow::{Context, Result}; use clap::Parser; @@ -18,9 +23,13 @@ use git_version::git_version; use common::{Config, ImageFormat}; use metadata_writer::MetadataWriter; +use notify::{RecommendedWatcher, RecursiveMode, Watcher as _}; +use rayon::ThreadPool; use region_processor::RegionProcessor; use tile_mipmapper::TileMipmapper; use tile_renderer::TileRenderer; +use tokio::runtime::Runtime; +use tracing::{info, warn}; use self::entity_collector::EntityCollector; @@ -44,9 +53,26 @@ pub struct Args { /// use one thread per logical CPU core. #[arg(short, long)] pub jobs: Option, + /// Number of parallel threads to use for initial processing + /// + /// Passing this option only makes sense with --watch. The first run after + /// starting MinedMap will use as many parallel jobs as configured using + /// --job-initial, while subsequent regenerations of tiles will use the + /// the number configured using --jobs. + /// + /// If not given, the value from the --jobs option is used. + #[arg(long)] + pub jobs_initial: Option, /// Enable verbose messages #[arg(short, long)] pub verbose: bool, + /// Watch for file changes and regenerate tiles automatically instead of + /// exiting after generation + #[arg(long)] + pub watch: bool, + /// Minimum delay between map generation cycles in watch mode + #[arg(long, value_parser = humantime::parse_duration, default_value = "30s")] + pub watch_delay: Duration, /// Format of generated map tiles #[arg(long, value_enum, default_value_t)] pub image_format: ImageFormat, @@ -74,14 +100,73 @@ pub struct Args { pub output_dir: PathBuf, } -/// Configures the Rayon thread pool for parallel processing -fn setup_threads(num_threads: usize) -> Result<()> { +/// Configures a Rayon thread pool for parallel processing +fn setup_threads(num_threads: usize) -> Result { rayon::ThreadPoolBuilder::new() .num_threads(num_threads) - .build_global() + .build() .context("Failed to configure thread pool") } +/// Runs all MinedMap generation steps, updating all tiles as needed +fn generate(config: &Config, rt: &Runtime) -> Result<()> { + let regions = RegionProcessor::new(config).run()?; + TileRenderer::new(config, rt, ®ions).run()?; + let tiles = TileMipmapper::new(config, ®ions).run()?; + EntityCollector::new(config, ®ions).run()?; + MetadataWriter::new(config, &tiles).run() +} + +/// Creates a file watcher for the +fn create_watcher(args: &Args) -> Result<(RecommendedWatcher, Receiver<()>)> { + let (tx, rx) = mpsc::sync_channel::<()>(1); + let mut watcher = notify::recommended_watcher(move |res| { + // Ignore errors - we already have a watch trigger queued if try_send() fails + let event: notify::Event = match res { + Ok(event) => event, + Err(err) => { + warn!("Watch error: {err}"); + return; + } + }; + let notify::EventKind::Modify(modify_kind) = event.kind else { + return; + }; + if !matches!( + modify_kind, + notify::event::ModifyKind::Data(_) + | notify::event::ModifyKind::Name(notify::event::RenameMode::To) + ) { + return; + } + if !event + .paths + .iter() + .any(|path| path.ends_with("level.dat") || path.extension() == Some("mcu".as_ref())) + { + return; + } + let _ = tx.try_send(()); + })?; + watcher.watch(&args.input_dir, RecursiveMode::Recursive)?; + Ok((watcher, rx)) +} + +/// Watches the data directory for changes, returning when a change has happened +fn wait_watcher(args: &Args, watch_channel: &Receiver<()>) -> Result<()> { + info!("Watching for changes..."); + let () = watch_channel + .recv() + .context("Failed to read watch event channel")?; + info!("Change detected."); + + thread::sleep(args.watch_delay); + + let _ = watch_channel.try_recv(); + + Ok(()) +} + /// MinedMap CLI main function pub fn cli() -> Result<()> { let args = Args::parse(); @@ -96,17 +181,26 @@ pub fn cli() -> Result<()> { .with_target(false) .init(); - setup_threads(config.num_threads)?; + let mut pool = setup_threads(config.num_threads_initial)?; let rt = tokio::runtime::Builder::new_current_thread() .build() .unwrap(); - let regions = RegionProcessor::new(&config).run()?; - TileRenderer::new(&config, &rt, ®ions).run()?; - let tiles = TileMipmapper::new(&config, ®ions).run()?; - EntityCollector::new(&config, ®ions).run()?; - MetadataWriter::new(&config, &tiles).run()?; + let watch = args.watch.then(|| create_watcher(&args)).transpose()?; - Ok(()) + pool.install(|| generate(&config, &rt))?; + + let Some((_watcher, watch_channel)) = watch else { + // watch mode disabled + return Ok(()); + }; + + if config.num_threads != config.num_threads_initial { + pool = setup_threads(config.num_threads)?; + } + pool.install(move || loop { + wait_watcher(&args, &watch_channel)?; + generate(&config, &rt)?; + }) } From d02ca9aea230b9ad387b21e7d911811ee67b6ab2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Feb 2025 17:28:47 +0100 Subject: [PATCH 09/55] ci: update OS --- .github/workflows/MinedMap.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index cf75b68..502e663 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -7,7 +7,7 @@ env: jobs: viewer: - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-latest' steps: - name: 'Checkout' @@ -101,7 +101,7 @@ jobs: - os: 'windows-2019' target: 'i686-pc-windows-msvc' ext: '.exe' - - os: 'ubuntu-20.04' + - os: 'ubuntu-22.04' target: 'x86_64-unknown-linux-gnu' steps: From cb0aa235db5055fda339d3a7f0d80a60b41d3599 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Feb 2025 17:18:14 +0100 Subject: [PATCH 10/55] docker: move viewer Dockerfile to viewer subdirectory --- .github/workflows/MinedMap.yml | 1 + viewer/.dockerignore | 1 + Dockerfile.viewer => viewer/Dockerfile | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 viewer/.dockerignore rename Dockerfile.viewer => viewer/Dockerfile (73%) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 502e663..198c472 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -25,6 +25,7 @@ jobs: pkgdir='build/pkg/MinedMap-${{ steps.tag.outputs.tag }}-viewer' mkdir -p "$pkgdir" cp -r viewer/* "$pkgdir"/ + rm "$pkgdir"/Dockerfile - name: 'Archive' uses: 'actions/upload-artifact@v4' diff --git a/viewer/.dockerignore b/viewer/.dockerignore new file mode 100644 index 0000000..3af0ccb --- /dev/null +++ b/viewer/.dockerignore @@ -0,0 +1 @@ +/data diff --git a/Dockerfile.viewer b/viewer/Dockerfile similarity index 73% rename from Dockerfile.viewer rename to viewer/Dockerfile index 82d50bb..794bcf5 100644 --- a/Dockerfile.viewer +++ b/viewer/Dockerfile @@ -1,3 +1,3 @@ FROM docker.io/library/nginx:alpine -COPY viewer /usr/share/nginx/html +COPY . /usr/share/nginx/html # datadir should be mounted to: /usr/share/nginx/html/data From 3b5ce8287368881728b6af2a81568fdd90189f64 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Feb 2025 16:49:42 +0100 Subject: [PATCH 11/55] docker: include Alpine base tools, tini Including tini fixes forwarding signals to MinedMap, allowing to interrupt it using Ctrl-C. The base tools may be used to add a wrapper script to configure MinedMap with environment variables. As the Alpine base is included now, we can switch from the rust:alpine image to alpine:latest, resulting in MinedMap to be linked dynamically. --- .dockerignore | 4 ++++ Dockerfile | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..cef6a14 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +* +!/Cargo.* +!/src +!/crates diff --git a/Dockerfile b/Dockerfile index fa3627c..04ce466 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,15 @@ -FROM docker.io/library/rust:alpine AS BUILDER +FROM docker.io/library/alpine:latest AS BUILDER WORKDIR /build -RUN apk update && apk add cmake build-base +RUN apk add --no-cache build-base cmake cargo -COPY src /build/src -COPY crates /build/crates -COPY Cargo.toml Cargo.lock /build +COPY . . RUN cargo build -r +RUN strip target/release/minedmap -FROM scratch AS RUNNER +FROM docker.io/library/alpine:latest -COPY --from=BUILDER /build/target/release/minedmap /minedmap -ENTRYPOINT [ "/minedmap" ] +RUN apk add --no-cache libgcc tini + +COPY --from=BUILDER /build/target/release/minedmap /bin/minedmap +ENTRYPOINT [ "/sbin/tini", "--", "/bin/minedmap" ] From 850b1a668b49341e75ae17c7389a5e634383cdeb Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 21 Feb 2025 19:06:05 +0100 Subject: [PATCH 12/55] docker: use lowercase stage name --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 04ce466..e052309 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/alpine:latest AS BUILDER +FROM docker.io/library/alpine:latest AS builder WORKDIR /build RUN apk add --no-cache build-base cmake cargo @@ -11,5 +11,5 @@ FROM docker.io/library/alpine:latest RUN apk add --no-cache libgcc tini -COPY --from=BUILDER /build/target/release/minedmap /bin/minedmap +COPY --from=builder /build/target/release/minedmap /bin/minedmap ENTRYPOINT [ "/sbin/tini", "--", "/bin/minedmap" ] From dba3dd551ecd504d81248db0855a510d479ab23d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 21 Feb 2025 10:51:05 +0100 Subject: [PATCH 13/55] ci: build Docker images, publish to GHCR --- .github/workflows/MinedMap.yml | 86 +++++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 198c472..2aef1ec 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -1,5 +1,14 @@ name: 'MinedMap' -on: ['push', 'pull_request', 'workflow_dispatch'] +on: + push: + branches: + - 'main' + tags: + - 'v*' + pull_request: + branches: + - 'main' + workflow_dispatch: {} env: RUSTFLAGS: -Dwarnings @@ -139,3 +148,78 @@ jobs: with: name: 'MinedMap-${{ steps.tag.outputs.tag }}-${{ matrix.target }}' path: 'target/pkg' + + build-container: + runs-on: ubuntu-latest + needs: + - test + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/neocturne/minedmap/minedmap + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=ref,event=branch,suffix=-{{sha}} + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/setup-buildx-action@v3 + + - name: Build + uses: docker/build-push-action@v6 + with: + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + viewer-container: + runs-on: ubuntu-latest + needs: + - test + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ghcr.io/neocturne/minedmap/viewer + tags: | + type=raw,value=latest,enable={{is_default_branch}} + type=ref,event=branch + type=ref,event=branch,suffix=-{{sha}} + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - uses: docker/setup-buildx-action@v3 + + - name: Build + uses: docker/build-push-action@v6 + with: + context: "{{defaultContext}}:viewer" + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} From 7bc15f97de13b08fc0372cddd281820bc0488b2b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 22 Feb 2025 03:13:43 +0100 Subject: [PATCH 14/55] docker: viewer: use nginx:alpine-slim as base --- viewer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viewer/Dockerfile b/viewer/Dockerfile index 794bcf5..524fd4c 100644 --- a/viewer/Dockerfile +++ b/viewer/Dockerfile @@ -1,3 +1,3 @@ -FROM docker.io/library/nginx:alpine +FROM docker.io/library/nginx:alpine-slim COPY . /usr/share/nginx/html # datadir should be mounted to: /usr/share/nginx/html/data From 282f62fc30352fa1ea801c2ae7652e538a922eb4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 22 Feb 2025 04:02:10 +0100 Subject: [PATCH 15/55] docker: run minedmap as unpriviledged user --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index e052309..bb0e0ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,12 @@ RUN strip target/release/minedmap FROM docker.io/library/alpine:latest +RUN addgroup -g 1000 -S minedmap \ + && adduser -S -D -H -u 1000 -h /output -s /sbin/nologin -G minedmap -g minedmap minedmap + RUN apk add --no-cache libgcc tini COPY --from=builder /build/target/release/minedmap /bin/minedmap ENTRYPOINT [ "/sbin/tini", "--", "/bin/minedmap" ] + +USER minedmap:minedmap From 8cb1eee60b82b0bfe00f3260ece281b269cd04fb Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 22 Feb 2025 11:06:46 +0100 Subject: [PATCH 16/55] docker, ci: fix --version output When building the docker image manually, MINEDMAP_VERSION needs to be set explicitly to get a proper version string. --- .github/workflows/MinedMap.yml | 12 ++++++++++++ Dockerfile | 2 ++ src/core/mod.rs | 18 ++++++++++++------ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 2aef1ec..24895c9 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -154,6 +154,16 @@ jobs: needs: - test steps: + - name: 'Checkout' + uses: 'actions/checkout@v4' + + - name: 'Get version' + id: 'tag' + run: | + set -o pipefail + git fetch --prune --unshallow --tags -f + echo "tag=$(git describe --abbrev=7 --match='v*' | sed 's/^v//')" >> $GITHUB_OUTPUT + - name: Docker meta id: meta uses: docker/metadata-action@v5 @@ -182,6 +192,8 @@ jobs: - name: Build uses: docker/build-push-action@v6 with: + build-args: | + MINEDMAP_VERSION=${{ steps.tag.outputs.tag }} push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index bb0e0ad..49965db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM docker.io/library/alpine:latest AS builder +ARG MINEDMAP_VERSION + WORKDIR /build RUN apk add --no-cache build-base cmake cargo diff --git a/src/core/mod.rs b/src/core/mod.rs index 202d017..a16f620 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -33,17 +33,23 @@ use tracing::{info, warn}; use self::entity_collector::EntityCollector; -/// MinedMap version number -const VERSION: &str = git_version!( - args = ["--abbrev=7", "--match=v*", "--dirty=-modified"], - cargo_prefix = "v", -); +/// Returns the MinedMap version number +fn version() -> &'static str { + option_env!("MINEDMAP_VERSION").unwrap_or( + git_version!( + args = ["--abbrev=7", "--match=v*", "--dirty=-modified"], + cargo_prefix = "v", + ) + .strip_prefix("v") + .unwrap(), + ) +} /// Command line arguments for minedmap CLI #[derive(Debug, Parser)] #[command( about, - version = VERSION.strip_prefix("v").unwrap(), + version = version(), max_term_width = 100, )] pub struct Args { From 90f2c5fdd05286037512380950a9fe076fe26600 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 22 Feb 2025 04:03:08 +0100 Subject: [PATCH 17/55] docker: add example docker-compose.yml --- docker-compose.yml | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5954ba7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,51 @@ +# This is an example docker-compose configuration providing a Minecraft server, +# map generator and webserver. Visit http://localhost:8080 to view the map. +# +# See https://docker-minecraft-server.readthedocs.io/ for more information on +# the itzg/minecraft-server image and its configuration. + +services: + mc: + image: docker.io/itzg/minecraft-server + environment: + EULA: 'true' + ports: + - '25565:25565' + volumes: + - data:/data + stdin_open: true + tty: true + restart: unless-stopped + + minedmap: + image: ghcr.io/neocturne/minedmap/minedmap + command: + - '--jobs-initial=2' + - '--image-format=webp' + - '--sign-filter=\[Map\]' + - '--sign-transform=s/\[Map\]//' + - '--watch' + - '/input/world' + - '/output' + volumes: + - data:/input + - output:/output + - processed:/output/processed + network_mode: 'none' + depends_on: + mc: + condition: service_healthy + restart: unless-stopped + + viewer: + image: ghcr.io/neocturne/minedmap/viewer + ports: + - '8080:80' + volumes: + - output:/usr/share/nginx/html/data + restart: unless-stopped + +volumes: + data: {} + processed: {} + output: {} From 24c266fc78db01115435c118c874d55a5a9f2d28 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 22 Feb 2025 11:27:40 +0100 Subject: [PATCH 18/55] docker: set ARG after apk add Allow reusing apk add layer when MINEDMAP_VERSION has changed. Signed-off-by: Matthias Schiffer --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 49965db..389fb08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM docker.io/library/alpine:latest AS builder -ARG MINEDMAP_VERSION - WORKDIR /build RUN apk add --no-cache build-base cmake cargo +ARG MINEDMAP_VERSION + COPY . . RUN cargo build -r RUN strip target/release/minedmap From 5ee8e493d4b85afa8f8090716bf04207e8425f3b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 25 Feb 2025 18:23:54 +0100 Subject: [PATCH 19/55] docker-compose.yml: mount volumes read-only where appropriate --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5954ba7..c725ae2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,7 +28,7 @@ services: - '/input/world' - '/output' volumes: - - data:/input + - data:/input:ro - output:/output - processed:/output/processed network_mode: 'none' @@ -42,7 +42,7 @@ services: ports: - '8080:80' volumes: - - output:/usr/share/nginx/html/data + - output:/usr/share/nginx/html/data:ro restart: unless-stopped volumes: From 40bc6cd2a9aaa5137561604c025edb5677d81b14 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 28 Feb 2025 11:54:20 +0100 Subject: [PATCH 20/55] Update dependencies --- Cargo.lock | 80 +++++++++++++++++++------------------- crates/resource/Cargo.toml | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 039e940..c8cbbe6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" [[package]] name = "autocfg" @@ -150,9 +150,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cc" -version = "1.2.13" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "jobserver", "libc", @@ -173,9 +173,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.29" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acebd8ad879283633b343856142139f2da2317c96b05b4dd6181c61e2480184" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", "clap_derive", @@ -183,9 +183,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.29" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ba32cbda51c7e1dfd49acc1457ba1a7dec5b64fe360e828acb13ca8dc9c2f9" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstream", "anstyle", @@ -263,9 +263,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "either" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" [[package]] name = "enum-map" @@ -310,9 +310,9 @@ dependencies = [ [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -359,9 +359,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" dependencies = [ "crc32fast", "libz-ng-sys", @@ -448,9 +448,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.29.2" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc46dd3ec48fdd8e693a98d2b8bafae273a2d54c1de02a2a7e3d57d501f39677" +checksum = "17fcdf9683c406c2fc4d124afd29c0d595e22210d633cbdb8695ba9935ab1dc6" [[package]] name = "hashbrown" @@ -593,9 +593,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "libredox" @@ -636,9 +636,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "lru" @@ -728,9 +728,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", "simd-adler32", @@ -989,9 +989,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "82b568323e98e49e2a0899dcee453dd679fae22d69adf9b11dd508d1549b7e2f" dependencies = [ "bitflags 2.8.0", ] @@ -1073,9 +1073,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] @@ -1091,9 +1091,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", @@ -1102,9 +1102,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.138" +version = "1.0.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949" +checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" dependencies = [ "itoa", "memchr", @@ -1150,9 +1150,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "strsim" @@ -1281,9 +1281,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" +checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" [[package]] name = "utf8parse" @@ -1428,27 +1428,27 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "zstd" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf2b778a664581e31e389454a7072dab1647606d44f7feea22cd5abb9c9f3f9" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" dependencies = [ "zstd-safe", ] [[package]] name = "zstd-safe" -version = "7.2.1" +version = "7.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a3ab4db68cea366acc5c897c7b4d4d1b8994a9cd6e6f841f8964566a419059" +checksum = "f3051792fbdc2e1e143244dc28c60f73d8470e93f3f9cbd0ead44da5ed802722" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.13+zstd.1.5.6" +version = "2.0.14+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" +checksum = "8fb060d4926e4ac3a3ad15d864e99ceb5f343c6b34f5bd6d81ae6ed417311be5" dependencies = [ "cc", "pkg-config", diff --git a/crates/resource/Cargo.toml b/crates/resource/Cargo.toml index 4e0d512..07b6d1f 100644 --- a/crates/resource/Cargo.toml +++ b/crates/resource/Cargo.toml @@ -9,5 +9,5 @@ repository.workspace = true [dependencies] enumflags2 = { version = "0.7.7", features = ["serde"] } -glam = "0.29.2" +glam = "0.30.0" serde = { version = "1.0.183", features = ["derive"] } From f8c8ca78bad8e0c66b1429666442c958be1a33bf Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 28 Feb 2025 12:12:58 +0100 Subject: [PATCH 21/55] Switch from zlib-ng to zlib-rs zlib-rs provides the same performance as zlib-ng with minedmap, while reducing the amount of C code and avoiding the external build dependency on CMake. --- CHANGELOG.md | 4 ++++ Cargo.lock | 27 ++++++++++++--------------- Cargo.toml | 4 ++-- Dockerfile | 2 +- README.md | 5 ----- crates/nbt/Cargo.toml | 6 ++---- 6 files changed, 21 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8fd052..1b84b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,10 @@ - Unknown biome types (from not yet supported or modded versions of Minecraft) will now use plains biome colors as a fallback instead of resulting in water, grass and foliage blocks to be rendered as transparent pixels +- Switched from zlib-ng to zlib-rs + + This should have no noticable effect on the usage of MinedMap, but avoids + an external build dependency on CMake. ## [2.4.0] - 2025-01-11 diff --git a/Cargo.lock b/Cargo.lock index c8cbbe6..7bd83ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -212,15 +212,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" -[[package]] -name = "cmake" -version = "0.1.54" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" -dependencies = [ - "cc", -] - [[package]] name = "colorchoice" version = "1.0.3" @@ -364,7 +355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" dependencies = [ "crc32fast", - "libz-ng-sys", + "libz-rs-sys", "miniz_oxide", ] @@ -609,13 +600,12 @@ dependencies = [ ] [[package]] -name = "libz-ng-sys" -version = "1.1.21" +name = "libz-rs-sys" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cee1488e961a80d172564fd6fcda11d8a4ac6672c06fe008e9213fa60520c2b" +checksum = "902bc563b5d65ad9bba616b490842ef0651066a1a1dc3ce1087113ffcb873c8d" dependencies = [ - "cmake", - "libc", + "zlib-rs", ] [[package]] @@ -664,6 +654,7 @@ dependencies = [ "clap", "enum-map", "fastnbt", + "flate2", "futures-util", "git-version", "humantime", @@ -1426,6 +1417,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "zlib-rs" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b20717f0917c908dc63de2e44e97f1e6b126ca58d0e391cee86d504eb8fbd05" + [[package]] name = "zstd" version = "0.13.3" diff --git a/Cargo.toml b/Cargo.toml index d213a56..812ad33 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,7 @@ bincode = "1.3.3" clap = { version = "4.1.4", features = ["derive", "wrap_help"] } enum-map = "2.7.3" fastnbt = "2.3.2" +flate2 = { version = "1.1.0", features = ["zlib-rs"] } futures-util = "0.3.28" git-version = "0.3.5" humantime = "2.1.0" @@ -67,7 +68,6 @@ tracing-subscriber = "0.3.17" zstd = "0.13.0" [features] -default = ["jemalloc-auto", "zlib-ng"] +default = ["jemalloc-auto"] jemalloc-auto = ["dep:minedmap-default-alloc"] jemalloc = ["jemalloc-auto", "minedmap-default-alloc/jemalloc"] -zlib-ng = ["minedmap-nbt/zlib-ng"] diff --git a/Dockerfile b/Dockerfile index 389fb08..818971d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM docker.io/library/alpine:latest AS builder WORKDIR /build -RUN apk add --no-cache build-base cmake cargo +RUN apk add --no-cache build-base cargo ARG MINEDMAP_VERSION diff --git a/README.md b/README.md index 7d60f78..952163f 100644 --- a/README.md +++ b/README.md @@ -117,11 +117,6 @@ or newer). The following command can be used to build the current development ve cargo install --git 'https://github.com/neocturne/MinedMap.git' ``` -In addition, CMake is needed to build the zlib-ng library. If you do not have -CMake installed, you can disable the zlib-ng feature by passing `--no-default-features` -to cargo. A pure-Rust zlib implementation will be used, which is more portable, -but slower than zlib-ng. - If you are looking for the older C++ implementation of the MinedMap tile renderer, see the [v1.19.1](https://github.com/neocturne/MinedMap/tree/v1.19.1) tag. diff --git a/crates/nbt/Cargo.toml b/crates/nbt/Cargo.toml index 9f815da..01bbd78 100644 --- a/crates/nbt/Cargo.toml +++ b/crates/nbt/Cargo.toml @@ -11,12 +11,10 @@ repository.workspace = true anyhow = "1.0.75" bytemuck = "1.13.1" fastnbt = "2.4.4" -flate2 = "1.0.27" +flate2 = "1.1.0" minedmap-types = { version = "0.1.4", path = "../types" } serde = "1.0.183" -[features] -zlib-ng = ["flate2/zlib-ng"] - [dev-dependencies] clap = { version = "4.3.23", features = ["derive"] } +flate2 = { version = "1.1.0", features = ["zlib-rs"] } From 7686996fd3b538d3b5409fcb3c251b178ed693df Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 28 Feb 2025 16:16:29 +0100 Subject: [PATCH 22/55] resource: make seagrass opaque See changelog for rationale. --- CHANGELOG.md | 7 +++++++ crates/resource/src/block_types.rs | 4 ++-- resource/blocks.json | 2 +- src/core/common.rs | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b84b15..14b7e35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,13 @@ This should have no noticable effect on the usage of MinedMap, but avoids an external build dependency on CMake. +- Small (1-block) seagrass is now visible on the map + + 1-block seagrass in 1-block deep water would previously result in the ground + to be shown instead of water, as MinedMap currently doesn't handle the + "waterlogged" block status. As 1-block seagrass is relatively big compared to + other "small" plants, just considering it opaque seems like a good enough + solution that avoids having to implement advanced block status flags. ## [2.4.0] - 2025-01-11 diff --git a/crates/resource/src/block_types.rs b/crates/resource/src/block_types.rs index 53abd54..da556b8 100644 --- a/crates/resource/src/block_types.rs +++ b/crates/resource/src/block_types.rs @@ -8692,8 +8692,8 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ "seagrass", ConstBlockType { block_color: BlockColor { - flags: make_bitflags!(BlockFlag::{}), - color: Color([0, 0, 0]), + flags: make_bitflags!(BlockFlag::{Opaque}), + color: Color([50, 126, 8]), }, sign_material: None, }, diff --git a/resource/blocks.json b/resource/blocks.json index a88aa34..a409abb 100644 --- a/resource/blocks.json +++ b/resource/blocks.json @@ -1781,7 +1781,7 @@ "sculk_vein": {}, "sea_lantern": {}, "sea_pickle": {}, - "seagrass": null, + "seagrass": {}, "short_grass": null, "shroomlight": {}, "shulker_box": {}, diff --git a/src/core/common.rs b/src/core/common.rs index a81dbf2..8230a79 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -25,7 +25,7 @@ use crate::{ /// /// Increase when the generation of processed regions from region data changes /// (usually because of updated resource data) -pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(4); +pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(5); /// MinedMap map tile data version number /// @@ -37,7 +37,7 @@ pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// /// Increase when the generation of lightmap tiles from region data changes /// (usually because of updated resource data) -pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(3); +pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(4); /// MinedMap mipmap data version number /// From fbdd5ed457f2e5ca12bc7a7d6f6992f47494e062 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 21:11:59 +0100 Subject: [PATCH 23/55] Dockerfile: switch back to docker.io/library/rust:alpine image bincode 2 required Rust 1.85, so our options are to switch to Alpine edge or to use the rust image. While using the rust image results in a statically linked binary, this does not actually increase the size of the image, as we were already using jemalloc, so almost nothing of libc is actually used. --- Dockerfile | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 818971d..0f0eecd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ -FROM docker.io/library/alpine:latest AS builder +FROM docker.io/library/rust:alpine AS builder WORKDIR /build -RUN apk add --no-cache build-base cargo +RUN apk add --no-cache build-base tini-static ARG MINEDMAP_VERSION @@ -9,14 +9,9 @@ COPY . . RUN cargo build -r RUN strip target/release/minedmap -FROM docker.io/library/alpine:latest +FROM scratch -RUN addgroup -g 1000 -S minedmap \ - && adduser -S -D -H -u 1000 -h /output -s /sbin/nologin -G minedmap -g minedmap minedmap +COPY --from=builder /sbin/tini-static /build/target/release/minedmap /bin/ +ENTRYPOINT [ "/bin/tini-static", "--", "/bin/minedmap" ] -RUN apk add --no-cache libgcc tini - -COPY --from=builder /build/target/release/minedmap /bin/minedmap -ENTRYPOINT [ "/sbin/tini", "--", "/bin/minedmap" ] - -USER minedmap:minedmap +USER 1000:1000 From deb232ddf356efd80a4658b0b0f8c329e420b244 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 20:34:16 +0100 Subject: [PATCH 24/55] Update dependencies --- Cargo.lock | 118 ++++++++++++++++++++++++++--------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7bd83ee..0142276 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -84,9 +84,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.96" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "autocfg" @@ -126,15 +126,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] name = "byteorder" @@ -173,9 +173,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.31" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" +checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" dependencies = [ "clap_builder", "clap_derive", @@ -183,9 +183,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.31" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" +checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" dependencies = [ "anstream", "anstyle", @@ -196,9 +196,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.28" +version = "4.5.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" dependencies = [ "heck", "proc-macro2", @@ -254,9 +254,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" [[package]] name = "either" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "enum-map" @@ -468,9 +468,9 @@ checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "humantime" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" +checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" [[package]] name = "image" @@ -497,9 +497,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.1" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" +checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown", @@ -512,7 +512,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "inotify-sys", "libc", ] @@ -543,9 +543,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" @@ -584,9 +584,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libredox" @@ -594,7 +594,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "libc", "redox_syscall", ] @@ -610,9 +610,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.15" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" [[package]] name = "lock_api" @@ -745,7 +745,7 @@ version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "filetime", "fsevent-sys", "inotify", @@ -813,9 +813,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.3" +version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" [[package]] name = "overload" @@ -902,9 +902,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "png" @@ -921,9 +921,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -936,9 +936,9 @@ checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" [[package]] name = "quote" -version = "1.0.38" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -980,11 +980,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.9" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b568323e98e49e2a0899dcee453dd679fae22d69adf9b11dd508d1549b7e2f" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -1030,11 +1030,11 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "0.38.44" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "errno", "libc", "linux-raw-sys", @@ -1043,9 +1043,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -1064,27 +1064,27 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" -version = "0.11.15" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "387cc504cb06bb40a96c8e04e951fe01854cf6bc921053c954e4a606d9675c6a" +checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" dependencies = [ "serde", ] [[package]] name = "serde_derive" -version = "1.0.218" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -1093,9 +1093,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", "memchr", @@ -1153,9 +1153,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.98" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -1164,9 +1164,9 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" +checksum = "45c6481c4829e4cc63825e62c49186a34538b7b2750b73b266581ffb612fb5ed" dependencies = [ "rustix", "windows-sys 0.59.0", @@ -1204,9 +1204,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.43.0" +version = "1.44.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" +checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" dependencies = [ "backtrace", "parking_lot", @@ -1272,9 +1272,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e2473a93778eb0bad35909dff6a10d28e63f792f16ed15e404fca9d5eeedbe" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "utf8parse" From 404ad74235cc69935204ea50497a80f9acce6aad Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 12 Mar 2025 20:54:04 +0100 Subject: [PATCH 25/55] core: deserialize biome list into Vec Only use IndexSet for deduplication while processing the biome; when deserializing, no deduplication is required, so using a Vec is faster (besides IndexSet missing non-serde support for bincode 2). --- src/core/common.rs | 3 +-- src/core/region_processor.rs | 12 ++++++++++-- src/core/tile_renderer.rs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/core/common.rs b/src/core/common.rs index 8230a79..b25d7b8 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -8,7 +8,6 @@ use std::{ use anyhow::{Context, Result}; use clap::ValueEnum; -use indexmap::IndexSet; use regex::{Regex, RegexSet}; use serde::{Deserialize, Serialize}; @@ -102,7 +101,7 @@ pub struct ProcessedRegion { /// List of biomes used in the region /// /// Indexed by [ProcessedChunk] biome data - pub biome_list: IndexSet, + pub biome_list: Vec, /// Processed chunk data pub chunks: ChunkArray>>, } diff --git a/src/core/region_processor.rs b/src/core/region_processor.rs index e448f5e..1dc50fb 100644 --- a/src/core/region_processor.rs +++ b/src/core/region_processor.rs @@ -1,9 +1,11 @@ //! The [RegionProcessor] and related functions -use std::{ffi::OsStr, path::PathBuf, sync::mpsc, time::SystemTime}; +use std::{ffi::OsStr, mem, path::PathBuf, sync::mpsc, time::SystemTime}; use anyhow::{Context, Result}; use enum_map::{Enum, EnumMap}; +use indexmap::IndexSet; +use minedmap_resource::Biome; use rayon::prelude::*; use tracing::{debug, info, warn}; @@ -73,6 +75,8 @@ struct SingleRegionProcessor<'a> { lightmap_needed: bool, /// True if entity output file needs to be updated entities_needed: bool, + /// [IndexSet] of biomes used by the processed region + biome_list: IndexSet, /// Processed region intermediate data processed_region: ProcessedRegion, /// Lightmap intermediate data @@ -108,6 +112,7 @@ impl<'a> SingleRegionProcessor<'a> { let entities_needed = Some(input_timestamp) > entities_timestamp; let processed_region = ProcessedRegion::default(); + let biome_list = IndexSet::default(); let lightmap = image::GrayAlphaImage::new(N, N); let entities = ProcessedEntities::default(); @@ -127,6 +132,7 @@ impl<'a> SingleRegionProcessor<'a> { lightmap_needed, entities_needed, processed_region, + biome_list, lightmap, entities, image_format: processor.config.tile_image_format(), @@ -220,7 +226,7 @@ impl<'a> SingleRegionProcessor<'a> { biomes, block_light, depths, - }) = world::layer::top_layer(&mut self.processed_region.biome_list, &chunk) + }) = world::layer::top_layer(&mut self.biome_list, &chunk) .with_context(|| format!("Failed to process chunk {:?}", chunk_coords))? { if self.output_needed { @@ -291,6 +297,8 @@ impl<'a> SingleRegionProcessor<'a> { } } + self.processed_region.biome_list = mem::take(&mut self.biome_list).into_iter().collect(); + self.save_region()?; self.save_lightmap()?; self.save_entities()?; diff --git a/src/core/tile_renderer.rs b/src/core/tile_renderer.rs index 24af234..e47e20e 100644 --- a/src/core/tile_renderer.rs +++ b/src/core/tile_renderer.rs @@ -187,7 +187,7 @@ impl<'a> TileRenderer<'a> { for ((region_x, region_z, index), w) in weights.into_values() { let region = region_group.get(region_x, region_z)?; - let biome = region.biome_list.get_index(index.into())?; + let biome = region.biome_list.get(usize::from(index))?; total += w; color += w * block_color(block, Some(biome), depth.0 as f32); From 53a0f2460006b89413feb80858a03673f2746b68 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 12 Mar 2025 20:34:26 +0100 Subject: [PATCH 26/55] treewide: update to bincode 2 Consistently use bincode's Encode/Decode to avoid issues with incompatible serde features. Support for storing some temporary files as JSON is removed. The size of the "processed" directory is reduced by ~8% with the new default encoding of bincode 2. Performance is more or less unaffected. --- Cargo.lock | 31 ++++++++++++++++++++--- Cargo.toml | 2 +- crates/resource/Cargo.toml | 2 +- crates/resource/src/lib.rs | 49 +++++++++++++++++++++++++++++++----- crates/types/Cargo.toml | 2 +- crates/types/src/lib.rs | 6 ++--- src/core/common.rs | 14 ++++++----- src/core/entity_collector.rs | 25 +++++++++--------- src/core/metadata_writer.rs | 5 ++-- src/core/region_processor.rs | 2 -- src/core/tile_renderer.rs | 3 +-- src/io/storage.rs | 46 +++++++++++++-------------------- src/world/block_entity.rs | 11 ++++---- src/world/json_text.rs | 7 ++++-- src/world/layer.rs | 4 +-- src/world/sign.rs | 5 ++-- 16 files changed, 133 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0142276..5c5d477 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -111,11 +111,22 @@ dependencies = [ [[package]] name = "bincode" -version = "1.3.3" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" dependencies = [ + "bincode_derive", "serde", + "unty", +] + +[[package]] +name = "bincode_derive" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" +dependencies = [ + "virtue", ] [[package]] @@ -704,17 +715,17 @@ dependencies = [ name = "minedmap-resource" version = "0.6.0" dependencies = [ + "bincode", "enumflags2", "glam", - "serde", ] [[package]] name = "minedmap-types" version = "0.1.4" dependencies = [ + "bincode", "itertools", - "serde", ] [[package]] @@ -1276,6 +1287,12 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +[[package]] +name = "unty" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" + [[package]] name = "utf8parse" version = "0.2.2" @@ -1288,6 +1305,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "virtue" +version = "0.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" + [[package]] name = "walkdir" version = "2.5.0" diff --git a/Cargo.toml b/Cargo.toml index 812ad33..4109bfd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ pre-release-replacements = [ [dependencies] anyhow = "1.0.68" -bincode = "1.3.3" +bincode = "2.0.1" clap = { version = "4.1.4", features = ["derive", "wrap_help"] } enum-map = "2.7.3" fastnbt = "2.3.2" diff --git a/crates/resource/Cargo.toml b/crates/resource/Cargo.toml index 07b6d1f..c654f40 100644 --- a/crates/resource/Cargo.toml +++ b/crates/resource/Cargo.toml @@ -8,6 +8,6 @@ readme.workspace = true repository.workspace = true [dependencies] +bincode = "2.0.1" enumflags2 = { version = "0.7.7", features = ["serde"] } glam = "0.30.0" -serde = { version = "1.0.183", features = ["derive"] } diff --git a/crates/resource/src/lib.rs b/crates/resource/src/lib.rs index a633d06..01b460b 100644 --- a/crates/resource/src/lib.rs +++ b/crates/resource/src/lib.rs @@ -10,13 +10,13 @@ mod legacy_block_types; use std::collections::HashMap; +use bincode::{BorrowDecode, Decode, Encode}; use enumflags2::{bitflags, BitFlags}; -use serde::{Deserialize, Serialize}; /// Flags describing special properties of [BlockType]s #[bitflags] #[repr(u8)] -#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq)] pub enum BlockFlag { /// The block type is opaque Opaque, @@ -38,14 +38,14 @@ pub enum BlockFlag { } /// An RGB color with u8 components -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode)] pub struct Color(pub [u8; 3]); /// An RGB color with f32 components pub type Colorf = glam::Vec3; /// A block type specification -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy)] pub struct BlockColor { /// Bit set of [BlockFlag]s describing special properties of the block type pub flags: BitFlags, @@ -61,6 +61,43 @@ impl BlockColor { } } +impl Encode for BlockColor { + fn encode( + &self, + encoder: &mut E, + ) -> Result<(), bincode::error::EncodeError> { + bincode::Encode::encode(&self.flags.bits(), encoder)?; + bincode::Encode::encode(&self.color, encoder)?; + Ok(()) + } +} + +impl Decode for BlockColor { + fn decode>( + decoder: &mut D, + ) -> Result { + Ok(BlockColor { + flags: BitFlags::from_bits(bincode::Decode::decode(decoder)?).or(Err( + bincode::error::DecodeError::Other("invalid block flags"), + ))?, + color: bincode::Decode::decode(decoder)?, + }) + } +} + +impl<'de, Context> BorrowDecode<'de, Context> for BlockColor { + fn borrow_decode>( + decoder: &mut D, + ) -> Result { + Ok(BlockColor { + flags: BitFlags::from_bits(bincode::BorrowDecode::borrow_decode(decoder)?).or(Err( + bincode::error::DecodeError::Other("invalid block flags"), + ))?, + color: bincode::BorrowDecode::borrow_decode(decoder)?, + }) + } +} + /// A block type specification (for use in constants) #[derive(Debug, Clone)] struct ConstBlockType { @@ -137,7 +174,7 @@ impl BlockTypes { pub use block_color::{block_color, needs_biome}; /// Grass color modifier used by a biome -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)] pub enum BiomeGrassColorModifier { /// Grass color modifier used by the dark forest biome DarkForest, @@ -149,7 +186,7 @@ pub enum BiomeGrassColorModifier { /// /// A Biome contains all information about a biome necessary to compute a block /// color given a block type and depth -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Encode, Decode)] pub struct Biome { /// Temperature value /// diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index c5bd47e..2b83c39 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -8,5 +8,5 @@ readme.workspace = true repository.workspace = true [dependencies] +bincode = "2.0.1" itertools = "0.14.0" -serde = { version = "1.0.183", features = ["derive"] } diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index b4f12c2..e770f6a 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -8,8 +8,8 @@ use std::{ ops::{Index, IndexMut}, }; +use bincode::{Decode, Encode}; use itertools::iproduct; -use serde::{Deserialize, Serialize}; /// Const generic AXIS arguments for coordinate types pub mod axis { @@ -110,7 +110,7 @@ impl LayerBlockCoords { /// Generic array for data stored per block of a chunk layer /// /// Includes various convenient iteration functions. -#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Default, Encode, Decode)] pub struct LayerBlockArray(pub [[T; BLOCKS_PER_CHUNK]; BLOCKS_PER_CHUNK]); impl Index for LayerBlockArray { @@ -196,7 +196,7 @@ impl Debug for ChunkCoords { /// Generic array for data stored per chunk of a region /// /// Includes various convenient iteration functions. -#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Default, Encode, Decode)] pub struct ChunkArray(pub [[T; CHUNKS_PER_REGION]; CHUNKS_PER_REGION]); impl ChunkArray { diff --git a/src/core/common.rs b/src/core/common.rs index b25d7b8..06a3277 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -3,13 +3,15 @@ use std::{ collections::{BTreeMap, BTreeSet}, fmt::Debug, + hash::Hash, path::{Path, PathBuf}, }; use anyhow::{Context, Result}; +use bincode::{Decode, Encode}; use clap::ValueEnum; use regex::{Regex, RegexSet}; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use crate::{ io::fs::FileMetaVersion, @@ -24,7 +26,7 @@ use crate::{ /// /// Increase when the generation of processed regions from region data changes /// (usually because of updated resource data) -pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(5); +pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(6); /// MinedMap map tile data version number /// @@ -46,7 +48,7 @@ pub const MIPMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// MinedMap processed entity data version number /// /// Increase when entity collection changes bacause of code changes. -pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(1); +pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(2); /// Coordinate pair of a generated tile /// @@ -85,7 +87,7 @@ impl TileCoordMap { } /// Data structure for storing chunk data between processing and rendering steps -#[derive(Debug, Serialize, Deserialize)] +#[derive(Debug, Encode, Decode)] pub struct ProcessedChunk { /// Block type data pub blocks: Box, @@ -96,7 +98,7 @@ pub struct ProcessedChunk { } /// Data structure for storing region data between processing and rendering steps -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Encode, Decode)] pub struct ProcessedRegion { /// List of biomes used in the region /// @@ -107,7 +109,7 @@ pub struct ProcessedRegion { } /// Data structure for storing entity data between processing and collection steps -#[derive(Debug, Default, Serialize, Deserialize)] +#[derive(Debug, Default, Encode, Decode)] pub struct ProcessedEntities { /// List of block entities pub block_entities: Vec, diff --git a/src/core/entity_collector.rs b/src/core/entity_collector.rs index 30b3a86..0d18090 100644 --- a/src/core/entity_collector.rs +++ b/src/core/entity_collector.rs @@ -78,23 +78,22 @@ impl<'a> EntityCollector<'a> { let mut output = ProcessedEntities::default(); for source_path in sources { - let mut source: ProcessedEntities = - match storage::read_file(source_path.as_ref(), storage::Format::Json) { - Ok(source) => source, - Err(err) => { - warn!( - "Failed to read entity data file {}: {:?}", - source_path.as_ref().display(), - err, - ); - continue; - } - }; + let mut source: ProcessedEntities = match storage::read_file(source_path.as_ref()) { + Ok(source) => source, + Err(err) => { + warn!( + "Failed to read entity data file {}: {:?}", + source_path.as_ref().display(), + err, + ); + continue; + } + }; output.block_entities.append(&mut source.block_entities); } - storage::write(file, &output, storage::Format::Json).context("Failed to write entity data") + storage::write(file, &output).context("Failed to write entity data") } /// Runs the mipmap generation diff --git a/src/core/metadata_writer.rs b/src/core/metadata_writer.rs index eb5f59f..40c5796 100644 --- a/src/core/metadata_writer.rs +++ b/src/core/metadata_writer.rs @@ -179,9 +179,8 @@ impl<'a> MetadataWriter<'a> { /// Generates [Entities] data from collected entity lists fn entities(&self) -> Result { - let data: ProcessedEntities = - storage::read_file(&self.config.entities_path_final, storage::Format::Json) - .context("Failed to read entity data file")?; + let data: ProcessedEntities = storage::read_file(&self.config.entities_path_final) + .context("Failed to read entity data file")?; let ret = Entities { signs: data diff --git a/src/core/region_processor.rs b/src/core/region_processor.rs index 1dc50fb..56f54ed 100644 --- a/src/core/region_processor.rs +++ b/src/core/region_processor.rs @@ -168,7 +168,6 @@ impl<'a> SingleRegionProcessor<'a> { storage::write_file( &self.output_path, &self.processed_region, - storage::Format::Bincode, REGION_FILE_META_VERSION, self.input_timestamp, ) @@ -207,7 +206,6 @@ impl<'a> SingleRegionProcessor<'a> { storage::write_file( &self.entities_path, &self.entities, - storage::Format::Json, ENTITIES_FILE_META_VERSION, self.input_timestamp, ) diff --git a/src/core/tile_renderer.rs b/src/core/tile_renderer.rs index e47e20e..e990a63 100644 --- a/src/core/tile_renderer.rs +++ b/src/core/tile_renderer.rs @@ -105,8 +105,7 @@ impl<'a> TileRenderer<'a> { region_loader .get_or_try_init(|| async { - storage::read_file(&processed_path, storage::Format::Bincode) - .context("Failed to load processed region data") + storage::read_file(&processed_path).context("Failed to load processed region data") }) .await .cloned() diff --git a/src/io/storage.rs b/src/io/storage.rs index 9296166..ae311de 100644 --- a/src/io/storage.rs +++ b/src/io/storage.rs @@ -10,28 +10,16 @@ use std::{ }; use anyhow::{Context, Result}; -use serde::{de::DeserializeOwned, Serialize}; +use bincode::{Decode, Encode}; use super::fs; -/// Storage format -#[derive(Debug, Copy, Clone, PartialEq, Eq)] -pub enum Format { - /// Encode as Bincode - /// - /// Bincode is more efficient than JSON, but cannot handle many of - /// serde's features like flatten, conditional skipping, ... - Bincode, - /// Encode as JSON - Json, -} +/// Bincode configuration +const BINCODE_CONFIG: bincode::config::Configuration = bincode::config::standard(); /// Serializes data and writes it to a writer -pub fn write(writer: &mut W, value: &T, format: Format) -> Result<()> { - let data = match format { - Format::Bincode => bincode::serialize(value)?, - Format::Json => serde_json::to_vec(value)?, - }; +pub fn write(writer: &mut W, value: &T) -> Result<()> { + let data = bincode::encode_to_vec(value, BINCODE_CONFIG)?; let len = u32::try_from(data.len())?; let compressed = zstd::bulk::compress(&data, 1)?; drop(data); @@ -45,18 +33,21 @@ pub fn write(writer: &mut W, value: &T, format: Format) /// Serializes data and stores it in a file /// /// A timestamp is stored in an assiciated metadata file. -pub fn write_file( +pub fn write_file( path: &Path, value: &T, - format: Format, version: fs::FileMetaVersion, timestamp: SystemTime, ) -> Result<()> { - fs::create_with_timestamp(path, version, timestamp, |file| write(file, value, format)) + fs::create_with_timestamp(path, version, timestamp, |file| write(file, value)) } /// Reads data from a reader and deserializes it -pub fn read(reader: &mut R, format: Format) -> Result { +pub fn read(reader: &mut R) -> Result +where + R: Read, + T: Decode<()>, +{ let mut len_buf = [0u8; 4]; reader.read_exact(&mut len_buf)?; let len = usize::try_from(u32::from_be_bytes(len_buf))?; @@ -66,18 +57,17 @@ pub fn read(reader: &mut R, format: Format) -> Res let data = zstd::bulk::decompress(&compressed, len)?; drop(compressed); - let value = match format { - Format::Bincode => bincode::deserialize(&data)?, - Format::Json => serde_json::from_slice(&data)?, - }; - Ok(value) + Ok(bincode::decode_from_slice(&data, BINCODE_CONFIG)?.0) } /// Reads data from a file and deserializes it -pub fn read_file(path: &Path, format: Format) -> Result { +pub fn read_file(path: &Path) -> Result +where + T: Decode<()>, +{ (|| -> Result { let mut file = File::open(path)?; - read(&mut file, format) + read(&mut file) })() .with_context(|| format!("Failed to read file {}", path.display())) } diff --git a/src/world/block_entity.rs b/src/world/block_entity.rs index 182ad50..6ad58a1 100644 --- a/src/world/block_entity.rs +++ b/src/world/block_entity.rs @@ -1,7 +1,8 @@ //! Processing of block entity data +use bincode::{Decode, Encode}; use minedmap_resource::{BlockFlag, BlockType}; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use super::{ de, @@ -9,7 +10,7 @@ use super::{ }; /// Kind of sign block -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] #[serde(rename_all = "snake_case")] pub enum SignKind { /// Standing sign @@ -23,7 +24,7 @@ pub enum SignKind { } /// Processed sign data -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] pub struct Sign { /// The kind of the sign pub kind: SignKind, @@ -54,7 +55,7 @@ impl Sign { } /// Data for different kinds of [BlockEntity] -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] #[serde(tag = "type", rename_all = "snake_case")] pub enum BlockEntityData { /// A sign block @@ -62,7 +63,7 @@ pub enum BlockEntityData { } /// A processed block entity -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode, Serialize)] pub struct BlockEntity { /// Global X coordinate pub x: i32, diff --git a/src/world/json_text.rs b/src/world/json_text.rs index fa18527..6a2d8ba 100644 --- a/src/world/json_text.rs +++ b/src/world/json_text.rs @@ -2,6 +2,7 @@ use std::{collections::VecDeque, fmt::Display}; +use bincode::{Decode, Encode}; use minedmap_resource::Color; use serde::{Deserialize, Serialize}; @@ -12,7 +13,9 @@ use serde::{Deserialize, Serialize}; /// is handled by [DeserializedText]. /// /// Formatting that is not set in a node is inherited from the parent. -#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Eq, PartialOrd, Ord)] +#[derive( + Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Encode, Decode, +)] pub struct FormattedText { #[serde(default)] /// Text content @@ -84,7 +87,7 @@ impl From for FormattedTextTree { } /// List of [FormattedText] -#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Encode, Decode)] pub struct FormattedTextList(pub Vec); impl FormattedTextList { diff --git a/src/world/layer.rs b/src/world/layer.rs index e59593c..deb4b48 100644 --- a/src/world/layer.rs +++ b/src/world/layer.rs @@ -3,8 +3,8 @@ use std::num::NonZeroU16; use anyhow::{Context, Result}; +use bincode::{Decode, Encode}; use indexmap::IndexSet; -use serde::{Deserialize, Serialize}; use super::chunk::{Chunk, SectionIterItem}; use crate::{ @@ -13,7 +13,7 @@ use crate::{ }; /// Height (Y coordinate) of a block -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Encode, Decode)] pub struct BlockHeight(pub i32); impl BlockHeight { diff --git a/src/world/sign.rs b/src/world/sign.rs index eff319f..579f5b3 100644 --- a/src/world/sign.rs +++ b/src/world/sign.rs @@ -2,8 +2,9 @@ use std::fmt::Display; +use bincode::{Decode, Encode}; use minedmap_resource::Color; -use serde::{Deserialize, Serialize}; +use serde::Serialize; use super::{ de, @@ -104,7 +105,7 @@ impl BlockEntitySignExt for de::BlockEntitySign { } } -#[derive(Debug, Default, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Debug, Default, Serialize, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)] /// Deserialized and linearized sign text pub struct SignText(pub Vec); From 708fb9645dc89f6e454f3564b81f8e9a265457d7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 20:27:51 +0100 Subject: [PATCH 27/55] core/region_processor: refactor Separate configuration and mutable state, also allowing to avoid a few mem::take(). --- src/core/region_processor.rs | 115 ++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/src/core/region_processor.rs b/src/core/region_processor.rs index 56f54ed..e638342 100644 --- a/src/core/region_processor.rs +++ b/src/core/region_processor.rs @@ -1,6 +1,6 @@ //! The [RegionProcessor] and related functions -use std::{ffi::OsStr, mem, path::PathBuf, sync::mpsc, time::SystemTime}; +use std::{ffi::OsStr, path::PathBuf, sync::mpsc, time::SystemTime}; use anyhow::{Context, Result}; use enum_map::{Enum, EnumMap}; @@ -45,6 +45,37 @@ enum RegionProcessorStatus { ErrorMissing, } +/// Data of a region being processed by a [SingleRegionProcessor] +#[derive(Debug)] +struct SingleRegionData { + /// [IndexSet] of biomes used by the processed region + biome_list: IndexSet, + /// Processed region chunk intermediate data + chunks: ChunkArray>>, + /// Lightmap intermediate data + lightmap: image::GrayAlphaImage, + /// Processed entity intermediate data + entities: ProcessedEntities, + /// True if any unknown block or biome types were encountered during processing + has_unknown: bool, +} + +impl Default for SingleRegionData { + fn default() -> Self { + /// Width/height of the region data + const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; + + let lightmap = image::GrayAlphaImage::new(N, N); + Self { + biome_list: Default::default(), + chunks: Default::default(), + lightmap, + entities: Default::default(), + has_unknown: false, + } + } +} + /// Handles processing for a single region struct SingleRegionProcessor<'a> { /// Registry of known block types @@ -75,26 +106,13 @@ struct SingleRegionProcessor<'a> { lightmap_needed: bool, /// True if entity output file needs to be updated entities_needed: bool, - /// [IndexSet] of biomes used by the processed region - biome_list: IndexSet, - /// Processed region intermediate data - processed_region: ProcessedRegion, - /// Lightmap intermediate data - lightmap: image::GrayAlphaImage, - /// Processed entity intermediate data - entities: ProcessedEntities, /// Format of generated map tiles image_format: image::ImageFormat, - /// True if any unknown block or biome types were encountered during processing - has_unknown: bool, } impl<'a> SingleRegionProcessor<'a> { /// Initializes a [SingleRegionProcessor] fn new(processor: &'a RegionProcessor<'a>, coords: TileCoords) -> Result { - /// Width/height of the region data - const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; - let input_path = processor.config.region_path(coords); let input_timestamp = fs::modified_timestamp(&input_path)?; @@ -111,11 +129,6 @@ impl<'a> SingleRegionProcessor<'a> { let lightmap_needed = Some(input_timestamp) > lightmap_timestamp; let entities_needed = Some(input_timestamp) > entities_timestamp; - let processed_region = ProcessedRegion::default(); - let biome_list = IndexSet::default(); - let lightmap = image::GrayAlphaImage::new(N, N); - let entities = ProcessedEntities::default(); - Ok(SingleRegionProcessor { block_types: &processor.block_types, biome_types: &processor.biome_types, @@ -131,12 +144,7 @@ impl<'a> SingleRegionProcessor<'a> { output_needed, lightmap_needed, entities_needed, - processed_region, - biome_list, - lightmap, - entities, image_format: processor.config.tile_image_format(), - has_unknown: false, }) } @@ -160,14 +168,14 @@ impl<'a> SingleRegionProcessor<'a> { /// Saves processed region data /// /// The timestamp is the time of the last modification of the input region data. - fn save_region(&self) -> Result<()> { + fn save_region(&self, processed_region: &ProcessedRegion) -> Result<()> { if !self.output_needed { return Ok(()); } storage::write_file( &self.output_path, - &self.processed_region, + processed_region, REGION_FILE_META_VERSION, self.input_timestamp, ) @@ -176,7 +184,7 @@ impl<'a> SingleRegionProcessor<'a> { /// Saves a lightmap tile /// /// The timestamp is the time of the last modification of the input region data. - fn save_lightmap(&self) -> Result<()> { + fn save_lightmap(&self, lightmap: &image::GrayAlphaImage) -> Result<()> { if !self.lightmap_needed { return Ok(()); } @@ -186,7 +194,7 @@ impl<'a> SingleRegionProcessor<'a> { LIGHTMAP_FILE_META_VERSION, self.input_timestamp, |file| { - self.lightmap + lightmap .write_to(file, self.image_format) .context("Failed to save image") }, @@ -196,27 +204,32 @@ impl<'a> SingleRegionProcessor<'a> { /// Saves processed entity data /// /// The timestamp is the time of the last modification of the input region data. - fn save_entities(&mut self) -> Result<()> { + fn save_entities(&self, entities: &mut ProcessedEntities) -> Result<()> { if !self.entities_needed { return Ok(()); } - self.entities.block_entities.sort_unstable(); + entities.block_entities.sort_unstable(); storage::write_file( &self.entities_path, - &self.entities, + entities, ENTITIES_FILE_META_VERSION, self.input_timestamp, ) } /// Processes a single chunk - fn process_chunk(&mut self, chunk_coords: ChunkCoords, data: world::de::Chunk) -> Result<()> { + fn process_chunk( + &self, + data: &mut SingleRegionData, + chunk_coords: ChunkCoords, + chunk_data: world::de::Chunk, + ) -> Result<()> { let (chunk, has_unknown) = - world::chunk::Chunk::new(&data, self.block_types, self.biome_types) + world::chunk::Chunk::new(&chunk_data, self.block_types, self.biome_types) .with_context(|| format!("Failed to decode chunk {:?}", chunk_coords))?; - self.has_unknown |= has_unknown; + data.has_unknown |= has_unknown; if self.output_needed || self.lightmap_needed { if let Some(layer::LayerData { @@ -224,11 +237,11 @@ impl<'a> SingleRegionProcessor<'a> { biomes, block_light, depths, - }) = world::layer::top_layer(&mut self.biome_list, &chunk) + }) = world::layer::top_layer(&mut data.biome_list, &chunk) .with_context(|| format!("Failed to process chunk {:?}", chunk_coords))? { if self.output_needed { - self.processed_region.chunks[chunk_coords] = Some(Box::new(ProcessedChunk { + data.chunks[chunk_coords] = Some(Box::new(ProcessedChunk { blocks, biomes, depths, @@ -237,7 +250,7 @@ impl<'a> SingleRegionProcessor<'a> { if self.lightmap_needed { let chunk_lightmap = Self::render_chunk_lightmap(block_light); - overlay_chunk(&mut self.lightmap, &chunk_lightmap, chunk_coords); + overlay_chunk(&mut data.lightmap, &chunk_lightmap, chunk_coords); } } } @@ -249,20 +262,21 @@ impl<'a> SingleRegionProcessor<'a> { chunk_coords, ) })?; - self.entities.block_entities.append(&mut block_entities); + data.entities.block_entities.append(&mut block_entities); } Ok(()) } /// Processes the chunks of the region - fn process_chunks(&mut self) -> Result<()> { - crate::nbt::region::from_file(&self.input_path)? - .foreach_chunk(|chunk_coords, data| self.process_chunk(chunk_coords, data)) + fn process_chunks(&self, data: &mut SingleRegionData) -> Result<()> { + crate::nbt::region::from_file(&self.input_path)?.foreach_chunk( + |chunk_coords, chunk_data| self.process_chunk(data, chunk_coords, chunk_data), + ) } /// Processes the region - fn run(mut self) -> Result { + fn run(&self) -> Result { if !self.output_needed && !self.lightmap_needed && !self.entities_needed { debug!( "Skipping unchanged region r.{}.{}.mca", @@ -276,7 +290,9 @@ impl<'a> SingleRegionProcessor<'a> { self.coords.x, self.coords.z ); - if let Err(err) = self.process_chunks() { + let mut data = SingleRegionData::default(); + + if let Err(err) = self.process_chunks(&mut data) { if self.output_timestamp.is_some() && self.lightmap_timestamp.is_some() && self.entities_timestamp.is_some() @@ -295,13 +311,16 @@ impl<'a> SingleRegionProcessor<'a> { } } - self.processed_region.biome_list = mem::take(&mut self.biome_list).into_iter().collect(); + let processed_region = ProcessedRegion { + biome_list: data.biome_list.into_iter().collect(), + chunks: data.chunks, + }; - self.save_region()?; - self.save_lightmap()?; - self.save_entities()?; + self.save_region(&processed_region)?; + self.save_lightmap(&data.lightmap)?; + self.save_entities(&mut data.entities)?; - Ok(if self.has_unknown { + Ok(if data.has_unknown { RegionProcessorStatus::OkWithUnknown } else { RegionProcessorStatus::Ok From 5c8568755441c8e91fc8bf2ea598a021a0bd5477 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 20:40:23 +0100 Subject: [PATCH 28/55] Clean up dependency features --- Cargo.lock | 2 -- Cargo.toml | 4 ++-- crates/resource/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5c5d477..4f5bfa2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -296,7 +296,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" dependencies = [ "enumflags2_derive", - "serde", ] [[package]] @@ -514,7 +513,6 @@ checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" dependencies = [ "equivalent", "hashbrown", - "serde", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 4109bfd..da9f2ca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,7 +47,7 @@ futures-util = "0.3.28" git-version = "0.3.5" humantime = "2.1.0" image = { version = "0.25.1", default-features = false, features = ["png", "webp"] } -indexmap = { version = "2.0.0", features = ["serde"] } +indexmap = "2.0.0" lru = "0.13.0" minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } @@ -60,7 +60,7 @@ phf = { version = "0.11.2", features = ["macros"] } rayon = "1.7.0" regex = "1.10.2" rustc-hash = "2.0.0" -serde = { version = "1.0.152", features = ["rc", "derive"] } +serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0.99" tokio = { version = "1.31.0", features = ["rt", "parking_lot", "sync"] } tracing = "0.1.37" diff --git a/crates/resource/Cargo.toml b/crates/resource/Cargo.toml index c654f40..9fc157c 100644 --- a/crates/resource/Cargo.toml +++ b/crates/resource/Cargo.toml @@ -9,5 +9,5 @@ repository.workspace = true [dependencies] bincode = "2.0.1" -enumflags2 = { version = "0.7.7", features = ["serde"] } +enumflags2 = "0.7.7" glam = "0.30.0" From 7bba5bae558780a30e0c3218fc41ff770230b4cc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 21:24:44 +0100 Subject: [PATCH 29/55] Update to Rust 2024 With bincode 2, we require rust 1.85 anyways, so we might as well upgrade, too. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index da9f2ca..0051203 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ members = ["crates/*"] [workspace.package] -edition = "2021" +edition = "2024" license = "MIT" readme = "README.md" repository = "https://github.com/neocturne/MinedMap" From 775fcb2d1b6adcd8aca3196ebdd1b2b0f16818cb Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 21:44:10 +0100 Subject: [PATCH 30/55] treewide: cargo fmt with 1.85 --- crates/nbt/src/region.rs | 4 ++-- crates/resource/src/lib.rs | 2 +- crates/types/src/lib.rs | 8 ++++---- src/core/mod.rs | 8 +++++--- src/core/tile_renderer.rs | 2 +- src/world/chunk.rs | 4 ++-- src/world/json_text.rs | 2 +- src/world/section.rs | 8 ++------ 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/crates/nbt/src/region.rs b/crates/nbt/src/region.rs index 8a52b9d..1325919 100644 --- a/crates/nbt/src/region.rs +++ b/crates/nbt/src/region.rs @@ -2,11 +2,11 @@ use std::{ fs::File, - io::{prelude::*, SeekFrom}, + io::{SeekFrom, prelude::*}, path::Path, }; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use flate2::read::ZlibDecoder; use serde::de::DeserializeOwned; diff --git a/crates/resource/src/lib.rs b/crates/resource/src/lib.rs index 01b460b..86cfb0f 100644 --- a/crates/resource/src/lib.rs +++ b/crates/resource/src/lib.rs @@ -11,7 +11,7 @@ mod legacy_block_types; use std::collections::HashMap; use bincode::{BorrowDecode, Decode, Encode}; -use enumflags2::{bitflags, BitFlags}; +use enumflags2::{BitFlags, bitflags}; /// Flags describing special properties of [BlockType]s #[bitflags] diff --git a/crates/types/src/lib.rs b/crates/types/src/lib.rs index e770f6a..f2dc0e1 100644 --- a/crates/types/src/lib.rs +++ b/crates/types/src/lib.rs @@ -48,10 +48,10 @@ macro_rules! coord_type { /// Returns an iterator over all possible values of the type #[inline] pub fn iter() -> impl DoubleEndedIterator> - + ExactSizeIterator - + FusedIterator - + Clone - + Debug { + + ExactSizeIterator + + FusedIterator + + Clone + + Debug { (0..Self::MAX as u8).map($t) } } diff --git a/src/core/mod.rs b/src/core/mod.rs index a16f620..fce2cb5 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -205,8 +205,10 @@ pub fn cli() -> Result<()> { if config.num_threads != config.num_threads_initial { pool = setup_threads(config.num_threads)?; } - pool.install(move || loop { - wait_watcher(&args, &watch_channel)?; - generate(&config, &rt)?; + pool.install(move || { + loop { + wait_watcher(&args, &watch_channel)?; + generate(&config, &rt)?; + } }) } diff --git a/src/core/tile_renderer.rs b/src/core/tile_renderer.rs index e990a63..9d7e188 100644 --- a/src/core/tile_renderer.rs +++ b/src/core/tile_renderer.rs @@ -16,7 +16,7 @@ use tracing::{debug, info}; use super::{common::*, region_group::RegionGroup}; use crate::{ io::{fs, storage}, - resource::{block_color, needs_biome, Colorf}, + resource::{Colorf, block_color, needs_biome}, types::*, util::coord_offset, }; diff --git a/src/world/chunk.rs b/src/world/chunk.rs index daee023..c4744d0 100644 --- a/src/world/chunk.rs +++ b/src/world/chunk.rs @@ -4,11 +4,11 @@ //! over different data versions as much as possible. use std::{ - collections::{btree_map, BTreeMap}, + collections::{BTreeMap, btree_map}, iter::{self, FusedIterator}, }; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use super::{block_entity::BlockEntity, de, section::*}; use crate::{ diff --git a/src/world/json_text.rs b/src/world/json_text.rs index 6a2d8ba..7d3ff3a 100644 --- a/src/world/json_text.rs +++ b/src/world/json_text.rs @@ -185,9 +185,9 @@ mod json_color { use minedmap_resource::Color; use serde::{ + Deserializer, Serializer, de::{self, Visitor}, ser::Error as _, - Deserializer, Serializer, }; /// Named JSON text colors diff --git a/src/world/section.rs b/src/world/section.rs index 845ddae..dc5c9a6 100644 --- a/src/world/section.rs +++ b/src/world/section.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; -use anyhow::{bail, Context, Result}; +use anyhow::{Context, Result, bail}; use num_integer::div_rem; use tracing::debug; @@ -400,10 +400,6 @@ impl<'a> BlockLight<'a> { let (offset, nibble) = div_rem(coords.offset(), 2); let byte = block_light[offset] as u8; - if nibble == 1 { - byte >> 4 - } else { - byte & 0xf - } + if nibble == 1 { byte >> 4 } else { byte & 0xf } } } From 5ee826a11b78905eeefdacfc78fced7592ec8962 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 13 Mar 2025 21:52:35 +0100 Subject: [PATCH 31/55] ci: set fixed Rust version 1.85 Avoid CI failure due to new warnings or fmt changes in new Rust version. --- .github/workflows/MinedMap.yml | 11 +++++------ Dockerfile | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 24895c9..16a3047 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: stable + toolchain: '1.85' components: rustfmt - run: cargo fmt --all -- --check @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: stable + toolchain: '1.85' components: clippy - uses: swatinem/rust-cache@v2 - uses: actions-rs/clippy-check@v1 @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: stable + toolchain: '1.85' components: rust-docs - uses: swatinem/rust-cache@v2 - run: cargo doc --workspace --no-deps --document-private-items @@ -83,12 +83,11 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macOS-latest] - rust: [stable] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: ${{ matrix.rust }} + toolchain: '1.85' - uses: swatinem/rust-cache@v2 - run: cargo test --workspace - run: cargo test --workspace --no-default-features @@ -128,7 +127,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: stable + toolchain: '1.85' targets: '${{ matrix.target }}' - uses: swatinem/rust-cache@v2 diff --git a/Dockerfile b/Dockerfile index 0f0eecd..41d4c6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/rust:alpine AS builder +FROM docker.io/library/rust:1.85-alpine AS builder WORKDIR /build RUN apk add --no-cache build-base tini-static From d6cd0fc53bd42209b204311eee0e334e80aaf970 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Mar 2025 12:19:39 +0100 Subject: [PATCH 32/55] ci: include target in cache key Avoid cache keys colliding between build jobs running on the same OS. --- .github/workflows/MinedMap.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 16a3047..40ea96a 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -131,6 +131,8 @@ jobs: targets: '${{ matrix.target }}' - uses: swatinem/rust-cache@v2 + with: + key: '${{ matrix.target }}' - name: 'Build' shell: 'bash' From e600a9dabb27857f729f97e89e7866b084fef72a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Mar 2025 16:24:22 +0100 Subject: [PATCH 33/55] CHANGELOG.md: mention Bincode update While the update is an internal change, it does affect the MSRV, so it should be mentioned in the changelog. --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b7e35..089e28a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,11 @@ "waterlogged" block status. As 1-block seagrass is relatively big compared to other "small" plants, just considering it opaque seems like a good enough solution that avoids having to implement advanced block status flags. +- Use Bincode 2 for storage of intermediate data + + The update from Bincode 1 to 2 slightly reduces the size of the `processed` + directory used for intermediate data. At least Rust 1.85 is now required to + build MinedMap. ## [2.4.0] - 2025-01-11 From dca365f4e23f7427571bfe943437a65cd48fc864 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Mar 2025 16:29:23 +0100 Subject: [PATCH 34/55] CHANGELOG.md: mention new Docker images and docker-compose example --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 089e28a..4f5c5bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,11 @@ Note that some platforms like `msvc` are unsupported by jemalloc, and trying to enable the `jemalloc` feature on these platforms may break the MinedMap build or cause issues at runtime. +- Docker images can be downloaded from the GitHub Container registry + + Two images are provided, one for the tile renderer and one with the viewer + and a web server. A `docker-compose.yml` example can be found in the + repository as a starting point. ### Changed From 6a54f57c509c6455371b0594b32a353920270fa2 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Mar 2025 20:02:13 +0100 Subject: [PATCH 35/55] minedmap-types 0.2.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/nbt/Cargo.toml | 2 +- crates/types/Cargo.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4f5bfa2..80766f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -720,7 +720,7 @@ dependencies = [ [[package]] name = "minedmap-types" -version = "0.1.4" +version = "0.2.0" dependencies = [ "bincode", "itertools", diff --git a/Cargo.toml b/Cargo.toml index 0051203..854a955 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,7 @@ lru = "0.13.0" minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } minedmap-resource = { version = "0.6.0", path = "crates/resource" } -minedmap-types = { version = "0.1.4", path = "crates/types" } +minedmap-types = { version = "0.2.0", path = "crates/types" } notify = "8.0.0" num-integer = "0.1.45" num_cpus = "1.16.0" diff --git a/crates/nbt/Cargo.toml b/crates/nbt/Cargo.toml index 01bbd78..6a4938e 100644 --- a/crates/nbt/Cargo.toml +++ b/crates/nbt/Cargo.toml @@ -12,7 +12,7 @@ anyhow = "1.0.75" bytemuck = "1.13.1" fastnbt = "2.4.4" flate2 = "1.1.0" -minedmap-types = { version = "0.1.4", path = "../types" } +minedmap-types = { version = "0.2.0", path = "../types" } serde = "1.0.183" [dev-dependencies] diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index 2b83c39..34caa1c 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minedmap-types" -version = "0.1.4" +version = "0.2.0" description = "Common types used by several MinedMap crates" edition.workspace = true license.workspace = true From 54ea2b2f2898a272be3ea4841d68081f9d1ff53d Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Mar 2025 20:02:36 +0100 Subject: [PATCH 36/55] minedmap-resource 0.7.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/resource/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80766f4..d5159bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -711,7 +711,7 @@ dependencies = [ [[package]] name = "minedmap-resource" -version = "0.6.0" +version = "0.7.0" dependencies = [ "bincode", "enumflags2", diff --git a/Cargo.toml b/Cargo.toml index 854a955..33256e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ indexmap = "2.0.0" lru = "0.13.0" minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } -minedmap-resource = { version = "0.6.0", path = "crates/resource" } +minedmap-resource = { version = "0.7.0", path = "crates/resource" } minedmap-types = { version = "0.2.0", path = "crates/types" } notify = "8.0.0" num-integer = "0.1.45" diff --git a/crates/resource/Cargo.toml b/crates/resource/Cargo.toml index 9fc157c..1257a90 100644 --- a/crates/resource/Cargo.toml +++ b/crates/resource/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minedmap-resource" -version = "0.6.0" +version = "0.7.0" description = "Data describing Minecraft biomes and block types" edition.workspace = true license.workspace = true From 974a0f37df6dab8d0ca529a78bb6615e57ed05db Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 14 Mar 2025 20:02:49 +0100 Subject: [PATCH 37/55] minedmap-nbt 0.2.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/nbt/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5159bf..726fd48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -698,7 +698,7 @@ dependencies = [ [[package]] name = "minedmap-nbt" -version = "0.1.1" +version = "0.2.0" dependencies = [ "anyhow", "bytemuck", diff --git a/Cargo.toml b/Cargo.toml index 33256e6..9b87ed1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ image = { version = "0.25.1", default-features = false, features = ["png", "webp indexmap = "2.0.0" lru = "0.13.0" minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } -minedmap-nbt = { version = "0.1.1", path = "crates/nbt", default-features = false } +minedmap-nbt = { version = "0.2.0", path = "crates/nbt", default-features = false } minedmap-resource = { version = "0.7.0", path = "crates/resource" } minedmap-types = { version = "0.2.0", path = "crates/types" } notify = "8.0.0" diff --git a/crates/nbt/Cargo.toml b/crates/nbt/Cargo.toml index 6a4938e..07a5fd7 100644 --- a/crates/nbt/Cargo.toml +++ b/crates/nbt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minedmap-nbt" -version = "0.1.1" +version = "0.2.0" description = "MinedMap's handling of Minecraft NBT data and region files" edition.workspace = true license.workspace = true From 6e5b958912be6e8c3e64d94c8b30d565847ced7f Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 16 Mar 2025 12:17:07 +0100 Subject: [PATCH 38/55] default-alloc: fix wildcard dependency --- crates/default-alloc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/default-alloc/Cargo.toml b/crates/default-alloc/Cargo.toml index 40f9e7e..b03a871 100644 --- a/crates/default-alloc/Cargo.toml +++ b/crates/default-alloc/Cargo.toml @@ -11,7 +11,7 @@ repository.workspace = true tikv-jemallocator = { version = "0.6.0", optional = true } [target.'cfg(target_env = "musl")'.dependencies] -tikv-jemallocator = "*" +tikv-jemallocator = "0.6.0" [features] jemalloc = ["dep:tikv-jemallocator"] From 3008203080e2ae44f2eea35121d8ae790f219dc0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 16 Mar 2025 12:24:29 +0100 Subject: [PATCH 39/55] minedmap 2.5.0 --- CHANGELOG.md | 5 ++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f5c5bd..482d462 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] - ReleaseDate +## [2.5.0] - 2025-03-16 + ### Added - Added experimental watch mode @@ -186,7 +188,8 @@ intermediate data. Full support for custom biomes datapacks might be added in a future release. -[Unreleased]: https://github.com/neocturne/MinedMap/compare/v2.4.0...HEAD +[Unreleased]: https://github.com/neocturne/MinedMap/compare/v2.5.0...HEAD +[2.5.0]: https://github.com/neocturne/MinedMap/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/neocturne/MinedMap/compare/v2.3.1...v2.4.0 [2.3.1]: https://github.com/neocturne/MinedMap/compare/v2.3.0...v2.3.1 [2.3.0]: https://github.com/neocturne/MinedMap/compare/v2.2.0...v2.3.0 diff --git a/Cargo.lock b/Cargo.lock index 726fd48..6b6d6ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -656,7 +656,7 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "minedmap" -version = "2.4.0" +version = "2.5.0" dependencies = [ "anyhow", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 9b87ed1..34e5619 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ pre-release-commit-message = "{{crate_name}} {{version}}" [package] name = "minedmap" -version = "2.4.0" +version = "2.5.0" description = "Generate browsable maps from Minecraft save data" edition.workspace = true license.workspace = true From 23b2f274be781fe20b24d778adb36595923be725 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 2 Apr 2025 19:04:15 +0200 Subject: [PATCH 40/55] ci, docker: update to Rust 1.85.1 --- .github/workflows/MinedMap.yml | 10 +++++----- Dockerfile | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 40ea96a..ece4e50 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85' + toolchain: '1.85.1' components: rustfmt - run: cargo fmt --all -- --check @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85' + toolchain: '1.85.1' components: clippy - uses: swatinem/rust-cache@v2 - uses: actions-rs/clippy-check@v1 @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85' + toolchain: '1.85.1' components: rust-docs - uses: swatinem/rust-cache@v2 - run: cargo doc --workspace --no-deps --document-private-items @@ -87,7 +87,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85' + toolchain: '1.85.1' - uses: swatinem/rust-cache@v2 - run: cargo test --workspace - run: cargo test --workspace --no-default-features @@ -127,7 +127,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85' + toolchain: '1.85.1' targets: '${{ matrix.target }}' - uses: swatinem/rust-cache@v2 diff --git a/Dockerfile b/Dockerfile index 41d4c6c..ad36c79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/rust:1.85-alpine AS builder +FROM docker.io/library/rust:1.85.1-alpine AS builder WORKDIR /build RUN apk add --no-cache build-base tini-static From 442009eb0804891fdca520edbbbb61dabb12ef2e Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 2 Apr 2025 19:05:52 +0200 Subject: [PATCH 41/55] Update dependencies --- Cargo.lock | 105 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 71 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b6d6ff..d9f14f8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,9 +161,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cc" -version = "1.2.16" +version = "1.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" dependencies = [ "jobserver", "libc", @@ -184,9 +184,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.32" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83" +checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" dependencies = [ "clap_builder", "clap_derive", @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.32" +version = "4.5.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8" +checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" dependencies = [ "anstream", "anstyle", @@ -360,9 +360,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" dependencies = [ "crc32fast", "libz-rs-sys", @@ -371,9 +371,9 @@ dependencies = [ [[package]] name = "foldhash" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] name = "fsevent-sys" @@ -421,6 +421,18 @@ dependencies = [ "slab", ] +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + [[package]] name = "gimli" version = "0.31.1" @@ -449,9 +461,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.30.0" +version = "0.30.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fcdf9683c406c2fc4d124afd29c0d595e22210d633cbdb8695ba9935ab1dc6" +checksum = "bf3aa70d918d2b234126ff4f850f628f172542bf0603ded26b8ee36e5e22d5f9" [[package]] name = "hashbrown" @@ -484,9 +496,9 @@ checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f" [[package]] name = "image" -version = "0.25.5" +version = "0.25.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" +checksum = "db35664ce6b9810857a38a906215e75a9c879f0696556a39f59c62829710251a" dependencies = [ "bytemuck", "byteorder-lite", @@ -558,10 +570,11 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jobserver" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" dependencies = [ + "getrandom", "libc", ] @@ -610,18 +623,18 @@ dependencies = [ [[package]] name = "libz-rs-sys" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "902bc563b5d65ad9bba616b490842ef0651066a1a1dc3ce1087113ffcb873c8d" +checksum = "6489ca9bd760fe9642d7644e827b0c9add07df89857b0416ee15c1cc1a3b8c5a" dependencies = [ "zlib-rs", ] [[package]] name = "linux-raw-sys" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9c683daf087dc577b7506e9695b3d556a9f3849903fa28186283afd6809e9" +checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" [[package]] name = "lock_api" @@ -635,9 +648,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.26" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" @@ -744,7 +757,7 @@ checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" dependencies = [ "libc", "log", - "wasi", + "wasi 0.11.0+wasi-snapshot-preview1", "windows-sys 0.52.0", ] @@ -822,9 +835,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.21.1" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "overload" @@ -952,6 +965,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + [[package]] name = "rand" version = "0.8.5" @@ -1039,9 +1058,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "1.0.2" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7178faa4b75a30e269c71e61c353ce2748cf3d76f0c44c393f4e60abf49b825" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ "bitflags 2.9.0", "errno", @@ -1325,6 +1344,15 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1439,10 +1467,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "zlib-rs" -version = "0.4.2" +name = "wit-bindgen-rt" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b20717f0917c908dc63de2e44e97f1e6b126ca58d0e391cee86d504eb8fbd05" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.0", +] + +[[package]] +name = "zlib-rs" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "868b928d7949e09af2f6086dfc1e01936064cc7a819253bce650d4e2a2d63ba8" [[package]] name = "zstd" @@ -1455,18 +1492,18 @@ dependencies = [ [[package]] name = "zstd-safe" -version = "7.2.3" +version = "7.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3051792fbdc2e1e143244dc28c60f73d8470e93f3f9cbd0ead44da5ed802722" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" dependencies = [ "zstd-sys", ] [[package]] name = "zstd-sys" -version = "2.0.14+zstd.1.5.7" +version = "2.0.15+zstd.1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb060d4926e4ac3a3ad15d864e99ceb5f343c6b34f5bd6d81ae6ed417311be5" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" dependencies = [ "cc", "pkg-config", From ba6e4bae7f072c697e1d204955f72ed2a6bbb148 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 2 Apr 2025 22:39:26 +0200 Subject: [PATCH 42/55] world: rename JSONText to TextValue New Minecraft version do not store text as JSON anymore. --- src/world/de.rs | 12 ++++++------ src/world/mod.rs | 2 +- src/world/sign.rs | 4 ++-- src/world/{json_text.rs => text_value.rs} | 22 +++++++++++----------- 4 files changed, 20 insertions(+), 20 deletions(-) rename src/world/{json_text.rs => text_value.rs} (93%) diff --git a/src/world/de.rs b/src/world/de.rs index 7ab8ba7..0a4b4b6 100644 --- a/src/world/de.rs +++ b/src/world/de.rs @@ -2,7 +2,7 @@ use serde::Deserialize; -use super::json_text::JSONText; +use super::text_value::TextValue; /// Element of the `palette` list of 1.18+ [block states](BlockStatesV1_18) #[derive(Debug, Deserialize)] @@ -110,7 +110,7 @@ pub enum BiomesV0 { #[derive(Debug, Deserialize)] pub struct BlockEntitySignV1_20Text { /// Lines of sign text - pub messages: Vec, + pub messages: Vec, /// Default text color pub color: Option, } @@ -125,13 +125,13 @@ pub enum BlockEntitySign { #[serde(rename_all = "PascalCase")] V0 { /// Line 1 of the sign text - text1: JSONText, + text1: TextValue, /// Line 2 of the sign text - text2: JSONText, + text2: TextValue, /// Line 3 of the sign text - text3: JSONText, + text3: TextValue, /// Line 4 of the sign text - text4: JSONText, + text4: TextValue, /// Default text color color: Option, }, diff --git a/src/world/mod.rs b/src/world/mod.rs index 6426c92..8a2e9be 100644 --- a/src/world/mod.rs +++ b/src/world/mod.rs @@ -3,7 +3,7 @@ pub mod block_entity; pub mod chunk; pub mod de; -pub mod json_text; pub mod layer; pub mod section; pub mod sign; +pub mod text_value; diff --git a/src/world/sign.rs b/src/world/sign.rs index 579f5b3..c913b6f 100644 --- a/src/world/sign.rs +++ b/src/world/sign.rs @@ -8,7 +8,7 @@ use serde::Serialize; use super::{ de, - json_text::{FormattedText, FormattedTextList, JSONText}, + text_value::{FormattedText, FormattedTextList, TextValue}, }; /// Version-independent reference to (front or back) sign text @@ -18,7 +18,7 @@ pub struct RawSignText<'a> { /// /// A regular sign always has 4 lines of text. The back of pre-1.20 /// signs is represented as a [SignText] without any `messages`. - pub messages: Vec<&'a JSONText>, + pub messages: Vec<&'a TextValue>, /// Sign color /// /// Defaults to "black". diff --git a/src/world/json_text.rs b/src/world/text_value.rs similarity index 93% rename from src/world/json_text.rs rename to src/world/text_value.rs index 7d3ff3a..336b1b1 100644 --- a/src/world/json_text.rs +++ b/src/world/text_value.rs @@ -1,4 +1,4 @@ -//! Newtype and helper methods for handling Minecraft Raw JSON Text +//! Newtype and helper methods for handling Minecraft text values use std::{collections::VecDeque, fmt::Display}; @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; /// A span of formatted text /// -/// A [JSONText] consists of a tree of [FormattedText] nodes (canonically +/// A [TextValue] consists of a tree of [FormattedText] nodes (canonically /// represented as a [FormattedTextTree], but other kinds are possible with /// is handled by [DeserializedText]. /// @@ -21,7 +21,7 @@ pub struct FormattedText { /// Text content pub text: String, /// Text color - #[serde(skip_serializing_if = "Option::is_none", with = "json_color")] + #[serde(skip_serializing_if = "Option::is_none", with = "text_color")] pub color: Option, /// Bold formatting #[serde(skip_serializing_if = "Option::is_none")] @@ -107,9 +107,9 @@ impl Display for FormattedTextList { } } -/// Raw deserialized [JSONText] +/// Raw deserialized [TextValue] /// -/// A [JSONText] can contain various different JSON types. +/// A [TextValue] can contain various different types serialized as JSON or NBT. #[derive(Debug, Deserialize)] #[serde(untagged)] pub enum DeserializedText { @@ -169,18 +169,18 @@ impl Default for DeserializedText { } } -/// Minecraft Raw JSON Text +/// Minecraft raw text value #[derive(Debug, Deserialize)] -pub struct JSONText(pub String); +pub struct TextValue(pub String); -impl JSONText { - /// Deserializes a [JSONText] into a [DeserializedText] +impl TextValue { + /// Deserializes a [TextValue] into a [DeserializedText] pub fn deserialize(&self) -> DeserializedText { serde_json::from_str(&self.0).unwrap_or_default() } } -mod json_color { +mod text_color { //! Helpers for serializing and deserializing [FormattedText](super::FormattedText) colors use minedmap_resource::Color; @@ -190,7 +190,7 @@ mod json_color { ser::Error as _, }; - /// Named JSON text colors + /// Named text colors static COLORS: phf::Map<&'static str, Color> = phf::phf_map! { "black" => Color([0x00, 0x00, 0x00]), "dark_blue" => Color([0x00, 0x00, 0xAA]), From 5f84ec8ed2c4701c24032bac0ee45175f2904ddc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 2 Apr 2025 22:43:02 +0200 Subject: [PATCH 43/55] world/text_value: add support for new NBT text serialization Starting with DataVersion 4290, text is stored as NBT instead of JSON. The structure remains the same. --- src/world/block_entity.rs | 19 ++++++++++++++----- src/world/chunk.rs | 9 ++++++++- src/world/sign.rs | 4 ++-- src/world/text_value.rs | 14 +++++++++++--- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/world/block_entity.rs b/src/world/block_entity.rs index 6ad58a1..589a53c 100644 --- a/src/world/block_entity.rs +++ b/src/world/block_entity.rs @@ -41,10 +41,15 @@ pub struct Sign { impl Sign { /// Processes a [de::BlockEntitySign] into a [Sign] - fn new(sign: &de::BlockEntitySign, kind: SignKind, material: Option) -> Sign { + fn new( + sign: &de::BlockEntitySign, + kind: SignKind, + material: Option, + data_version: u32, + ) -> Sign { let (front_text, back_text) = sign.text(); - let front_text = front_text.decode(); - let back_text = back_text.decode(); + let front_text = front_text.decode(data_version); + let back_text = back_text.decode(data_version); Sign { kind, material, @@ -78,7 +83,11 @@ pub struct BlockEntity { impl BlockEntity { /// Processes a [de::BlockEntity] into a [BlockEntity] - pub fn new(entity: &de::BlockEntity, block_type: Option<&BlockType>) -> Option { + pub fn new( + entity: &de::BlockEntity, + block_type: Option<&BlockType>, + data_version: u32, + ) -> Option { let wall_sign = block_type .map(|block_type| block_type.block_color.is(BlockFlag::WallSign)) .unwrap_or_default(); @@ -92,7 +101,7 @@ impl BlockEntity { let material = block_type .as_ref() .and_then(|block_type| block_type.sign_material.as_ref()); - let data = BlockEntityData::Sign(Sign::new(sign, kind, material.cloned())); + let data = BlockEntityData::Sign(Sign::new(sign, kind, material.cloned(), data_version)); Some(BlockEntity { x: entity.x, diff --git a/src/world/chunk.rs b/src/world/chunk.rs index c4744d0..311fca8 100644 --- a/src/world/chunk.rs +++ b/src/world/chunk.rs @@ -58,6 +58,8 @@ pub struct Chunk<'a> { inner: ChunkInner<'a>, /// Unprocessed block entities block_entities: &'a Vec, + /// Chunk data version + data_version: u32, } impl<'a> Chunk<'a> { @@ -87,6 +89,7 @@ impl<'a> Chunk<'a> { Chunk { inner, block_entities, + data_version, }, has_unknown, )) @@ -292,7 +295,11 @@ impl<'a> Chunk<'a> { .iter() .map(|block_entity| { let block_type = self.block_type_at_block_entity(block_entity)?; - Ok(BlockEntity::new(block_entity, block_type)) + Ok(BlockEntity::new( + block_entity, + block_type, + self.data_version, + )) }) .collect::>()?; Ok(entities.into_iter().flatten().collect()) diff --git a/src/world/sign.rs b/src/world/sign.rs index c913b6f..8e4e670 100644 --- a/src/world/sign.rs +++ b/src/world/sign.rs @@ -49,7 +49,7 @@ static DYE_COLORS: phf::Map<&'static str, Color> = phf::phf_map! { impl RawSignText<'_> { /// Decodes the [RawSignText] into a [SignText] - pub fn decode(&self) -> SignText { + pub fn decode(&self, data_version: u32) -> SignText { let color = self .color .map(|c| DYE_COLORS.get(c).copied().unwrap_or(DEFAULT_COLOR)); @@ -60,7 +60,7 @@ impl RawSignText<'_> { SignText( self.messages .iter() - .map(|message| message.deserialize().linearize(&parent)) + .map(|message| message.deserialize(data_version).linearize(&parent)) .collect(), ) } diff --git a/src/world/text_value.rs b/src/world/text_value.rs index 336b1b1..75defc4 100644 --- a/src/world/text_value.rs +++ b/src/world/text_value.rs @@ -171,12 +171,20 @@ impl Default for DeserializedText { /// Minecraft raw text value #[derive(Debug, Deserialize)] -pub struct TextValue(pub String); +pub struct TextValue(pub fastnbt::Value); impl TextValue { /// Deserializes a [TextValue] into a [DeserializedText] - pub fn deserialize(&self) -> DeserializedText { - serde_json::from_str(&self.0).unwrap_or_default() + pub fn deserialize(&self, data_version: u32) -> DeserializedText { + if data_version < 4290 { + if let fastnbt::Value::String(json) = &self.0 { + if let Ok(content) = serde_json::from_str(json) { + return content; + } + } + } + + fastnbt::from_value(&self.0).unwrap_or_default() } } From 42b302f493a0824efa912fb8c56cf16c19adc266 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 2 Apr 2025 19:05:09 +0200 Subject: [PATCH 44/55] resource: add new Minecraft 1.21.5 block types --- CHANGELOG.md | 6 ++ crates/resource/src/block_types.rs | 90 ++++++++++++++++++++++++++++++ resource/blocks.json | 11 ++++ src/core/common.rs | 4 +- 4 files changed, 109 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 482d462..f96ddca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] - ReleaseDate +### Added + +- Added support for Minecraft 1.21.5 + + Added new block types and handling for changed sign text storage format. + ## [2.5.0] - 2025-03-16 ### Added diff --git a/crates/resource/src/block_types.rs b/crates/resource/src/block_types.rs index da556b8..044a153 100644 --- a/crates/resource/src/block_types.rs +++ b/crates/resource/src/block_types.rs @@ -1488,6 +1488,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "bush", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{Opaque|Grass}), + color: Color([119, 120, 119]), + }, + sign_material: None, + }, + ), ( "cactus", ConstBlockType { @@ -1498,6 +1508,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "cactus_flower", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{Opaque}), + color: Color([209, 120, 135]), + }, + sign_material: None, + }, + ), ( "cake", ConstBlockType { @@ -3808,6 +3828,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "firefly_bush", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{Opaque}), + color: Color([87, 83, 43]), + }, + sign_material: None, + }, + ), ( "fletching_table", ConstBlockType { @@ -4878,6 +4908,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "leaf_litter", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{}), + color: Color([0, 0, 0]), + }, + sign_material: None, + }, + ), ( "lectern", ConstBlockType { @@ -8698,6 +8738,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "short_dry_grass", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{Opaque}), + color: Color([187, 158, 108]), + }, + sign_material: None, + }, + ), ( "short_grass", ConstBlockType { @@ -9638,6 +9688,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "tall_dry_grass", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{Opaque}), + color: Color([196, 171, 122]), + }, + sign_material: None, + }, + ), ( "tall_grass", ConstBlockType { @@ -9678,6 +9738,26 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "test_block", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{}), + color: Color([0, 0, 0]), + }, + sign_material: None, + }, + ), + ( + "test_instance_block", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{}), + color: Color([0, 0, 0]), + }, + sign_material: None, + }, + ), ( "tinted_glass", ConstBlockType { @@ -10828,6 +10908,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "wildflowers", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{}), + color: Color([0, 0, 0]), + }, + sign_material: None, + }, + ), ( "wither_rose", ConstBlockType { diff --git a/resource/blocks.json b/resource/blocks.json index a409abb..caf6f8a 100644 --- a/resource/blocks.json +++ b/resource/blocks.json @@ -316,9 +316,13 @@ "bubble_coral_fan": null, "bubble_coral_wall_fan": null, "budding_amethyst": {}, + "bush": { + "grass": true + }, "cactus": { "texture": "cactus_top" }, + "cactus_flower": {}, "cake": { "texture": "cake_top" }, @@ -778,6 +782,7 @@ "fire_coral_block": {}, "fire_coral_fan": null, "fire_coral_wall_fan": null, + "firefly_bush": {}, "fletching_table": { "texture": "fletching_table_top" }, @@ -987,6 +992,7 @@ "lava_cauldron": { "texture": "cauldron_top" }, + "leaf_litter": null, "lectern": { "texture": "lectern_top" }, @@ -1782,6 +1788,7 @@ "sea_lantern": {}, "sea_pickle": {}, "seagrass": {}, + "short_dry_grass": {}, "short_grass": null, "shroomlight": {}, "shulker_box": {}, @@ -2013,6 +2020,7 @@ "sweet_berry_bush": { "texture": "sweet_berry_bush_stage3" }, + "tall_dry_grass": {}, "tall_grass": { "grass": true, "texture": "tall_grass_top" @@ -2024,6 +2032,8 @@ "texture": "target_top" }, "terracotta": {}, + "test_block": null, + "test_instance_block": null, "tinted_glass": {}, "tnt": { "texture": "tnt_top" @@ -2288,6 +2298,7 @@ "white_tulip": null, "white_wall_banner": null, "white_wool": {}, + "wildflowers": null, "wither_rose": null, "wither_skeleton_skull": null, "wither_skeleton_wall_skull": null, diff --git a/src/core/common.rs b/src/core/common.rs index 06a3277..d285f4c 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -26,7 +26,7 @@ use crate::{ /// /// Increase when the generation of processed regions from region data changes /// (usually because of updated resource data) -pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(6); +pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(7); /// MinedMap map tile data version number /// @@ -38,7 +38,7 @@ pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// /// Increase when the generation of lightmap tiles from region data changes /// (usually because of updated resource data) -pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(4); +pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(5); /// MinedMap mipmap data version number /// From 69b62576ea805c2674144f5f600ad00fecdbb111 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 3 Apr 2025 18:37:36 +0200 Subject: [PATCH 45/55] world/chunk: fix new Rust 1.86 clippy warning --- src/world/chunk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/chunk.rs b/src/world/chunk.rs index 311fca8..aadf882 100644 --- a/src/world/chunk.rs +++ b/src/world/chunk.rs @@ -419,7 +419,7 @@ impl<'a> Iterator for SectionIter<'a> { } fn last(mut self) -> Option { - self.with_iter(|iter| iter.last()) + self.next_back() } } From dd56e842b526774aa0d1bba035b7da6d7cdd57e9 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 3 Apr 2025 18:31:41 +0200 Subject: [PATCH 46/55] ci: update to Rust 1.86 There is no official 1.86 Docker image yet. --- .github/workflows/MinedMap.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index ece4e50..4dbb5d2 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85.1' + toolchain: '1.86' components: rustfmt - run: cargo fmt --all -- --check @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85.1' + toolchain: '1.86' components: clippy - uses: swatinem/rust-cache@v2 - uses: actions-rs/clippy-check@v1 @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85.1' + toolchain: '1.86' components: rust-docs - uses: swatinem/rust-cache@v2 - run: cargo doc --workspace --no-deps --document-private-items @@ -87,7 +87,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85.1' + toolchain: '1.86' - uses: swatinem/rust-cache@v2 - run: cargo test --workspace - run: cargo test --workspace --no-default-features @@ -127,7 +127,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.85.1' + toolchain: '1.86' targets: '${{ matrix.target }}' - uses: swatinem/rust-cache@v2 From ca880ab3b457a12f775e83a43b3ede5804f7bc63 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 3 Apr 2025 18:26:49 +0200 Subject: [PATCH 47/55] world/text_value: do not fall back to NBT deserialization after DataVersion 4290 An invalid JSON string should not be emitted verbatim; ignore the content instead. Also increment entity meta version, which had been forgotten in the previous commit. --- src/core/common.rs | 2 +- src/world/text_value.rs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/common.rs b/src/core/common.rs index d285f4c..45b541c 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -48,7 +48,7 @@ pub const MIPMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// MinedMap processed entity data version number /// /// Increase when entity collection changes bacause of code changes. -pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(2); +pub const ENTITIES_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(3); /// Coordinate pair of a generated tile /// diff --git a/src/world/text_value.rs b/src/world/text_value.rs index 75defc4..3de6593 100644 --- a/src/world/text_value.rs +++ b/src/world/text_value.rs @@ -176,15 +176,20 @@ pub struct TextValue(pub fastnbt::Value); impl TextValue { /// Deserializes a [TextValue] into a [DeserializedText] pub fn deserialize(&self, data_version: u32) -> DeserializedText { + // TODO: Improve error handling + // + // Unfortunately, there are a number of weird ways an empty sign coould + // be encoded (for example a compound with an "" key), so for now we + // simply interpret undecodable data as empty. if data_version < 4290 { - if let fastnbt::Value::String(json) = &self.0 { - if let Ok(content) = serde_json::from_str(json) { - return content; - } - } - } + let fastnbt::Value::String(json) = &self.0 else { + return DeserializedText::default(); + }; - fastnbt::from_value(&self.0).unwrap_or_default() + serde_json::from_str(json).unwrap_or_default() + } else { + fastnbt::from_value(&self.0).unwrap_or_default() + } } } From ec4fd7986497f9d1e03626c4044ebf07cd561271 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 29 Jun 2025 17:04:15 +0200 Subject: [PATCH 48/55] Update dependencies --- Cargo.lock | 394 ++++++++++++++++++++++++++++++----------------------- Cargo.toml | 4 +- 2 files changed, 228 insertions(+), 170 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d9f14f8..8187256 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,9 +13,9 @@ dependencies = [ [[package]] name = "adler2" -version = "2.0.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aho-corasick" @@ -34,9 +34,9 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "anstream" -version = "0.6.18" +version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" dependencies = [ "anstyle", "anstyle-parse", @@ -49,56 +49,56 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" [[package]] name = "anstyle-parse" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" dependencies = [ "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.7" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" dependencies = [ "anstyle", - "once_cell", + "once_cell_polyfill", "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "backtrace" -version = "0.3.74" +version = "0.3.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" dependencies = [ "addr2line", "cfg-if", @@ -106,7 +106,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -137,15 +137,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" [[package]] name = "bytemuck" -version = "1.22.0" +version = "1.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" [[package]] name = "byteorder" @@ -161,9 +161,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cc" -version = "1.2.17" +version = "1.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" dependencies = [ "jobserver", "libc", @@ -178,15 +178,15 @@ checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "clap" -version = "4.5.35" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" +checksum = "40b6887a1d8685cebccf115538db5c0efe625ccac9696ad45c409d96566e910f" dependencies = [ "clap_builder", "clap_derive", @@ -194,9 +194,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.35" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" +checksum = "e0c66c08ce9f0c698cbce5c0279d0bb6ac936d8674174fe48f736533b964f59e" dependencies = [ "anstream", "anstyle", @@ -207,9 +207,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.32" +version = "4.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +checksum = "d2c7947ae4cc3d851207c1adb5b5e260ff0cca11446b1d6d1423788e442257ce" dependencies = [ "heck", "proc-macro2", @@ -219,15 +219,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" [[package]] name = "colorchoice" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" [[package]] name = "crc32fast" @@ -291,18 +291,18 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba2f4b465f5318854c6f8dd686ede6c0a9dc67d4b1ac241cf0eb51521a309147" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4caf64a58d7a6d65ab00639b046ff54399a39f5f2554728895ace4b297cd79" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" dependencies = [ "proc-macro2", "quote", @@ -317,12 +317,12 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" dependencies = [ "libc", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] @@ -337,6 +337,12 @@ dependencies = [ "serde_bytes", ] +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + [[package]] name = "fdeflate" version = "0.3.7" @@ -360,9 +366,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", "libz-rs-sys", @@ -423,9 +429,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" dependencies = [ "cfg-if", "libc", @@ -461,15 +467,15 @@ dependencies = [ [[package]] name = "glam" -version = "0.30.1" +version = "0.30.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf3aa70d918d2b234126ff4f850f628f172542bf0603ded26b8ee36e5e22d5f9" +checksum = "50a99dbe56b72736564cfa4b85bf9a33079f16ae8b74983ab06af3b1a3696b11" [[package]] name = "hashbrown" -version = "0.15.2" +version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" dependencies = [ "allocator-api2", "equivalent", @@ -484,9 +490,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" -version = "0.3.9" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" [[package]] name = "humantime" @@ -509,9 +515,9 @@ dependencies = [ [[package]] name = "image-webp" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77d01e822461baa8409e156015a1d91735549f0f2c17691bd2d996bef238f7f" +checksum = "f6970fe7a5300b4b42e62c52efa0187540a5bef546c60edaf554ef595d2e6f0b" dependencies = [ "byteorder-lite", "quick-error", @@ -519,9 +525,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.8.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", "hashbrown", @@ -533,7 +539,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "inotify-sys", "libc", ] @@ -580,9 +586,9 @@ dependencies = [ [[package]] name = "kqueue" -version = "1.0.8" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7447f1ca1b7b563588a205fe93dea8df60fd981423a768bc1c0ded35ed147d0c" +checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a" dependencies = [ "kqueue-sys", "libc", @@ -606,41 +612,41 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.171" +version = "0.2.174" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" [[package]] name = "libredox" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +checksum = "1580801010e535496706ba011c15f8532df6b42297d2e471fec38ceadd8c0638" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "libc", "redox_syscall", ] [[package]] name = "libz-rs-sys" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6489ca9bd760fe9642d7644e827b0c9add07df89857b0416ee15c1cc1a3b8c5a" +checksum = "172a788537a2221661b480fee8dc5f96c580eb34fa88764d3205dc356c7e4221" dependencies = [ "zlib-rs", ] [[package]] name = "linux-raw-sys" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "lock_api" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" dependencies = [ "autocfg", "scopeguard", @@ -654,18 +660,18 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" -version = "0.13.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" +checksum = "0281c2e25e62316a5c9d98f2d2e9e95a37841afdaf4383c177dbb5c1dfab0568" dependencies = [ "hashbrown", ] [[package]] name = "memchr" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "minedmap" @@ -741,9 +747,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", "simd-adler32", @@ -751,14 +757,14 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" dependencies = [ "libc", "log", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.52.0", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", ] [[package]] @@ -767,7 +773,7 @@ version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "filetime", "fsevent-sys", "inotify", @@ -816,9 +822,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" dependencies = [ "hermit-abi", "libc", @@ -839,6 +845,12 @@ version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + [[package]] name = "overload" version = "0.1.1" @@ -847,9 +859,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "parking_lot" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" dependencies = [ "lock_api", "parking_lot_core", @@ -857,42 +869,43 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.10" +version = "0.9.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] name = "phf" -version = "0.11.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" dependencies = [ "phf_macros", "phf_shared", + "serde", ] [[package]] name = "phf_generator" -version = "0.11.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" +checksum = "2cbb1126afed61dd6368748dae63b1ee7dc480191c6262a3b4ff1e29d86a6c5b" dependencies = [ + "fastrand", "phf_shared", - "rand", ] [[package]] name = "phf_macros" -version = "0.11.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" +checksum = "d713258393a82f091ead52047ca779d37e5766226d009de21696c4e667044368" dependencies = [ "phf_generator", "phf_shared", @@ -903,9 +916,9 @@ dependencies = [ [[package]] name = "phf_shared" -version = "0.11.3" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" dependencies = [ "siphasher", ] @@ -943,9 +956,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -967,24 +980,9 @@ dependencies = [ [[package]] name = "r-efi" -version = "5.2.0" +version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" [[package]] name = "rayon" @@ -1008,11 +1006,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.10" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" +checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] @@ -1046,9 +1044,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rustc-demangle" -version = "0.1.24" +version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f" [[package]] name = "rustc-hash" @@ -1058,11 +1056,11 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "1.0.5" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", "errno", "libc", "linux-raw-sys", @@ -1160,18 +1158,15 @@ checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" [[package]] name = "slab" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "strsim" @@ -1181,9 +1176,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.100" +version = "2.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" dependencies = [ "proc-macro2", "quote", @@ -1202,12 +1197,11 @@ dependencies = [ [[package]] name = "thread_local" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" dependencies = [ "cfg-if", - "once_cell", ] [[package]] @@ -1232,9 +1226,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.44.1" +version = "1.45.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779" dependencies = [ "backtrace", "parking_lot", @@ -1254,9 +1248,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.28" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" dependencies = [ "proc-macro2", "quote", @@ -1265,9 +1259,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" dependencies = [ "once_cell", "valuable", @@ -1340,9 +1334,9 @@ dependencies = [ [[package]] name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" +version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasi" @@ -1384,22 +1378,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", ] [[package]] @@ -1408,14 +1402,30 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", ] [[package]] @@ -1424,62 +1434,110 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + [[package]] name = "wit-bindgen-rt" version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "bitflags 2.9.0", + "bitflags 2.9.1", ] [[package]] name = "zlib-rs" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "868b928d7949e09af2f6086dfc1e01936064cc7a819253bce650d4e2a2d63ba8" +checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a" [[package]] name = "zstd" diff --git a/Cargo.toml b/Cargo.toml index 34e5619..2f7a483 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,7 +48,7 @@ git-version = "0.3.5" humantime = "2.1.0" image = { version = "0.25.1", default-features = false, features = ["png", "webp"] } indexmap = "2.0.0" -lru = "0.13.0" +lru = "0.15.0" minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } minedmap-nbt = { version = "0.2.0", path = "crates/nbt", default-features = false } minedmap-resource = { version = "0.7.0", path = "crates/resource" } @@ -56,7 +56,7 @@ minedmap-types = { version = "0.2.0", path = "crates/types" } notify = "8.0.0" num-integer = "0.1.45" num_cpus = "1.16.0" -phf = { version = "0.11.2", features = ["macros"] } +phf = { version = "0.12.1", features = ["macros"] } rayon = "1.7.0" regex = "1.10.2" rustc-hash = "2.0.0" From 64e7375f2fe171d5d9226f5ab6b938c5316aa198 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 29 Jun 2025 17:05:59 +0200 Subject: [PATCH 49/55] Fix 1.88.0 clippy warnings --- crates/nbt/examples/nbtdump.rs | 2 +- crates/nbt/examples/regiondump.rs | 2 +- crates/nbt/src/region.rs | 6 +++--- src/core/common.rs | 4 ++-- src/core/region_processor.rs | 11 ++++------- src/core/tile_renderer.rs | 6 +++--- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/crates/nbt/examples/nbtdump.rs b/crates/nbt/examples/nbtdump.rs index 66aaa2a..8b61693 100644 --- a/crates/nbt/examples/nbtdump.rs +++ b/crates/nbt/examples/nbtdump.rs @@ -20,7 +20,7 @@ fn main() -> Result<()> { let args = Args::parse(); let value: fastnbt::Value = minedmap_nbt::data::from_file(args.file.as_path())?; - println!("{:#x?}", value); + println!("{value:#x?}"); Ok(()) } diff --git a/crates/nbt/examples/regiondump.rs b/crates/nbt/examples/regiondump.rs index 9315022..7cece8c 100644 --- a/crates/nbt/examples/regiondump.rs +++ b/crates/nbt/examples/regiondump.rs @@ -21,7 +21,7 @@ fn main() -> Result<()> { minedmap_nbt::region::from_file(args.file.as_path())?.foreach_chunk( |coords, value: fastnbt::Value| { - println!("Chunk {:?}: {:#x?}", coords, value); + println!("Chunk {coords:?}: {value:#x?}"); Ok(()) }, ) diff --git a/crates/nbt/src/region.rs b/crates/nbt/src/region.rs index 1325919..6a79a39 100644 --- a/crates/nbt/src/region.rs +++ b/crates/nbt/src/region.rs @@ -124,7 +124,7 @@ impl Region { let mut len_buf = [0u8; 4]; reader .read_exact(&mut len_buf) - .with_context(|| format!("Failed to read length for chunk {:?}", coords))?; + .with_context(|| format!("Failed to read length for chunk {coords:?}"))?; let byte_len = u32::from_be_bytes(len_buf) as usize; if byte_len < 1 || byte_len > (len as usize) * BLOCKSIZE - 4 { bail!("Invalid length for chunk {:?}", coords); @@ -133,9 +133,9 @@ impl Region { let mut buffer = vec![0; byte_len]; reader .read_exact(&mut buffer) - .with_context(|| format!("Failed to read data for chunk {:?}", coords))?; + .with_context(|| format!("Failed to read data for chunk {coords:?}"))?; let chunk = decode_chunk(&buffer) - .with_context(|| format!("Failed to decode data for chunk {:?}", coords))?; + .with_context(|| format!("Failed to decode data for chunk {coords:?}"))?; f(coords, chunk)?; } diff --git a/src/core/common.rs b/src/core/common.rs index 45b541c..3f3e69d 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -237,7 +237,7 @@ impl Config { fn sign_transform(splitter: &Regex, transform: &str) -> Result<(Regex, String)> { let captures = splitter .captures(transform) - .with_context(|| format!("Invalid transform pattern '{}'", transform))?; + .with_context(|| format!("Invalid transform pattern '{transform}'"))?; let regexp = Regex::new(&captures[1])?; let replacement = captures[2].to_string(); Ok((regexp, replacement)) @@ -275,7 +275,7 @@ impl Config { TileKind::Map => "map", TileKind::Lightmap => "light", }; - let dir = format!("{}/{}", prefix, level); + let dir = format!("{prefix}/{level}"); [&self.output_dir, Path::new(&dir)].iter().collect() } diff --git a/src/core/region_processor.rs b/src/core/region_processor.rs index e638342..74939bd 100644 --- a/src/core/region_processor.rs +++ b/src/core/region_processor.rs @@ -228,7 +228,7 @@ impl<'a> SingleRegionProcessor<'a> { ) -> Result<()> { let (chunk, has_unknown) = world::chunk::Chunk::new(&chunk_data, self.block_types, self.biome_types) - .with_context(|| format!("Failed to decode chunk {:?}", chunk_coords))?; + .with_context(|| format!("Failed to decode chunk {chunk_coords:?}"))?; data.has_unknown |= has_unknown; if self.output_needed || self.lightmap_needed { @@ -238,7 +238,7 @@ impl<'a> SingleRegionProcessor<'a> { block_light, depths, }) = world::layer::top_layer(&mut data.biome_list, &chunk) - .with_context(|| format!("Failed to process chunk {:?}", chunk_coords))? + .with_context(|| format!("Failed to process chunk {chunk_coords:?}"))? { if self.output_needed { data.chunks[chunk_coords] = Some(Box::new(ProcessedChunk { @@ -257,10 +257,7 @@ impl<'a> SingleRegionProcessor<'a> { if self.entities_needed { let mut block_entities = chunk.block_entities().with_context(|| { - format!( - "Failed to process block entities for chunk {:?}", - chunk_coords, - ) + format!("Failed to process block entities for chunk {chunk_coords:?}") })?; data.entities.block_entities.append(&mut block_entities); } @@ -407,7 +404,7 @@ impl<'a> RegionProcessor<'a> { self.collect_regions()?.par_iter().try_for_each(|&coords| { let ret = self .process_region(coords) - .with_context(|| format!("Failed to process region {:?}", coords))?; + .with_context(|| format!("Failed to process region {coords:?}"))?; if ret != Status::ErrorMissing { region_send.send(coords).unwrap(); diff --git a/src/core/tile_renderer.rs b/src/core/tile_renderer.rs index 9d7e188..0b534b8 100644 --- a/src/core/tile_renderer.rs +++ b/src/core/tile_renderer.rs @@ -249,7 +249,7 @@ impl<'a> TileRenderer<'a> { .filter(|entry| self.region_set.contains(entry)) }) .try_map(|entry| self.processed_source(entry)) - .with_context(|| format!("Region {:?} from previous step must exist", coords))?; + .with_context(|| format!("Region {coords:?} from previous step must exist"))?; let max_timestamp = *sources .iter() @@ -293,7 +293,7 @@ impl<'a> TileRenderer<'a> { let region_group = self .rt .block_on(self.load_region_group(processed_paths)) - .with_context(|| format!("Region {:?} from previous step must be loadable", coords))?; + .with_context(|| format!("Region {coords:?} from previous step must be loadable"))?; let mut image = image::RgbaImage::new(N, N); Self::render_region(&mut image, ®ion_group); @@ -325,7 +325,7 @@ impl<'a> TileRenderer<'a> { .map(|&coords| { anyhow::Ok(usize::from( self.render_tile(coords) - .with_context(|| format!("Failed to render tile {:?}", coords))?, + .with_context(|| format!("Failed to render tile {coords:?}"))?, )) }) .try_reduce(|| 0, |a, b| Ok(a + b))?; From 6a2f5356d90959a2d2664383975cee88fcdb930a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 29 Jun 2025 17:26:59 +0200 Subject: [PATCH 50/55] ci, docker: update to Rust 1.88.0 --- .github/workflows/MinedMap.yml | 10 +++++----- Dockerfile | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/MinedMap.yml b/.github/workflows/MinedMap.yml index 4dbb5d2..a0e58cf 100644 --- a/.github/workflows/MinedMap.yml +++ b/.github/workflows/MinedMap.yml @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.86' + toolchain: '1.88' components: rustfmt - run: cargo fmt --all -- --check @@ -58,7 +58,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.86' + toolchain: '1.88' components: clippy - uses: swatinem/rust-cache@v2 - uses: actions-rs/clippy-check@v1 @@ -72,7 +72,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.86' + toolchain: '1.88' components: rust-docs - uses: swatinem/rust-cache@v2 - run: cargo doc --workspace --no-deps --document-private-items @@ -87,7 +87,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.86' + toolchain: '1.88' - uses: swatinem/rust-cache@v2 - run: cargo test --workspace - run: cargo test --workspace --no-default-features @@ -127,7 +127,7 @@ jobs: - uses: dtolnay/rust-toolchain@master with: - toolchain: '1.86' + toolchain: '1.88' targets: '${{ matrix.target }}' - uses: swatinem/rust-cache@v2 diff --git a/Dockerfile b/Dockerfile index ad36c79..4b9de31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/rust:1.85.1-alpine AS builder +FROM docker.io/library/rust:1.88.0-alpine AS builder WORKDIR /build RUN apk add --no-cache build-base tini-static From 19355d8f64732de0be43e736556f5814cfaa4159 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 29 Jun 2025 23:29:02 +0200 Subject: [PATCH 51/55] README.md: add link to minecraft_map_marker project --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 952163f..6402d21 100644 --- a/README.md +++ b/README.md @@ -120,3 +120,8 @@ cargo install --git 'https://github.com/neocturne/MinedMap.git' If you are looking for the older C++ implementation of the MinedMap tile renderer, see the [v1.19.1](https://github.com/neocturne/MinedMap/tree/v1.19.1) tag. +## See also + +Other projects using MinedMap: + +- [minecraft\_map\_marker](https://github.com/christopher-besch/minecraft_map_marker) From 04aeacbfd41a2b49c84d8cd5710406bf8e0d762a Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 29 Jun 2025 23:53:56 +0200 Subject: [PATCH 52/55] resource: add Minecraft 1.21.6 Dried Ghast block type As Minecraft 1.21.7 is a hotfix release with no new block types or biomes, it is supported as well. --- CHANGELOG.md | 2 +- README.md | 2 +- crates/resource/src/block_types.rs | 10 ++++++++++ resource/blocks.json | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f96ddca..94dbb8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Added -- Added support for Minecraft 1.21.5 +- Added support for Minecraft 1.21.5 to 1.21.7 Added new block types and handling for changed sign text storage format. diff --git a/README.md b/README.md index 6402d21..cd30c8b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ * Render beautiful maps of your [Minecraft](https://minecraft.net/) worlds! * Put them on a webserver and view them in your browser! -* Compatible with unmodified Minecraft Java Edition 1.8 up to 1.21.4 (no mod installation required!) +* Compatible with unmodified Minecraft Java Edition 1.8 up to 1.21.7 (no mod installation required!) * Illumination layer: the world at night * Fast: create a full map for a huge 3GB savegame in less than 5 minutes in single-threaded operation * Multi-threading support: pass `-j N` to the renderer to use `N` parallel threads for generation diff --git a/crates/resource/src/block_types.rs b/crates/resource/src/block_types.rs index 044a153..9419690 100644 --- a/crates/resource/src/block_types.rs +++ b/crates/resource/src/block_types.rs @@ -3508,6 +3508,16 @@ pub const BLOCK_TYPES: &[(&str, ConstBlockType)] = &[ sign_material: None, }, ), + ( + "dried_ghast", + ConstBlockType { + block_color: BlockColor { + flags: make_bitflags!(BlockFlag::{Opaque}), + color: Color([179, 168, 168]), + }, + sign_material: None, + }, + ), ( "dried_kelp_block", ConstBlockType { diff --git a/resource/blocks.json b/resource/blocks.json index caf6f8a..15dae2b 100644 --- a/resource/blocks.json +++ b/resource/blocks.json @@ -720,6 +720,9 @@ "dragon_egg": {}, "dragon_head": null, "dragon_wall_head": null, + "dried_ghast": { + "texture": "dried_ghast_hydration_1_top" + }, "dried_kelp_block": { "texture": "dried_kelp_top" }, From 8278185c9c6dff03838423482321d39425eee4a5 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 Jun 2025 22:00:59 +0200 Subject: [PATCH 53/55] core: update region and lightmap version The versions need to be updated for the new block type. --- src/core/common.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/common.rs b/src/core/common.rs index 3f3e69d..094d567 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -26,7 +26,7 @@ use crate::{ /// /// Increase when the generation of processed regions from region data changes /// (usually because of updated resource data) -pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(7); +pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(8); /// MinedMap map tile data version number /// @@ -38,7 +38,7 @@ pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0); /// /// Increase when the generation of lightmap tiles from region data changes /// (usually because of updated resource data) -pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(5); +pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(6); /// MinedMap mipmap data version number /// From 190b92b68d474db18a406146c0c2819439b274c4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 Jun 2025 22:07:55 +0200 Subject: [PATCH 54/55] minedmap-resource 0.8.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/resource/Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8187256..953a4a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -730,7 +730,7 @@ dependencies = [ [[package]] name = "minedmap-resource" -version = "0.7.0" +version = "0.8.0" dependencies = [ "bincode", "enumflags2", diff --git a/Cargo.toml b/Cargo.toml index 2f7a483..39664f7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ indexmap = "2.0.0" lru = "0.15.0" minedmap-default-alloc = { version = "0.1.0", path = "crates/default-alloc", optional = true } minedmap-nbt = { version = "0.2.0", path = "crates/nbt", default-features = false } -minedmap-resource = { version = "0.7.0", path = "crates/resource" } +minedmap-resource = { version = "0.8.0", path = "crates/resource" } minedmap-types = { version = "0.2.0", path = "crates/types" } notify = "8.0.0" num-integer = "0.1.45" diff --git a/crates/resource/Cargo.toml b/crates/resource/Cargo.toml index 1257a90..b59492c 100644 --- a/crates/resource/Cargo.toml +++ b/crates/resource/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "minedmap-resource" -version = "0.7.0" +version = "0.8.0" description = "Data describing Minecraft biomes and block types" edition.workspace = true license.workspace = true From f0ef6d318983580e99082822b965a68d585d4e16 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 30 Jun 2025 22:08:16 +0200 Subject: [PATCH 55/55] minedmap 2.6.0 --- CHANGELOG.md | 5 ++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94dbb8b..f1f0234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [Unreleased] - ReleaseDate +## [2.6.0] - 2025-06-30 + ### Added - Added support for Minecraft 1.21.5 to 1.21.7 @@ -194,7 +196,8 @@ intermediate data. Full support for custom biomes datapacks might be added in a future release. -[Unreleased]: https://github.com/neocturne/MinedMap/compare/v2.5.0...HEAD +[Unreleased]: https://github.com/neocturne/MinedMap/compare/v2.6.0...HEAD +[2.6.0]: https://github.com/neocturne/MinedMap/compare/v2.5.0...v2.6.0 [2.5.0]: https://github.com/neocturne/MinedMap/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/neocturne/MinedMap/compare/v2.3.1...v2.4.0 [2.3.1]: https://github.com/neocturne/MinedMap/compare/v2.3.0...v2.3.1 diff --git a/Cargo.lock b/Cargo.lock index 953a4a3..a000b9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -675,7 +675,7 @@ checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" [[package]] name = "minedmap" -version = "2.5.0" +version = "2.6.0" dependencies = [ "anyhow", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 39664f7..f0c2bc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ pre-release-commit-message = "{{crate_name}} {{version}}" [package] name = "minedmap" -version = "2.5.0" +version = "2.6.0" description = "Generate browsable maps from Minecraft save data" edition.workspace = true license.workspace = true