Merge pull request #42 from neocturne/updates

Dependency updates & some region processor refactoring
This commit is contained in:
Matthias Schiffer 2023-12-30 01:28:04 +01:00 committed by GitHub
commit c67f3b8c48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 405 additions and 284 deletions

237
Cargo.lock generated
View file

@ -37,9 +37,9 @@ checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]] [[package]]
name = "anstream" name = "anstream"
version = "0.6.4" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"anstyle-parse", "anstyle-parse",
@ -57,27 +57,27 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
[[package]] [[package]]
name = "anstyle-parse" name = "anstyle-parse"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"
dependencies = [ dependencies = [
"utf8parse", "utf8parse",
] ]
[[package]] [[package]]
name = "anstyle-query" name = "anstyle-query"
version = "1.0.0" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648"
dependencies = [ dependencies = [
"windows-sys", "windows-sys",
] ]
[[package]] [[package]]
name = "anstyle-wincon" name = "anstyle-wincon"
version = "3.0.1" version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"
dependencies = [ dependencies = [
"anstyle", "anstyle",
"windows-sys", "windows-sys",
@ -85,9 +85,9 @@ dependencies = [
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.75" version = "1.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" checksum = "c9d19de80eff169429ac1e9f48fffb163916b448a44e8e046186232046d9e1f9"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
@ -161,9 +161,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.8" version = "4.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
dependencies = [ dependencies = [
"clap_builder", "clap_builder",
"clap_derive", "clap_derive",
@ -171,9 +171,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_builder" name = "clap_builder"
version = "4.4.8" version = "4.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9"
dependencies = [ dependencies = [
"anstream", "anstream",
"anstyle", "anstyle",
@ -231,9 +231,9 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-deque" name = "crossbeam-deque"
version = "0.8.3" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-epoch", "crossbeam-epoch",
@ -242,22 +242,20 @@ dependencies = [
[[package]] [[package]]
name = "crossbeam-epoch" name = "crossbeam-epoch"
version = "0.9.15" version = "0.9.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"cfg-if", "cfg-if",
"crossbeam-utils", "crossbeam-utils",
"memoffset",
"scopeguard",
] ]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.16" version = "0.8.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
@ -309,9 +307,9 @@ dependencies = [
[[package]] [[package]]
name = "fdeflate" name = "fdeflate"
version = "0.3.1" version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" checksum = "209098dd6dfc4445aa6111f0e98653ac323eaa4dfd212c9ca3931bf9955c31bd"
dependencies = [ dependencies = [
"simd-adler32", "simd-adler32",
] ]
@ -329,15 +327,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-core" name = "futures-core"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d"
[[package]] [[package]]
name = "futures-macro" name = "futures-macro"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -346,15 +344,15 @@ dependencies = [
[[package]] [[package]]
name = "futures-task" name = "futures-task"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004"
[[package]] [[package]]
name = "futures-util" name = "futures-util"
version = "0.3.29" version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-macro", "futures-macro",
@ -366,24 +364,24 @@ dependencies = [
[[package]] [[package]]
name = "gimli" name = "gimli"
version = "0.28.0" version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
[[package]] [[package]]
name = "git-version" name = "git-version"
version = "0.3.8" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13ad01ffa8221f7fe8b936d6ffb2a3e7ad428885a04fad51866a5f33eafda57c" checksum = "1ad568aa3db0fcbc81f2f116137f263d7304f512a1209b35b85150d3ef88ad19"
dependencies = [ dependencies = [
"git-version-macro", "git-version-macro",
] ]
[[package]] [[package]]
name = "git-version-macro" name = "git-version-macro"
version = "0.3.8" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84488ccbdb24ad6f56dc1863b4a8154a7856cd3c6c7610401634fab3cb588dae" checksum = "53010ccb100b96a67bc32c0175f0ed1426b31b655d562898e57325f81c023ac0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -392,15 +390,15 @@ dependencies = [
[[package]] [[package]]
name = "glam" name = "glam"
version = "0.24.2" version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945" checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.2" version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [ dependencies = [
"ahash", "ahash",
"allocator-api2", "allocator-api2",
@ -454,9 +452,9 @@ dependencies = [
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.9" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]] [[package]]
name = "jobserver" name = "jobserver"
@ -475,9 +473,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.150" version = "0.2.151"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
[[package]] [[package]]
name = "libz-ng-sys" name = "libz-ng-sys"
@ -507,27 +505,18 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]] [[package]]
name = "lru" name = "lru"
version = "0.12.0" version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efa59af2ddfad1854ae27d75009d538d0998b4b2fd47083e743ac1a10e46c60" checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7"
dependencies = [ dependencies = [
"hashbrown", "hashbrown",
] ]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.6.4" version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "memoffset"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "minedmap" name = "minedmap"
@ -539,7 +528,6 @@ dependencies = [
"fastnbt", "fastnbt",
"futures-util", "futures-util",
"git-version", "git-version",
"glam",
"image", "image",
"indexmap", "indexmap",
"lru", "lru",
@ -650,18 +638,18 @@ dependencies = [
[[package]] [[package]]
name = "object" name = "object"
version = "0.32.1" version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.18.0" version = "1.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]] [[package]]
name = "overload" name = "overload"
@ -689,7 +677,7 @@ dependencies = [
"libc", "libc",
"redox_syscall", "redox_syscall",
"smallvec", "smallvec",
"windows-targets", "windows-targets 0.48.5",
] ]
[[package]] [[package]]
@ -706,9 +694,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.27" version = "0.3.28"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
[[package]] [[package]]
name = "png" name = "png"
@ -725,9 +713,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.69" version = "1.0.71"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -784,9 +772,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.15" version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
@ -796,27 +784,27 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.192" version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_bytes" name = "serde_bytes"
version = "0.11.12" version = "0.11.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab33ec92f677585af6d88c65593ae2375adde54efdbf16d597f2cbc7a6d368ff" checksum = "8bb1879ea93538b78549031e2d54da3e901fd7e75f2e4dc758d760937b123d10"
dependencies = [ dependencies = [
"serde", "serde",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.192" version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -872,9 +860,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.39" version = "2.0.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -893,9 +881,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.34.0" version = "1.35.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"parking_lot", "parking_lot",
@ -1007,11 +995,11 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [ dependencies = [
"windows-targets", "windows-targets 0.52.0",
] ]
[[package]] [[package]]
@ -1020,13 +1008,28 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [ dependencies = [
"windows_aarch64_gnullvm", "windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc", "windows_aarch64_msvc 0.48.5",
"windows_i686_gnu", "windows_i686_gnu 0.48.5",
"windows_i686_msvc", "windows_i686_msvc 0.48.5",
"windows_x86_64_gnu", "windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm", "windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc", "windows_x86_64_msvc 0.48.5",
]
[[package]]
name = "windows-targets"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
dependencies = [
"windows_aarch64_gnullvm 0.52.0",
"windows_aarch64_msvc 0.52.0",
"windows_i686_gnu 0.52.0",
"windows_i686_msvc 0.52.0",
"windows_x86_64_gnu 0.52.0",
"windows_x86_64_gnullvm 0.52.0",
"windows_x86_64_msvc 0.52.0",
] ]
[[package]] [[package]]
@ -1035,36 +1038,72 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.48.5" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.48.5" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.48.5" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.48.5" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
[[package]] [[package]]
name = "windows_x86_64_gnullvm" name = "windows_x86_64_gnullvm"
version = "0.48.5" version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.48.5" version = "0.48.5"
@ -1072,19 +1111,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]] [[package]]
name = "zerocopy" name = "windows_x86_64_msvc"
version = "0.7.26" version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "zerocopy"
version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
dependencies = [ dependencies = [
"zerocopy-derive", "zerocopy-derive",
] ]
[[package]] [[package]]
name = "zerocopy-derive" name = "zerocopy-derive"
version = "0.7.26" version = "0.7.32"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -43,7 +43,6 @@ clap = { version = "4.1.4", features = ["derive"] }
fastnbt = "2.3.2" fastnbt = "2.3.2"
futures-util = "0.3.28" futures-util = "0.3.28"
git-version = "0.3.5" git-version = "0.3.5"
glam = "0.24.0"
image = { version = "0.24.5", default-features = false, features = ["png"] } image = { version = "0.24.5", default-features = false, features = ["png"] }
indexmap = { version = "2.0.0", features = ["serde"] } indexmap = { version = "2.0.0", features = ["serde"] }
lru = "0.12.0" lru = "0.12.0"

View file

@ -9,5 +9,5 @@ repository.workspace = true
[dependencies] [dependencies]
enumflags2 = { version = "0.7.7", features = ["serde"] } enumflags2 = { version = "0.7.7", features = ["serde"] }
glam = "0.24.1" glam = "0.25.0"
serde = { version = "1.0.183", features = ["derive"] } serde = { version = "1.0.183", features = ["derive"] }

View file

@ -1,16 +1,14 @@
//! Functions for computations of block colors //! Functions for computations of block colors
use super::{Biome, BlockType, Color}; use super::{Biome, BlockType, Color, Colorf};
use glam::Vec3;
/// Converts an u8 RGB color to a float vector /// Converts an u8 RGB color to a float vector
fn color_vec_unscaled(color: Color) -> Vec3 { fn color_vec_unscaled(color: Color) -> Colorf {
Vec3::from_array(color.0.map(f32::from)) Colorf::from_array(color.0.map(f32::from))
} }
/// Converts an u8 RGB color to a float vector, scaling the components to 0.0..1.0 /// Converts an u8 RGB color to a float vector, scaling the components to 0.0..1.0
fn color_vec(color: Color) -> Vec3 { fn color_vec(color: Color) -> Colorf {
color_vec_unscaled(color) / 255.0 color_vec_unscaled(color) / 255.0
} }
@ -18,7 +16,7 @@ fn color_vec(color: Color) -> Vec3 {
/// ///
/// Biome temperature and downfall are modified based on the depth value /// Biome temperature and downfall are modified based on the depth value
/// before using them to compute the final color /// before using them to compute the final color
fn color_from_params(colors: &[Vec3; 3], biome: &Biome, depth: f32) -> Vec3 { fn color_from_params(colors: &[Colorf; 3], biome: &Biome, depth: f32) -> Colorf {
let temp = (biome.temp() - f32::max((depth - 64.0) / 600.0, 0.0)).clamp(0.0, 1.0); let temp = (biome.temp() - f32::max((depth - 64.0) / 600.0, 0.0)).clamp(0.0, 1.0);
let downfall = biome.downfall().clamp(0.0, 1.0) * temp; let downfall = biome.downfall().clamp(0.0, 1.0) * temp;
@ -28,27 +26,27 @@ fn color_from_params(colors: &[Vec3; 3], biome: &Biome, depth: f32) -> Vec3 {
/// Extension trait with helpers for computing biome-specific block colors /// Extension trait with helpers for computing biome-specific block colors
trait BiomeExt { trait BiomeExt {
/// Returns the grass color of the biome at a given depth /// Returns the grass color of the biome at a given depth
fn grass_color(&self, depth: f32) -> Vec3; fn grass_color(&self, depth: f32) -> Colorf;
/// Returns the foliage color of the biome at a given depth /// Returns the foliage color of the biome at a given depth
fn foliage_color(&self, depth: f32) -> Vec3; fn foliage_color(&self, depth: f32) -> Colorf;
/// Returns the water color of the biome /// Returns the water color of the biome
fn water_color(&self) -> Vec3; fn water_color(&self) -> Colorf;
} }
impl BiomeExt for Biome { impl BiomeExt for Biome {
fn grass_color(&self, depth: f32) -> Vec3 { fn grass_color(&self, depth: f32) -> Colorf {
use super::BiomeGrassColorModifier::*; use super::BiomeGrassColorModifier::*;
/// Color matrix extracted from grass color texture /// Color matrix extracted from grass color texture
const GRASS_COLORS: [Vec3; 3] = [ const GRASS_COLORS: [Colorf; 3] = [
Vec3::new(0.502, 0.706, 0.592), // lower right Colorf::new(0.502, 0.706, 0.592), // lower right
Vec3::new(0.247, 0.012, -0.259), // lower left - lower right Colorf::new(0.247, 0.012, -0.259), // lower left - lower right
Vec3::new(-0.471, 0.086, -0.133), // upper left - lower left Colorf::new(-0.471, 0.086, -0.133), // upper left - lower left
]; ];
/// Used for dark forst grass color modifier /// Used for dark forst grass color modifier
const DARK_FOREST_GRASS_COLOR: Vec3 = Vec3::new(0.157, 0.204, 0.039); // == color_vec(Color([40, 52, 10])) const DARK_FOREST_GRASS_COLOR: Colorf = Colorf::new(0.157, 0.204, 0.039); // == color_vec(Color([40, 52, 10]))
/// Grass color in swamp biomes /// Grass color in swamp biomes
const SWAMP_GRASS_COLOR: Vec3 = Vec3::new(0.416, 0.439, 0.224); // == color_vec(Color([106, 112, 57])) const SWAMP_GRASS_COLOR: Colorf = Colorf::new(0.416, 0.439, 0.224); // == color_vec(Color([106, 112, 57]))
let regular_color = || { let regular_color = || {
self.grass_color self.grass_color
@ -63,12 +61,12 @@ impl BiomeExt for Biome {
} }
} }
fn foliage_color(&self, depth: f32) -> Vec3 { fn foliage_color(&self, depth: f32) -> Colorf {
/// Color matrix extracted from foliage color texture /// Color matrix extracted from foliage color texture
const FOLIAGE_COLORS: [Vec3; 3] = [ const FOLIAGE_COLORS: [Colorf; 3] = [
Vec3::new(0.376, 0.631, 0.482), // lower right Colorf::new(0.376, 0.631, 0.482), // lower right
Vec3::new(0.306, 0.012, -0.317), // lower left - lower right Colorf::new(0.306, 0.012, -0.317), // lower left - lower right
Vec3::new(-0.580, 0.106, -0.165), // upper left - lower left Colorf::new(-0.580, 0.106, -0.165), // upper left - lower left
]; ];
self.foliage_color self.foliage_color
@ -76,11 +74,11 @@ impl BiomeExt for Biome {
.unwrap_or_else(|| color_from_params(&FOLIAGE_COLORS, self, depth)) .unwrap_or_else(|| color_from_params(&FOLIAGE_COLORS, self, depth))
} }
fn water_color(&self) -> Vec3 { fn water_color(&self) -> Colorf {
/// Default biome water color /// Default biome water color
/// ///
/// Used for biomes that don't explicitly set a water color /// Used for biomes that don't explicitly set a water color
const DEFAULT_WATER_COLOR: Vec3 = Vec3::new(0.247, 0.463, 0.894); // == color_vec(Color([63, 118, 228])) const DEFAULT_WATER_COLOR: Colorf = Colorf::new(0.247, 0.463, 0.894); // == color_vec(Color([63, 118, 228]))
self.water_color self.water_color
.map(color_vec) .map(color_vec)
@ -89,9 +87,9 @@ impl BiomeExt for Biome {
} }
/// Color multiplier for birch leaves /// Color multiplier for birch leaves
const BIRCH_COLOR: Vec3 = Vec3::new(0.502, 0.655, 0.333); // == color_vec(Color([128, 167, 85])) const BIRCH_COLOR: Colorf = Colorf::new(0.502, 0.655, 0.333); // == color_vec(Color([128, 167, 85]))
/// Color multiplier for spruce leaves /// Color multiplier for spruce leaves
const EVERGREEN_COLOR: Vec3 = Vec3::new(0.380, 0.600, 0.380); // == color_vec(Color([97, 153, 97])) const EVERGREEN_COLOR: Colorf = Colorf::new(0.380, 0.600, 0.380); // == color_vec(Color([97, 153, 97]))
/// Determined if calling [block_color] for a given [BlockType] needs biome information /// Determined if calling [block_color] for a given [BlockType] needs biome information
pub fn needs_biome(block: BlockType) -> bool { pub fn needs_biome(block: BlockType) -> bool {
@ -104,7 +102,7 @@ pub fn needs_biome(block: BlockType) -> bool {
/// ///
/// [needs_biome] must be used to determine whether passing a [Biome] is necessary. /// [needs_biome] must be used to determine whether passing a [Biome] is necessary.
/// Will panic if a [Biome] is necessary, but none is passed. /// Will panic if a [Biome] is necessary, but none is passed.
pub fn block_color(block: BlockType, biome: Option<&Biome>, depth: f32) -> Vec3 { pub fn block_color(block: BlockType, biome: Option<&Biome>, depth: f32) -> Colorf {
use super::BlockFlag::*; use super::BlockFlag::*;
let get_biome = || biome.expect("needs biome to determine block color"); let get_biome = || biome.expect("needs biome to determine block color");

View file

@ -33,10 +33,13 @@ pub enum BlockFlag {
Water, Water,
} }
/// An RGB color /// An RGB color with u8 components
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Color(pub [u8; 3]); pub struct Color(pub [u8; 3]);
/// An RGB color with f32 components
pub type Colorf = glam::Vec3;
/// A block type specification /// A block type specification
#[derive(Debug, Clone, Copy, Serialize, Deserialize)] #[derive(Debug, Clone, Copy, Serialize, Deserialize)]
pub struct BlockType { pub struct BlockType {

View file

@ -11,10 +11,16 @@ use serde::{Deserialize, Serialize};
use crate::{io::fs::FileMetaVersion, resource::Biome, types::*, world::layer}; use crate::{io::fs::FileMetaVersion, resource::Biome, types::*, world::layer};
/// MinedMap data version number
///
/// Increase to force regeneration of all output files /// Increase to force regeneration of all output files
pub const FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
/// MinedMap processed region data version number
pub const REGION_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
/// MinedMap map tile data version number
pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
/// MinedMap lightmap data version number
pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
/// Coordinate pair of a generated tile /// Coordinate pair of a generated tile
/// ///
@ -53,7 +59,7 @@ impl TileCoordMap {
} }
/// Data structure for storing chunk data between processing and rendering steps /// Data structure for storing chunk data between processing and rendering steps
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct ProcessedChunk { pub struct ProcessedChunk {
/// Block type data /// Block type data
pub blocks: Box<layer::BlockArray>, pub blocks: Box<layer::BlockArray>,
@ -64,7 +70,7 @@ pub struct ProcessedChunk {
} }
/// Data structure for storing region data between processing and rendering steps /// Data structure for storing region data between processing and rendering steps
#[derive(Debug, Clone, Default, Serialize, Deserialize)] #[derive(Debug, Default, Serialize, Deserialize)]
pub struct ProcessedRegion { pub struct ProcessedRegion {
/// List of biomes used in the region /// List of biomes used in the region
/// ///

View file

@ -1,21 +1,17 @@
//! The [RegionProcessor] and related functions //! The [RegionProcessor] and related functions
use std::{ffi::OsStr, path::Path, sync::mpsc, time::SystemTime}; use std::{ffi::OsStr, path::PathBuf, sync::mpsc, time::SystemTime};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use indexmap::IndexSet;
use rayon::prelude::*; use rayon::prelude::*;
use tracing::{debug, info, warn}; use tracing::{debug, info, warn};
use super::common::*; use super::common::*;
use crate::{ use crate::{
io::{fs, storage}, io::{fs, storage},
resource::{self, Biome}, resource,
types::*, types::*,
world::{ world::{self, layer},
self,
layer::{self, LayerData},
},
}; };
/// Parses a filename in the format r.X.Z.mca into the contained X and Z values /// Parses a filename in the format r.X.Z.mca into the contained X and Z values
@ -44,6 +40,201 @@ enum RegionProcessorStatus {
ErrorMissing, ErrorMissing,
} }
/// Handles processing for a single region
struct SingleRegionProcessor<'a> {
/// Registry of known block types
block_types: &'a resource::BlockTypes,
/// Registry of known biome types
biome_types: &'a resource::BiomeTypes,
/// Coordinates of the region this instance is processing
coords: TileCoords,
/// Input region filename
input_path: PathBuf,
/// Processed region data output filename
output_path: PathBuf,
/// Lightmap output filename
lightmap_path: PathBuf,
/// Timestamp of last modification of input file
input_timestamp: SystemTime,
/// Timestamp of last modification of processed region output file (if valid)
output_timestamp: Option<SystemTime>,
/// Timestamp of last modification of lightmap output file (if valid)
lightmap_timestamp: Option<SystemTime>,
/// True if processed region output file needs to be updated
output_needed: bool,
/// True if lightmap output file needs to be updated
lightmap_needed: bool,
/// Processed region intermediate data
processed_region: ProcessedRegion,
/// Lightmap intermediate data
lightmap: image::GrayAlphaImage,
}
impl<'a> SingleRegionProcessor<'a> {
/// Initializes a [SingleRegionProcessor]
fn new(processor: &'a RegionProcessor<'a>, coords: TileCoords) -> Result<Self> {
/// 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)?;
let output_path = processor.config.processed_path(coords);
let output_timestamp = fs::read_timestamp(&output_path, REGION_FILE_META_VERSION);
let lightmap_path = processor.config.tile_path(TileKind::Lightmap, 0, coords);
let lightmap_timestamp = fs::read_timestamp(&lightmap_path, LIGHTMAP_FILE_META_VERSION);
let output_needed = Some(input_timestamp) > output_timestamp;
let lightmap_needed = Some(input_timestamp) > lightmap_timestamp;
let processed_region = ProcessedRegion::default();
let lightmap = image::GrayAlphaImage::new(N, N);
Ok(SingleRegionProcessor {
block_types: &processor.block_types,
biome_types: &processor.biome_types,
coords,
input_path,
output_path,
lightmap_path,
input_timestamp,
output_timestamp,
lightmap_timestamp,
output_needed,
lightmap_needed,
processed_region,
lightmap,
})
}
/// Renders a lightmap subtile from chunk block light data
fn render_chunk_lightmap(
block_light: Box<world::layer::BlockLightArray>,
) -> image::GrayAlphaImage {
/// Width/height of generated chunk lightmap
const N: u32 = BLOCKS_PER_CHUNK as u32;
image::GrayAlphaImage::from_fn(N, N, |x, z| {
let v: f32 = block_light[LayerBlockCoords {
x: BlockX::new(x),
z: BlockZ::new(z),
}]
.into();
image::LumaA([0, (192.0 * (1.0 - v / 15.0)) as u8])
})
}
/// Saves processed region data
///
/// The timestamp is the time of the last modification of the input region data.
fn save_region(&self) -> Result<()> {
if !self.output_needed {
return Ok(());
}
storage::write(
&self.output_path,
&self.processed_region,
REGION_FILE_META_VERSION,
self.input_timestamp,
)
}
/// Saves a lightmap tile
///
/// The timestamp is the time of the last modification of the input region data.
fn save_lightmap(&self) -> Result<()> {
if !self.lightmap_needed {
return Ok(());
}
fs::create_with_timestamp(
&self.lightmap_path,
LIGHTMAP_FILE_META_VERSION,
self.input_timestamp,
|file| {
self.lightmap
.write_to(file, image::ImageFormat::Png)
.context("Failed to save image")
},
)
}
/// Processes a single chunk
fn process_chunk(&mut self, chunk_coords: ChunkCoords, data: world::de::Chunk) -> Result<()> {
let chunk = world::chunk::Chunk::new(&data, self.block_types, self.biome_types)
.with_context(|| format!("Failed to decode chunk {:?}", chunk_coords))?;
let Some(layer::LayerData {
blocks,
biomes,
block_light,
depths,
}) = world::layer::top_layer(&mut self.processed_region.biome_list, &chunk)
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
else {
return Ok(());
};
if self.output_needed {
self.processed_region.chunks[chunk_coords] = Some(Box::new(ProcessedChunk {
blocks,
biomes,
depths,
}));
}
if self.lightmap_needed {
let chunk_lightmap = Self::render_chunk_lightmap(block_light);
overlay_chunk(&mut self.lightmap, &chunk_lightmap, chunk_coords);
}
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))
}
/// Processes the region
fn run(mut self) -> Result<RegionProcessorStatus> {
if !self.output_needed && !self.lightmap_needed {
debug!(
"Skipping unchanged region r.{}.{}.mca",
self.coords.x, self.coords.z
);
return Ok(RegionProcessorStatus::Skipped);
}
debug!(
"Processing region r.{}.{}.mca",
self.coords.x, self.coords.z
);
if let Err(err) = self.process_chunks() {
if self.output_timestamp.is_some() && self.lightmap_timestamp.is_some() {
warn!(
"Failed to process region {:?}, using old data: {:?}",
self.coords, err
);
return Ok(RegionProcessorStatus::ErrorOk);
} else {
warn!(
"Failed to process region {:?}, no old data available: {:?}",
self.coords, err
);
return Ok(RegionProcessorStatus::ErrorMissing);
}
}
self.save_region()?;
self.save_lightmap()?;
Ok(RegionProcessorStatus::Ok)
}
}
/// Type with methods for processing the regions of a Minecraft save directory /// Type with methods for processing the regions of a Minecraft save directory
/// ///
/// The RegionProcessor builds lightmap tiles as well as processed region data /// The RegionProcessor builds lightmap tiles as well as processed region data
@ -91,133 +282,9 @@ impl<'a> RegionProcessor<'a> {
.collect()) .collect())
} }
/// Processes a single chunk
fn process_chunk(
&self,
biome_list: &mut IndexSet<Biome>,
data: world::de::Chunk,
) -> Result<Option<LayerData>> {
let chunk = world::chunk::Chunk::new(&data, &self.block_types, &self.biome_types)?;
world::layer::top_layer(biome_list, &chunk)
}
/// Renders a lightmap subtile from chunk block light data
fn render_chunk_lightmap(
block_light: Box<world::layer::BlockLightArray>,
) -> image::GrayAlphaImage {
/// Width/height of generated chunk lightmap
const N: u32 = BLOCKS_PER_CHUNK as u32;
image::GrayAlphaImage::from_fn(N, N, |x, z| {
let v: f32 = block_light[LayerBlockCoords {
x: BlockX::new(x),
z: BlockZ::new(z),
}]
.into();
image::LumaA([0, (192.0 * (1.0 - v / 15.0)) as u8])
})
}
/// Saves processed region data
///
/// The timestamp is the time of the last modification of the input region data.
fn save_region(
path: &Path,
processed_region: &ProcessedRegion,
timestamp: SystemTime,
) -> Result<()> {
storage::write(path, processed_region, FILE_META_VERSION, timestamp)
}
/// Saves a lightmap tile
///
/// The timestamp is the time of the last modification of the input region data.
fn save_lightmap(
path: &Path,
lightmap: &image::GrayAlphaImage,
timestamp: SystemTime,
) -> Result<()> {
fs::create_with_timestamp(path, FILE_META_VERSION, timestamp, |file| {
lightmap
.write_to(file, image::ImageFormat::Png)
.context("Failed to save image")
})
}
/// Processes a single region file /// Processes a single region file
fn process_region(&self, coords: TileCoords) -> Result<RegionProcessorStatus> { fn process_region(&self, coords: TileCoords) -> Result<RegionProcessorStatus> {
/// Width/height of the region data SingleRegionProcessor::new(self, coords)?.run()
const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32;
let mut processed_region = ProcessedRegion::default();
let mut lightmap = image::GrayAlphaImage::new(N, N);
let input_path = self.config.region_path(coords);
let input_timestamp = fs::modified_timestamp(&input_path)?;
let output_path = self.config.processed_path(coords);
let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION);
let lightmap_path = self.config.tile_path(TileKind::Lightmap, 0, coords);
let lightmap_timestamp = fs::read_timestamp(&lightmap_path, FILE_META_VERSION);
if Some(input_timestamp) <= output_timestamp && Some(input_timestamp) <= lightmap_timestamp
{
debug!("Skipping unchanged region r.{}.{}.mca", coords.x, coords.z);
return Ok(RegionProcessorStatus::Skipped);
}
debug!("Processing region r.{}.{}.mca", coords.x, coords.z);
if let Err(err) = (|| -> Result<()> {
crate::nbt::region::from_file(input_path)?.foreach_chunk(
|chunk_coords, data: world::de::Chunk| {
let Some(layer::LayerData {
blocks,
biomes,
block_light,
depths,
}) = self
.process_chunk(&mut processed_region.biome_list, data)
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
else {
return Ok(());
};
processed_region.chunks[chunk_coords] = Some(Box::new(ProcessedChunk {
blocks,
biomes,
depths,
}));
let chunk_lightmap = Self::render_chunk_lightmap(block_light);
overlay_chunk(&mut lightmap, &chunk_lightmap, chunk_coords);
Ok(())
},
)
})() {
if output_timestamp.is_some() && lightmap_timestamp.is_some() {
warn!(
"Failed to process region {:?}, using old data: {:?}",
coords, err
);
return Ok(RegionProcessorStatus::ErrorOk);
} else {
warn!(
"Failed to process region {:?}, no old data available: {:?}",
coords, err
);
return Ok(RegionProcessorStatus::ErrorMissing);
}
}
if Some(input_timestamp) > output_timestamp {
Self::save_region(&output_path, &processed_region, input_timestamp)?;
}
if Some(input_timestamp) > lightmap_timestamp {
Self::save_lightmap(&lightmap_path, &lightmap, input_timestamp)?;
}
Ok(RegionProcessorStatus::Ok)
} }
/// Iterates over all region files of a Minecraft save directory /// Iterates over all region files of a Minecraft save directory

View file

@ -70,8 +70,12 @@ impl<'a> TileMipmapper<'a> {
/// Tile width/height /// Tile width/height
const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32; const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32;
let version = match kind {
TileKind::Map => REGION_FILE_META_VERSION,
TileKind::Lightmap => LIGHTMAP_FILE_META_VERSION,
};
let output_path = self.config.tile_path(kind, level, coords); let output_path = self.config.tile_path(kind, level, coords);
let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION); let output_timestamp = fs::read_timestamp(&output_path, version);
let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)] let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)]
.into_iter() .into_iter()
@ -145,7 +149,7 @@ impl<'a> TileMipmapper<'a> {
); );
} }
fs::create_with_timestamp(&output_path, FILE_META_VERSION, input_timestamp, |file| { fs::create_with_timestamp(&output_path, version, input_timestamp, |file| {
image image
.write_to(file, image::ImageFormat::Png) .write_to(file, image::ImageFormat::Png)
.context("Failed to save image") .context("Failed to save image")

View file

@ -8,7 +8,6 @@ use std::{
}; };
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use glam::Vec3;
use lru::LruCache; use lru::LruCache;
use rayon::prelude::*; use rayon::prelude::*;
use tokio::sync::OnceCell; use tokio::sync::OnceCell;
@ -17,7 +16,7 @@ use tracing::{debug, info};
use super::{common::*, region_group::RegionGroup}; use super::{common::*, region_group::RegionGroup};
use crate::{ use crate::{
io::{fs, storage}, io::{fs, storage},
resource::{block_color, needs_biome}, resource::{block_color, needs_biome, Colorf},
types::*, types::*,
util::coord_offset, util::coord_offset,
}; };
@ -128,7 +127,7 @@ impl<'a> TileRenderer<'a> {
chunk: &ProcessedChunk, chunk: &ProcessedChunk,
chunk_coords: ChunkCoords, chunk_coords: ChunkCoords,
block_coords: LayerBlockCoords, block_coords: LayerBlockCoords,
) -> Option<Vec3> { ) -> Option<Colorf> {
/// Helper for keys in the weight table /// Helper for keys in the weight table
/// ///
/// Hashing the value as a single u32 is more efficient than hashing /// Hashing the value as a single u32 is more efficient than hashing
@ -182,7 +181,7 @@ impl<'a> TileRenderer<'a> {
return None; return None;
} }
let mut color = Vec3::ZERO; let mut color = Colorf::ZERO;
let mut total = 0.0; let mut total = 0.0;
for ((region_x, region_z, index), w) in weights.into_values() { for ((region_x, region_z, index), w) in weights.into_values() {
@ -270,7 +269,7 @@ impl<'a> TileRenderer<'a> {
let (processed_paths, processed_timestamp) = self.processed_sources(coords)?; let (processed_paths, processed_timestamp) = self.processed_sources(coords)?;
let output_path = self.config.tile_path(TileKind::Map, 0, coords); let output_path = self.config.tile_path(TileKind::Map, 0, coords);
let output_timestamp = fs::read_timestamp(&output_path, FILE_META_VERSION); let output_timestamp = fs::read_timestamp(&output_path, MAP_FILE_META_VERSION);
if Some(processed_timestamp) <= output_timestamp { if Some(processed_timestamp) <= output_timestamp {
debug!( debug!(
@ -300,7 +299,7 @@ impl<'a> TileRenderer<'a> {
fs::create_with_timestamp( fs::create_with_timestamp(
&output_path, &output_path,
FILE_META_VERSION, MAP_FILE_META_VERSION,
processed_timestamp, processed_timestamp,
|file| { |file| {
image image

View file

@ -93,10 +93,10 @@ impl<'a> Chunk<'a> {
let data_version = data.data_version.unwrap_or_default(); let data_version = data.data_version.unwrap_or_default();
match &data.chunk { match &data.chunk {
de::ChunkVariants::V1_18 { sections } => { de::ChunkVariant::V1_18 { sections } => {
Self::new_v1_18(data_version, sections, block_types, biome_types) Self::new_v1_18(data_version, sections, block_types, biome_types)
} }
de::ChunkVariants::V0 { level } => { de::ChunkVariant::V0 { level } => {
Self::new_v0(data_version, level, block_types, biome_types) Self::new_v0(data_version, level, block_types, biome_types)
} }
} }
@ -113,7 +113,7 @@ impl<'a> Chunk<'a> {
for section in sections { for section in sections {
match &section.section { match &section.section {
de::SectionV1_18Variants::V1_18 { de::SectionV1_18Variant::V1_18 {
block_states, block_states,
biomes, biomes,
block_light, block_light,
@ -140,7 +140,7 @@ impl<'a> Chunk<'a> {
), ),
); );
} }
de::SectionV1_18Variants::Empty {} => {} de::SectionV1_18Variant::Empty {} => {}
}; };
} }
@ -163,7 +163,7 @@ impl<'a> Chunk<'a> {
format!("Failed to load section block light at Y={}", section.y) format!("Failed to load section block light at Y={}", section.y)
})?; })?;
match &section.section { match &section.section {
de::SectionV0Variants::V1_13 { de::SectionV0Variant::V1_13 {
block_states, block_states,
palette, palette,
} => { } => {
@ -183,7 +183,7 @@ impl<'a> Chunk<'a> {
), ),
); );
} }
de::SectionV0Variants::V0 { blocks, data } => { de::SectionV0Variant::V0 { blocks, data } => {
section_map_v0.insert( section_map_v0.insert(
SectionY(section.y.into()), SectionY(section.y.into()),
( (
@ -194,7 +194,7 @@ impl<'a> Chunk<'a> {
), ),
); );
} }
de::SectionV0Variants::Empty {} => {} de::SectionV0Variant::Empty {} => {}
} }
} }

View file

@ -31,7 +31,7 @@ pub struct BiomesV1_18 {
/// Variable part of a [SectionV1_18] /// Variable part of a [SectionV1_18]
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum SectionV1_18Variants { pub enum SectionV1_18Variant {
/// Populated 1.18+ section /// Populated 1.18+ section
V1_18 { V1_18 {
/// Block type data /// Block type data
@ -54,13 +54,13 @@ pub struct SectionV1_18 {
pub y: i32, pub y: i32,
/// Variable part of section /// Variable part of section
#[serde(flatten)] #[serde(flatten)]
pub section: SectionV1_18Variants, pub section: SectionV1_18Variant,
} }
/// Version-specific part of a pre-1.18 [Section](SectionV0) /// Version-specific part of a pre-1.18 [Section](SectionV0)
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum SectionV0Variants { pub enum SectionV0Variant {
/// v1.13+ data /// v1.13+ data
#[serde(rename_all = "PascalCase")] #[serde(rename_all = "PascalCase")]
V1_13 { V1_13 {
@ -91,7 +91,7 @@ pub struct SectionV0 {
pub block_light: Option<fastnbt::ByteArray>, pub block_light: Option<fastnbt::ByteArray>,
/// Version-specific data /// Version-specific data
#[serde(flatten)] #[serde(flatten)]
pub section: SectionV0Variants, pub section: SectionV0Variant,
} }
/// Pre-1.18 biome fields found in the [Level](LevelV0) compound /// Pre-1.18 biome fields found in the [Level](LevelV0) compound
@ -118,7 +118,7 @@ pub struct LevelV0 {
/// Version-specific part of a [Chunk] compound /// Version-specific part of a [Chunk] compound
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum ChunkVariants { pub enum ChunkVariant {
/// 1.18+ chunk data /// 1.18+ chunk data
V1_18 { V1_18 {
/// List of chunk sections /// List of chunk sections
@ -140,7 +140,7 @@ pub struct Chunk {
pub data_version: Option<u32>, pub data_version: Option<u32>,
/// Version-specific chunk data /// Version-specific chunk data
#[serde(flatten)] #[serde(flatten)]
pub chunk: ChunkVariants, pub chunk: ChunkVariant,
} }
/// `Data` compound element of level.dat /// `Data` compound element of level.dat