fix: some bugs

This commit is contained in:
Alexander Medvedev
2026-04-03 18:35:34 +02:00
parent 8a6698cd21
commit 0656aec158
45 changed files with 2866 additions and 642 deletions

190
Cargo.lock generated
View File

@@ -357,9 +357,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
version = "1.2.58"
version = "1.2.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1e928d4b69e3077709075a938a05ffbedfa53a84c8f766efbf8220bb1ff60e1"
checksum = "b7a4d3ec6524d28a329fc53654bbadc9bdd7b0431f5d65f1a56ffb28a1ee5283"
dependencies = [
"find-msvc-tools",
"jobserver",
@@ -491,9 +491,9 @@ dependencies = [
[[package]]
name = "cmov"
version = "0.5.2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de0758edba32d61d1fd9f4d69491b47604b91ee2f7e6b33de7e54ca4ebe55dc3"
checksum = "3f88a43d011fc4a6876cb7344703e297c71dda42494fee094d5f7c76bf13f746"
[[package]]
name = "cobs"
@@ -982,9 +982,9 @@ dependencies = [
[[package]]
name = "ctutils"
version = "0.4.0"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1005a6d4446f5120ef475ad3d2af2b30c49c2c9c6904258e3bb30219bebed5e4"
checksum = "7d5515a3834141de9eafb9717ad39eea8247b5674e6066c404e8c4b365d2a29e"
dependencies = [
"cmov",
]
@@ -1663,18 +1663,18 @@ checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
[[package]]
name = "hybrid-array"
version = "0.4.8"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8655f91cd07f2b9d0c24137bd650fe69617773435ee5ec83022377777ce65ef1"
checksum = "3944cf8cf766b40e2a1a333ee5e9b563f854d5fa49d6a8ca2764e97c6eddb214"
dependencies = [
"typenum",
]
[[package]]
name = "hyper"
version = "1.8.1"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ab2d4f250c3d7b1c9fcdff1cece94ea4e2dfbec68614f7b87cb205f24ca9d11"
checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca"
dependencies = [
"atomic-waker",
"bytes",
@@ -1687,7 +1687,6 @@ dependencies = [
"httpdate",
"itoa",
"pin-project-lite",
"pin-utils",
"smallvec",
"tokio",
"want",
@@ -1752,12 +1751,13 @@ dependencies = [
[[package]]
name = "icu_collections"
version = "2.1.1"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6b649701667bbe825c3b7e6388cb521c23d88644678e83c0c4d0a621a34b43"
checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c"
dependencies = [
"displaydoc",
"potential_utf",
"utf8_iter",
"yoke",
"zerofrom",
"zerovec",
@@ -1765,9 +1765,9 @@ dependencies = [
[[package]]
name = "icu_locale_core"
version = "2.1.1"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "edba7861004dd3714265b4db54a3c390e880ab658fec5f7db895fae2046b5bb6"
checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29"
dependencies = [
"displaydoc",
"litemap",
@@ -1778,9 +1778,9 @@ dependencies = [
[[package]]
name = "icu_normalizer"
version = "2.1.1"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f6c8828b67bf8908d82127b2054ea1b4427ff0230ee9141c54251934ab1b599"
checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4"
dependencies = [
"icu_collections",
"icu_normalizer_data",
@@ -1792,15 +1792,15 @@ dependencies = [
[[package]]
name = "icu_normalizer_data"
version = "2.1.1"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a"
checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38"
[[package]]
name = "icu_properties"
version = "2.1.2"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec"
checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de"
dependencies = [
"icu_collections",
"icu_locale_core",
@@ -1812,15 +1812,15 @@ dependencies = [
[[package]]
name = "icu_properties_data"
version = "2.1.2"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af"
checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14"
[[package]]
name = "icu_provider"
version = "2.1.1"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85962cf0ce02e1e0a629cc34e7ca3e373ce20dda4c4d7294bbd0bf1fdb59e614"
checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421"
dependencies = [
"displaydoc",
"icu_locale_core",
@@ -1874,9 +1874,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.13.0"
version = "2.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
checksum = "45a8a2b9cb3e0b0c1803dbb0758ffac5de2f425b23c28f518faabd9d805342ff"
dependencies = [
"equivalent",
"hashbrown 0.16.1",
@@ -1971,9 +1971,9 @@ dependencies = [
[[package]]
name = "js-sys"
version = "0.3.92"
version = "0.3.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc4c90f45aa2e6eacbe8645f77fdea542ac97a494bcd117a67df9ff4d611f995"
checksum = "2e04e2ef80ce82e13552136fabeef8a5ed1f985a96805761cbb9a2c34e7664d9"
dependencies = [
"once_cell",
"wasm-bindgen",
@@ -1999,9 +1999,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
[[package]]
name = "libc"
version = "0.2.183"
version = "0.2.184"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
checksum = "48f5d2a454e16a5ea0f4ced81bd44e4cfc7bd3a507b61887c99fd3538b28e4af"
[[package]]
name = "libloading"
@@ -2042,9 +2042,9 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "litemap"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6373607a59f0be73a39b6fe456b8192fcc3585f602af20751600e974dd455e77"
checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0"
[[package]]
name = "litrs"
@@ -2487,12 +2487,6 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkcs1"
version = "0.8.0-rc.4"
@@ -2565,9 +2559,9 @@ dependencies = [
[[package]]
name = "potential_utf"
version = "0.1.4"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b73949432f5e2a09657003c25bca5e19a0e9c84f8058ca374f49e0ebe605af77"
checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564"
dependencies = [
"zerovec",
]
@@ -2766,7 +2760,7 @@ version = "0.1.0-dev+26.1"
dependencies = [
"pumpkin-util",
"serde",
"toml 1.1.0+spec-1.1.0",
"toml 1.1.2+spec-1.1.0",
"tracing",
"uuid",
]
@@ -3354,9 +3348,9 @@ dependencies = [
[[package]]
name = "serde_spanned"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "876ac351060d4f882bb1032b6369eb0aef79ad9df1ea8bc404874d8cc3d0cd98"
checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26"
dependencies = [
"serde_core",
]
@@ -3737,9 +3731,9 @@ dependencies = [
[[package]]
name = "tinystr"
version = "0.8.2"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42d3e9c45c09de15d06dd8acf5f4e0e399e85927b7f00711024eb7ae10fa4869"
checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d"
dependencies = [
"displaydoc",
"zerovec",
@@ -3757,9 +3751,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.50.0"
version = "1.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d"
checksum = "2bd1c4c0fc4a7ab90fc15ef6daaa3ec3b893f004f915f2392557ed23237820cd"
dependencies = [
"bytes",
"libc",
@@ -3774,9 +3768,9 @@ dependencies = [
[[package]]
name = "tokio-macros"
version = "2.6.1"
version = "2.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c"
checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496"
dependencies = [
"proc-macro2",
"quote",
@@ -3825,17 +3819,17 @@ dependencies = [
[[package]]
name = "toml"
version = "1.1.0+spec-1.1.0"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8195ca05e4eb728f4ba94f3e3291661320af739c4e43779cbdfae82ab239fcc"
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
dependencies = [
"indexmap",
"serde_core",
"serde_spanned",
"toml_datetime 1.1.0+spec-1.1.0",
"toml_datetime 1.1.1+spec-1.1.0",
"toml_parser",
"toml_writer",
"winnow 1.0.0",
"winnow 1.0.1",
]
[[package]]
@@ -3849,27 +3843,27 @@ dependencies = [
[[package]]
name = "toml_datetime"
version = "1.1.0+spec-1.1.0"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97251a7c317e03ad83774a8752a7e81fb6067740609f75ea2b585b569a59198f"
checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
dependencies = [
"serde_core",
]
[[package]]
name = "toml_parser"
version = "1.1.0+spec-1.1.0"
version = "1.1.2+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2334f11ee363607eb04df9b8fc8a13ca1715a72ba8662a26ac285c98aabb4011"
checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526"
dependencies = [
"winnow 1.0.0",
"winnow 1.0.1",
]
[[package]]
name = "toml_writer"
version = "1.1.0+spec-1.1.0"
version = "1.1.1+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d282ade6016312faf3e41e57ebbba0c073e4056dab1232ab1cb624199648f8ed"
checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db"
[[package]]
name = "tonic"
@@ -4219,9 +4213,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen"
version = "0.2.115"
version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6523d69017b7633e396a89c5efab138161ed5aafcbc8d3e5c5a42ae38f50495a"
checksum = "0551fc1bb415591e3372d0bc4780db7e587d84e2a7e79da121051c5c4b89d0b0"
dependencies = [
"cfg-if",
"once_cell",
@@ -4232,9 +4226,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.115"
version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e3a6c758eb2f701ed3d052ff5737f5bfe6614326ea7f3bbac7156192dc32e67"
checksum = "7fbdf9a35adf44786aecd5ff89b4563a90325f9da0923236f6104e603c7e86be"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@@ -4242,9 +4236,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.115"
version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "921de2737904886b52bcbb237301552d05969a6f9c40d261eb0533c8b055fedf"
checksum = "dca9693ef2bab6d4e6707234500350d8dad079eb508dca05530c85dc3a529ff2"
dependencies = [
"bumpalo",
"proc-macro2",
@@ -4255,9 +4249,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.115"
version = "0.2.117"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a93e946af942b58934c604527337bad9ae33ba1d5c6900bbb41c2c07c2364a93"
checksum = "39129a682a6d2d841b6c429d0c51e5cb0ed1a03829d8b3d1e69a011e62cb3d3b"
dependencies = [
"unicode-ident",
]
@@ -4303,6 +4297,16 @@ dependencies = [
"wasmparser 0.245.1",
]
[[package]]
name = "wasm-encoder"
version = "0.246.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e1929aad146499e47362c876fcbcbb0363f730951d93438f511178626e999a8"
dependencies = [
"leb128fmt",
"wasmparser 0.246.1",
]
[[package]]
name = "wasm-metadata"
version = "0.244.0"
@@ -4687,24 +4691,24 @@ dependencies = [
[[package]]
name = "wast"
version = "245.0.1"
version = "246.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28cf1149285569120b8ce39db8b465e8a2b55c34cbb586bd977e43e2bc7300bf"
checksum = "96cf2d50bc7478dcca61d00df4dadf922ef46c5924db20a97e6daaf09fe1cb09"
dependencies = [
"bumpalo",
"leb128fmt",
"memchr",
"unicode-width",
"wasm-encoder 0.245.1",
"wasm-encoder 0.246.1",
]
[[package]]
name = "wat"
version = "1.245.1"
version = "1.246.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd48d1679b6858988cb96b154dda0ec5bbb09275b71db46057be37332d5477be"
checksum = "723f2473b47f738c12fc11c8e0bb8b27ce7cf9c78cf1a29dadbc2d34a2513292"
dependencies = [
"wast 245.0.1",
"wast 246.0.1",
]
[[package]]
@@ -4964,9 +4968,9 @@ checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"
[[package]]
name = "winnow"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a90e88e4667264a994d34e6d1ab2d26d398dcdca8b7f52bec8668957517fc7d8"
checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5"
[[package]]
name = "winx"
@@ -5170,15 +5174,15 @@ dependencies = [
[[package]]
name = "writeable"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9edde0db4769d2dc68579893f2306b26c6ecfbe0ef499b013d731b7b9247e0b9"
checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4"
[[package]]
name = "yoke"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72d6e5c6afb84d73944e5cedb052c4680d5657337201555f9f2a16b7406d4954"
checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca"
dependencies = [
"stable_deref_trait",
"yoke-derive",
@@ -5187,9 +5191,9 @@ dependencies = [
[[package]]
name = "yoke-derive"
version = "0.8.1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d"
checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e"
dependencies = [
"proc-macro2",
"quote",
@@ -5219,18 +5223,18 @@ dependencies = [
[[package]]
name = "zerofrom"
version = "0.1.6"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5"
checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.6"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1"
dependencies = [
"proc-macro2",
"quote",
@@ -5246,9 +5250,9 @@ checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
[[package]]
name = "zerotrie"
version = "0.2.3"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a59c17a5562d507e4b54960e8569ebee33bee890c70aa3fe7b97e85a9fd7851"
checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf"
dependencies = [
"displaydoc",
"yoke",
@@ -5257,9 +5261,9 @@ dependencies = [
[[package]]
name = "zerovec"
version = "0.11.5"
version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c28719294829477f525be0186d13efa9a3c602f7ec202ca9e353d310fb9a002"
checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239"
dependencies = [
"yoke",
"zerofrom",
@@ -5268,9 +5272,9 @@ dependencies = [
[[package]]
name = "zerovec-derive"
version = "0.11.2"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3"
checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555"
dependencies = [
"proc-macro2",
"quote",

View File

@@ -90,7 +90,7 @@ debug = true
strip = false
[workspace.dependencies]
tokio = { version = "1.50", default-features = false }
tokio = { version = "1.51", default-features = false }
syn = { version = "2.0", default-features = false, features = ["printing"] }

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
{}
{"byte":0,"int":1,"long":2,"float":3,"string":4,"component":5,"optional_component":6,"item_stack":7,"block_state":14,"optional_block_state":15,"boolean":8,"particle":16,"particles":17,"rotations":9,"block_pos":10,"optional_block_pos":11,"direction":12,"optional_living_entity_reference":13,"optional_global_pos":33,"villager_data":18,"optional_unsigned_int":19,"pose":20,"cat_variant":21,"cat_sound_variant":22,"chicken_variant":30,"chicken_sound_variant":31,"cow_variant":23,"cow_sound_variant":24,"wolf_variant":25,"wolf_sound_variant":26,"frog_variant":27,"pig_variant":28,"pig_sound_variant":29,"zombie_nautilus_variant":32,"painting_variant":34,"armadillo_state":36,"sniffer_state":35,"weathering_copper_state":38,"copper_golem_state":37,"vector3":39,"quaternion":40,"resolvable_profile":41,"humanoid_arm":42}

View File

@@ -905,9 +905,9 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.50.0"
version = "1.51.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d"
checksum = "2bd1c4c0fc4a7ab90fc15ef6daaa3ec3b893f004f915f2392557ed23237820cd"
dependencies = [
"pin-project-lite",
]

View File

@@ -381,9 +381,7 @@ impl ToTokens for MaterialConditionStruct {
"floor" => quote!(
pumpkin_util::math::vertical_surface_type::VerticalSurfaceType::Floor
),
_ => quote!(
pumpkin_util::math::vertical_surface_type::VerticalSurfaceType::Floor
),
_ => quote!(panic!("Unknown surface type")),
};
tokens.extend(quote!(

View File

@@ -13,8 +13,7 @@ use crate::loot::LootTableStruct;
pub struct EntityType {
/// Numeric registry ID for this entity type.
pub id: u16,
/// Base maximum health points, if defined.
pub max_health: Option<f32>,
pub attributes: Option<Vec<BTreeMap<String, f64>>>,
/// Whether this entity can be attacked by players or other entities.
pub attackable: Option<bool>,
/// Whether this entity is classified as a mob (affects spawning mechanics).
@@ -85,11 +84,18 @@ impl ToTokens for NamedEntityType<'_> {
let entity = self.1;
let id = LitInt::new(&entity.id.to_string(), proc_macro2::Span::call_site());
let max_health = if let Some(mh) = entity.max_health {
quote! { Some(#mh) }
} else {
quote! { None }
};
let attribute_tokens = entity.attributes.as_ref().map(|vec| {
vec.iter().map(|map| {
let (key, value) = map.iter().next().unwrap();
let key = key.strip_prefix("minecraft:").unwrap_or(key);
// Replace dots with underscores and uppercase for Enum naming (e.g. generic.max_health -> GENERIC_MAX_HEALTH)
let enum_variant = format_ident!("{}", key.replace('.', "_").to_uppercase());
quote! { (Attributes::#enum_variant, #value) }
}).collect::<Vec<_>>()
}).unwrap_or_default();
let attributes_field = quote! { &[#(#attribute_tokens),*] };
let attackable = if let Some(a) = entity.attackable {
quote! { Some(#a) }
@@ -160,7 +166,7 @@ impl ToTokens for NamedEntityType<'_> {
tokens.extend(quote! {
EntityType {
id: #id,
max_health: #max_health,
attributes: #attributes_field,
attackable: #attackable,
mob: #mob,
saveable: #saveable,
@@ -213,6 +219,7 @@ pub fn build() -> TokenStream {
use crate::data_component_impl::IDSetContent;
use crate::tag::Taggable;
use crate::tag::RegistryKey;
use crate::attributes::Attributes;
use pumpkin_util::loot_table::*;
use pumpkin_util::HeightMap;
use std::hash::Hash;
@@ -220,7 +227,7 @@ pub fn build() -> TokenStream {
#[derive(Debug, Clone)]
pub struct EntityType {
pub id: u16,
pub max_health: Option<f32>,
pub attributes: &'static [(Attributes, f64)],
pub attackable: Option<bool>,
pub mob: bool,
pub saveable: bool,

View File

@@ -126,8 +126,7 @@ fn value_to_placement_modifier(v: &Value) -> TokenStream {
quote! { PlacementModifier::FixedPlacement(vec![#(#positions),*]) }
}
"minecraft:heightmap" => {
let heightmap =
value_to_height_map(v["heightmap"].as_str().unwrap_or("MOTION_BLOCKING"));
let heightmap = value_to_height_map(v["heightmap"].as_str().unwrap());
quote! {
PlacementModifier::Heightmap(HeightmapPlacementModifier {
heightmap: #heightmap,

File diff suppressed because it is too large Load Diff

View File

@@ -32,7 +32,7 @@ impl MetaDataType {
v1_21_7: 32i32,
v1_21_9: 31i32,
v1_21_11: 32i32,
v26_1: -1i32,
v26_1: 36i32,
};
pub const BLOCK_POS: MetaDataType = MetaDataType {
v1_21: 10i32,
@@ -43,7 +43,7 @@ impl MetaDataType {
v1_21_7: 10i32,
v1_21_9: 10i32,
v1_21_11: 10i32,
v26_1: -1i32,
v26_1: 10i32,
};
pub const BLOCK_STATE: MetaDataType = MetaDataType {
v1_21: 14i32,
@@ -54,7 +54,7 @@ impl MetaDataType {
v1_21_7: 14i32,
v1_21_9: 14i32,
v1_21_11: 14i32,
v26_1: -1i32,
v26_1: 14i32,
};
pub const BOOLEAN: MetaDataType = MetaDataType {
v1_21: 8i32,
@@ -65,7 +65,7 @@ impl MetaDataType {
v1_21_7: 8i32,
v1_21_9: 8i32,
v1_21_11: 8i32,
v26_1: -1i32,
v26_1: 8i32,
};
pub const BYTE: MetaDataType = MetaDataType {
v1_21: 0i32,
@@ -76,7 +76,18 @@ impl MetaDataType {
v1_21_7: 0i32,
v1_21_9: 0i32,
v1_21_11: 0i32,
v26_1: -1i32,
v26_1: 0i32,
};
pub const CAT_SOUND_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 22i32,
};
pub const CAT_VARIANT: MetaDataType = MetaDataType {
v1_21: 22i32,
@@ -87,7 +98,18 @@ impl MetaDataType {
v1_21_7: 22i32,
v1_21_9: 21i32,
v1_21_11: 21i32,
v26_1: -1i32,
v26_1: 21i32,
};
pub const CHICKEN_SOUND_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 31i32,
};
pub const CHICKEN_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -98,7 +120,18 @@ impl MetaDataType {
v1_21_7: 28i32,
v1_21_9: 27i32,
v1_21_11: 27i32,
v26_1: -1i32,
v26_1: 30i32,
};
pub const COMPONENT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 5i32,
};
pub const COPPER_GOLEM_STATE: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -109,7 +142,18 @@ impl MetaDataType {
v1_21_7: -1i32,
v1_21_9: 32i32,
v1_21_11: 33i32,
v26_1: -1i32,
v26_1: 37i32,
};
pub const COW_SOUND_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 24i32,
};
pub const COW_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -120,7 +164,18 @@ impl MetaDataType {
v1_21_7: 23i32,
v1_21_9: 22i32,
v1_21_11: 22i32,
v26_1: -1i32,
v26_1: 23i32,
};
pub const DIRECTION: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 12i32,
};
pub const ENTITY_POSE: MetaDataType = MetaDataType {
v1_21: 21i32,
@@ -153,7 +208,7 @@ impl MetaDataType {
v1_21_7: 3i32,
v1_21_9: 3i32,
v1_21_11: 3i32,
v26_1: -1i32,
v26_1: 3i32,
};
pub const FROG_VARIANT: MetaDataType = MetaDataType {
v1_21: 24i32,
@@ -164,7 +219,29 @@ impl MetaDataType {
v1_21_7: 26i32,
v1_21_9: 25i32,
v1_21_11: 25i32,
v26_1: -1i32,
v26_1: 27i32,
};
pub const HUMANOID_ARM: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 42i32,
};
pub const INT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 1i32,
};
pub const INTEGER: MetaDataType = MetaDataType {
v1_21: 1i32,
@@ -186,7 +263,7 @@ impl MetaDataType {
v1_21_7: 7i32,
v1_21_9: 7i32,
v1_21_11: 7i32,
v26_1: -1i32,
v26_1: 7i32,
};
pub const LAZY_ENTITY_REFERENCE: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -208,7 +285,7 @@ impl MetaDataType {
v1_21_7: 2i32,
v1_21_9: 2i32,
v1_21_11: 2i32,
v26_1: -1i32,
v26_1: 2i32,
};
pub const NBT_COMPOUND: MetaDataType = MetaDataType {
v1_21: 16i32,
@@ -230,7 +307,7 @@ impl MetaDataType {
v1_21_7: 11i32,
v1_21_9: 11i32,
v1_21_11: 11i32,
v26_1: -1i32,
v26_1: 11i32,
};
pub const OPTIONAL_BLOCK_STATE: MetaDataType = MetaDataType {
v1_21: 15i32,
@@ -241,7 +318,18 @@ impl MetaDataType {
v1_21_7: 15i32,
v1_21_9: 15i32,
v1_21_11: 15i32,
v26_1: -1i32,
v26_1: 15i32,
};
pub const OPTIONAL_COMPONENT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 6i32,
};
pub const OPTIONAL_GLOBAL_POS: MetaDataType = MetaDataType {
v1_21: 25i32,
@@ -252,7 +340,7 @@ impl MetaDataType {
v1_21_7: 29i32,
v1_21_9: 28i32,
v1_21_11: 29i32,
v26_1: -1i32,
v26_1: 33i32,
};
pub const OPTIONAL_INT: MetaDataType = MetaDataType {
v1_21: 20i32,
@@ -265,6 +353,17 @@ impl MetaDataType {
v1_21_11: 19i32,
v26_1: -1i32,
};
pub const OPTIONAL_LIVING_ENTITY_REFERENCE: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 13i32,
};
pub const OPTIONAL_TEXT_COMPONENT: MetaDataType = MetaDataType {
v1_21: 6i32,
v1_21_2: 6i32,
@@ -276,6 +375,17 @@ impl MetaDataType {
v1_21_11: 6i32,
v26_1: -1i32,
};
pub const OPTIONAL_UNSIGNED_INT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 19i32,
};
pub const OPTIONAL_UUID: MetaDataType = MetaDataType {
v1_21: 13i32,
v1_21_2: 13i32,
@@ -307,7 +417,7 @@ impl MetaDataType {
v1_21_7: 30i32,
v1_21_9: 29i32,
v1_21_11: 30i32,
v26_1: -1i32,
v26_1: 34i32,
};
pub const PARTICLE: MetaDataType = MetaDataType {
v1_21: 17i32,
@@ -318,7 +428,7 @@ impl MetaDataType {
v1_21_7: 17i32,
v1_21_9: 16i32,
v1_21_11: 16i32,
v26_1: -1i32,
v26_1: 16i32,
};
pub const PARTICLE_LIST: MetaDataType = MetaDataType {
v1_21: 18i32,
@@ -331,6 +441,28 @@ impl MetaDataType {
v1_21_11: 17i32,
v26_1: -1i32,
};
pub const PARTICLES: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 17i32,
};
pub const PIG_SOUND_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 29i32,
};
pub const PIG_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
@@ -340,7 +472,18 @@ impl MetaDataType {
v1_21_7: 27i32,
v1_21_9: 26i32,
v1_21_11: 26i32,
v26_1: -1i32,
v26_1: 28i32,
};
pub const POSE: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 20i32,
};
pub const PROFILE: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -353,6 +496,17 @@ impl MetaDataType {
v1_21_11: 37i32,
v26_1: -1i32,
};
pub const QUATERNION: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 40i32,
};
pub const QUATERNION_F: MetaDataType = MetaDataType {
v1_21: 30i32,
v1_21_2: 30i32,
@@ -364,6 +518,17 @@ impl MetaDataType {
v1_21_11: 36i32,
v26_1: -1i32,
};
pub const RESOLVABLE_PROFILE: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 41i32,
};
pub const ROTATION: MetaDataType = MetaDataType {
v1_21: 9i32,
v1_21_2: 9i32,
@@ -375,6 +540,17 @@ impl MetaDataType {
v1_21_11: 9i32,
v26_1: -1i32,
};
pub const ROTATIONS: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 9i32,
};
pub const SNIFFER_STATE: MetaDataType = MetaDataType {
v1_21: 27i32,
v1_21_2: 27i32,
@@ -384,7 +560,7 @@ impl MetaDataType {
v1_21_7: 31i32,
v1_21_9: 30i32,
v1_21_11: 31i32,
v26_1: -1i32,
v26_1: 35i32,
};
pub const STRING: MetaDataType = MetaDataType {
v1_21: 4i32,
@@ -395,7 +571,7 @@ impl MetaDataType {
v1_21_7: 4i32,
v1_21_9: 4i32,
v1_21_11: 4i32,
v26_1: -1i32,
v26_1: 4i32,
};
pub const TEXT_COMPONENT: MetaDataType = MetaDataType {
v1_21: 5i32,
@@ -408,6 +584,17 @@ impl MetaDataType {
v1_21_11: 5i32,
v26_1: -1i32,
};
pub const VECTOR3: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 39i32,
};
pub const VECTOR_3F: MetaDataType = MetaDataType {
v1_21: 29i32,
v1_21_2: 29i32,
@@ -428,7 +615,18 @@ impl MetaDataType {
v1_21_7: 19i32,
v1_21_9: 18i32,
v1_21_11: 18i32,
v26_1: -1i32,
v26_1: 18i32,
};
pub const WEATHERING_COPPER_STATE: MetaDataType = MetaDataType {
v1_21: -1i32,
v1_21_2: -1i32,
v1_21_4: -1i32,
v1_21_5: -1i32,
v1_21_6: -1i32,
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: -1i32,
v26_1: 38i32,
};
pub const WOLF_SOUND_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -439,7 +637,7 @@ impl MetaDataType {
v1_21_7: 25i32,
v1_21_9: 24i32,
v1_21_11: 24i32,
v26_1: -1i32,
v26_1: 26i32,
};
pub const WOLF_VARIANT: MetaDataType = MetaDataType {
v1_21: 23i32,
@@ -450,7 +648,7 @@ impl MetaDataType {
v1_21_7: 24i32,
v1_21_9: 23i32,
v1_21_11: 23i32,
v26_1: -1i32,
v26_1: 25i32,
};
pub const ZOMBIE_NAUTILUS_VARIANT: MetaDataType = MetaDataType {
v1_21: -1i32,
@@ -461,7 +659,7 @@ impl MetaDataType {
v1_21_7: -1i32,
v1_21_9: -1i32,
v1_21_11: 28i32,
v26_1: -1i32,
v26_1: 32i32,
};
pub const fn id(&self, version: pumpkin_util::version::MinecraftVersion) -> i32 {
match version {

View File

@@ -55,8 +55,8 @@ impl ClientPacket for CSetEntityMetadata {
}
pub struct Metadata<T> {
index: TrackedId,
r#type: MetaDataType,
pub index: TrackedId,
pub r#type: MetaDataType,
value: T,
}

View File

@@ -5,7 +5,6 @@ use pumpkin_util::{
math::{block_box::BlockBox, position::BlockPos, vector3::Vector3},
random::{RandomDeriverImpl, RandomGenerator, RandomImpl},
};
use tracing::debug;
use crate::{
ProtoChunk,
@@ -100,11 +99,6 @@ impl StructureGenerator for NetherFossilGenerator {
collector.add_piece(Box::new(piece));
debug!(
"Nether fossil candidate at ({}, {}, {}), template={}, rotation={:?}",
x, initial_y, z, template_name, rotation
);
Some(StructurePosition {
start_pos: BlockPos::new(x, initial_y, z),
collector: Arc::new(collector.into()),
@@ -175,12 +169,6 @@ impl StructurePieceBase for NetherFossilPiece {
) {
// Vanilla column scan: find air above soul sand or solid block
let Some(placement_y) = self.find_placement_y(chunk) else {
debug!(
"Nether fossil at ({}, {}) failed column scan from Y={}, no valid placement",
self.shiftable_structure_piece.piece.bounding_box.min.x,
self.shiftable_structure_piece.piece.bounding_box.min.z,
self.initial_y
);
return;
};
@@ -192,11 +180,6 @@ impl StructurePieceBase for NetherFossilPiece {
let origin = self.shiftable_structure_piece.piece.bounding_box.min;
debug!(
"Placing nether fossil at ({}, {}, {}), rotation={:?}",
origin.x, origin.y, origin.z, self.rotation
);
// Vanilla uses IGNORE_AIR_AND_STRUCTURE_BLOCKS processor
place_template(chunk, &self.template, origin, (0, 0), self.rotation, true);

View File

@@ -129,6 +129,6 @@ async fn can_place_at(world: &dyn BlockAccessor, block_pos: &BlockPos) -> bool {
}
}
let block = world.get_block(&block_pos.down()).await;
(block == &Block::CACTUS || block.has_tag(&tag::Block::MINECRAFT_SAND))
(block == &Block::CACTUS || block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_CACTUS))
&& !world.get_block_state(&block_pos.up()).await.is_liquid()
}

View File

@@ -1,5 +1,6 @@
use crate::block::blocks::plant::PlantBlockBase;
use crate::block::{BlockBehaviour, BlockFuture, CanPlaceAtArgs, GetStateForNeighborUpdateArgs};
use pumpkin_data::tag::{self, Taggable};
use pumpkin_data::{Block, BlockDirection, BlockState};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
@@ -58,7 +59,6 @@ impl PlantBlockBase for CactusFlowerBlock {
}
}
fn supports_cactus_flower(block: &Block, block_state: &BlockState) -> bool {
block == &Block::FARMLAND
|| block == &Block::CACTUS
block.has_tag(&tag::Block::MINECRAFT_SUPPORT_OVERRIDE_CACTUS_FLOWER)
|| block_state.is_center_solid(BlockDirection::Up)
}

View File

@@ -3,6 +3,7 @@ use pumpkin_data::{
block_properties::{
BlockProperties, EnumVariants, Integer0To7, WallTorchLikeProperties, WheatLikeProperties,
},
tag::{self, Taggable},
};
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::{BlockStateId, world::BlockAccessor};
@@ -79,6 +80,10 @@ impl BlockBehaviour for AttachedStemBlock {
impl PlantBlockBase for AttachedStemBlock {
async fn can_plant_on_top(&self, block_accessor: &dyn BlockAccessor, pos: &BlockPos) -> bool {
let block = block_accessor.get_block(pos).await;
block == &Block::FARMLAND
if block == &Block::ATTACHED_PUMPKIN_STEM {
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_PUMPKIN_STEM)
} else {
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_MELON_STEM)
}
}
}

View File

@@ -134,6 +134,10 @@ impl BlockBehaviour for StemBlock {
impl PlantBlockBase for StemBlock {
async fn can_plant_on_top(&self, block_accessor: &dyn BlockAccessor, pos: &BlockPos) -> bool {
let block = block_accessor.get_block(pos).await;
block == &Block::FARMLAND
if block == &Block::PUMPKIN_STEM {
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_PUMPKIN_STEM)
} else {
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_MELON_STEM)
}
}
}

View File

@@ -3,6 +3,7 @@ use std::sync::Arc;
use pumpkin_data::{
Block,
block_properties::{BlockProperties, EnumVariants, Integer0To3, NetherWartLikeProperties},
tag::{self, Taggable},
};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
@@ -55,7 +56,7 @@ impl BlockBehaviour for NetherWartBlock {
impl PlantBlockBase for NetherWartBlock {
async fn can_plant_on_top(&self, block_accessor: &dyn BlockAccessor, pos: &BlockPos) -> bool {
let block = block_accessor.get_block(pos).await;
block == &Block::SOUL_SAND
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_NETHER_WART)
}
async fn can_place_at(&self, block_accessor: &dyn BlockAccessor, block_pos: &BlockPos) -> bool {

View File

@@ -16,7 +16,6 @@ use pumpkin_data::{
entity::EntityType,
item::Item,
item_stack::ItemStack,
tag::{self, Taggable},
};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
@@ -150,11 +149,6 @@ impl BlockBehaviour for SweetBerryBushBlock {
}
impl PlantBlockBase for SweetBerryBushBlock {
async fn can_plant_on_top(&self, block_accessor: &dyn BlockAccessor, pos: &BlockPos) -> bool {
let block = block_accessor.get_block(pos).await;
block.has_tag(&tag::Block::MINECRAFT_DIRT)
}
async fn get_state_for_neighbor_update(
&self,
block_accessor: &dyn BlockAccessor,

View File

@@ -49,11 +49,9 @@ impl PlantBlockBase for FungusBlock {
}
#[must_use]
pub fn supports_fungus(block: &Block) -> bool {
block.has_tag(&tag::Block::MINECRAFT_DIRT)
|| block == &Block::FARMLAND
|| block == &Block::WARPED_NYLIUM
|| block == &Block::CRIMSON_NYLIUM
|| block == &Block::SOUL_SOIL
|| block == &Block::MUD
|| block == &Block::MUDDY_MANGROVE_ROOTS
if block == &Block::WARPED_FUNGUS {
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_WARPED_FUNGUS)
} else {
block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_CRIMSON_FUNGUS)
}
}

View File

@@ -1,4 +1,4 @@
use pumpkin_data::Block;
use pumpkin_data::tag::{self, Taggable};
use pumpkin_macros::pumpkin_block;
use pumpkin_util::math::position::BlockPos;
use pumpkin_world::{
@@ -55,9 +55,11 @@ impl BlockBehaviour for LilyPadBlock {
impl PlantBlockBase for LilyPadBlock {
async fn can_plant_on_top(&self, block_accessor: &dyn BlockAccessor, pos: &BlockPos) -> bool {
// TODO: get and use fluids not blocks
let block = block_accessor.get_block(pos).await;
let above_fluid = block_accessor.get_block(&pos.up()).await;
(block == &Block::WATER || block == &Block::ICE)
&& (above_fluid != &Block::WATER && above_fluid != &Block::LAVA)
(block.has_tag(&tag::Fluid::MINECRAFT_SUPPORTS_LILY_PAD)
|| block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_LILY_PAD))
&& above_fluid.is_air()
}
}

View File

@@ -43,10 +43,11 @@ impl BlockBehaviour for RootsBlock {
impl PlantBlockBase for RootsBlock {
async fn can_plant_on_top(&self, block_accessor: &dyn BlockAccessor, pos: &BlockPos) -> bool {
let block_below = block_accessor.get_block(pos).await;
block_below.has_tag(&tag::Block::MINECRAFT_NYLIUM)
|| block_below == &Block::SOUL_SOIL
|| block_below.has_tag(&tag::Block::MINECRAFT_DIRT)
|| block_below == &Block::FARMLAND
if block_below == &Block::WARPED_ROOTS {
block_below.has_tag(&tag::Block::MINECRAFT_SUPPORTS_WARPED_ROOTS)
} else {
block_below.has_tag(&tag::Block::MINECRAFT_SUPPORTS_CRIMSON_ROOTS)
}
}
async fn can_place_at(&self, block_accessor: &dyn BlockAccessor, block_pos: &BlockPos) -> bool {

View File

@@ -99,15 +99,15 @@ async fn can_place_at(block_accessor: &dyn BlockAccessor, block_pos: &BlockPos)
return true;
}
if block_below.has_tag(&tag::Block::MINECRAFT_DIRT)
|| block_below.has_tag(&tag::Block::MINECRAFT_SAND)
{
if block_below.has_tag(&tag::Block::MINECRAFT_SUPPORTS_SUGAR_CANE) {
for direction in HorizontalFacing::all() {
let block = block_accessor
.get_block(&block_pos.down().offset(direction.to_offset()))
.await;
if block == &Block::WATER || block == &Block::FROSTED_ICE {
// TODO: use fluid
if block.has_tag(&tag::Fluid::MINECRAFT_SUPPORTS_SUGAR_CANE_ADJACENTLY)
&& block.has_tag(&tag::Block::MINECRAFT_SUPPORTS_SUGAR_CANE_ADJACENTLY)
{
return true;
}
}

View File

@@ -4,14 +4,14 @@ use super::{Controls, Goal};
use crate::entity::{ai::goal::GoalFuture, mob::Mob};
use rand::RngExt;
pub struct LookAroundGoal {
pub struct RandomLookAroundGoal {
goal_control: Controls,
delta_x: f64,
delta_z: f64,
look_time: i32,
}
impl Default for LookAroundGoal {
impl Default for RandomLookAroundGoal {
fn default() -> Self {
Self {
goal_control: Controls::MOVE | Controls::LOOK,
@@ -22,7 +22,7 @@ impl Default for LookAroundGoal {
}
}
impl Goal for LookAroundGoal {
impl Goal for RandomLookAroundGoal {
fn can_start<'a>(&'a mut self, mob: &'a dyn Mob) -> GoalFuture<'a, bool> {
Box::pin(async { mob.get_random().random::<f32>() < 0.02 })
}

View File

@@ -1,8 +1,6 @@
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use std::collections::HashMap;
use std::sync::LazyLock;
use std::sync::RwLock;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::AtomicU64;
use std::sync::atomic::Ordering;
@@ -260,87 +258,3 @@ impl AttributeRegistry {
}
}
}
// Provide a global default registry that can be referenced.
pub static DEFAULT_ATTRIBUTE_REGISTRY: LazyLock<RwLock<AttributeRegistry>> =
LazyLock::new(|| RwLock::new(AttributeRegistry::new()));
/// Initialize the global attribute registry with per-entity registrations.
pub fn init_all_attributes() {
let mut reg = DEFAULT_ATTRIBUTE_REGISTRY.write().unwrap();
// Register per-entity attribute builders here. Add entries as modules implement
// `create_attributes()` on their entity types.
reg.register_builder(
&EntityType::CREEPER, // Aw man
crate::entity::mob::creeper::CreeperEntity::create_attributes(),
);
reg.register_builder(
&EntityType::ENDERMAN,
crate::entity::mob::enderman::EndermanEntity::create_attributes(),
);
reg.register_builder(
&EntityType::WOLF,
crate::entity::passive::wolf::WolfEntity::create_attributes(),
);
reg.register_builder(
&EntityType::IRON_GOLEM,
crate::entity::passive::iron_golem::IronGolemEntity::create_attributes(),
);
reg.register_builder(
&EntityType::SNOW_GOLEM,
crate::entity::passive::snow_golem::SnowGolemEntity::create_attributes(),
);
reg.register_builder(
&EntityType::SKELETON,
crate::entity::mob::skeleton::SkeletonEntityBase::create_attributes(),
);
// Register skeleton variants that reuse the base skeleton attributes
reg.register_builder(
&EntityType::STRAY,
crate::entity::mob::skeleton::SkeletonEntityBase::create_attributes(),
);
reg.register_builder(
&EntityType::WITHER_SKELETON,
crate::entity::mob::skeleton::SkeletonEntityBase::create_attributes(),
);
reg.register_builder(
&EntityType::ZOMBIE,
crate::entity::mob::zombie::ZombieEntityBase::create_attributes(),
);
// Register zombie-family variants that reuse the zombie attributes
reg.register_builder(
&EntityType::HUSK,
crate::entity::mob::zombie::ZombieEntityBase::create_attributes(),
);
reg.register_builder(
&EntityType::DROWNED,
crate::entity::mob::zombie::ZombieEntityBase::create_attributes(),
);
reg.register_builder(
&EntityType::ZOMBIE_VILLAGER,
crate::entity::mob::zombie::ZombieEntityBase::create_attributes(),
);
// Boss entities
reg.register_builder(
&EntityType::WITHER,
crate::entity::boss::wither::WitherEntity::create_attributes(),
);
reg.register_builder(
&EntityType::PLAYER,
crate::entity::player::Player::create_attributes(),
);
}

View File

@@ -1,10 +1,9 @@
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::{attributes::Attributes, entity::EntityType};
use pumpkin_data::entity::EntityType;
use std::sync::{Arc, Weak};
use crate::entity::{
Entity, NBTStorage,
ai::goal::{look_around::LookAroundGoal, look_at_entity::LookAtEntityGoal},
ai::goal::{look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal},
mob::{Mob, MobEntity},
};
@@ -30,21 +29,11 @@ impl WitherEntity {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::ARMOR, 4.0)
.add(Attributes::FLYING_SPEED, 0.6)
.add(Attributes::FOLLOW_RANGE, 40.0)
.add(Attributes::MOVEMENT_SPEED, 0.6)
.add(Attributes::MAX_HEALTH, 300.0)
}
}
impl NBTStorage for WitherEntity {}

View File

@@ -22,9 +22,9 @@ use tracing::warn;
use super::{Entity, NBTStorage};
use super::{EntityBase, NBTStorageInit};
use crate::block::OnLandedUponArgs;
use crate::entity::attributes::AttributeInstance;
use crate::entity::attributes::Modifier;
use crate::entity::attributes::ModifierOperation;
use crate::entity::attributes::{AttributeInstance, DEFAULT_ATTRIBUTE_REGISTRY};
use crate::entity::{EntityBaseFuture, NbtFuture};
use crate::server::Server;
use crate::world::loot::{LootContextParameters, LootTableExt};
@@ -134,21 +134,17 @@ impl LivingEntity {
} else {
0.8
};
let entity_type_id = entity.entity_type.id;
let mut max_health: f32 = 20.0; // Overridden by attribute base below
Self {
// Populate local attribute instances from the default registry and get initial vars
attributes: {
let mut m = std::collections::HashMap::new();
let reg = DEFAULT_ATTRIBUTE_REGISTRY.read().unwrap();
if let Some(overrides) = reg.get_overrides_for_entity(entity_type_id) {
for (attr_id, base) in overrides {
if attr_id == Attributes::MAX_HEALTH.id {
max_health = base as f32;
}
m.insert(attr_id, AttributeInstance::new(base));
for (attr, base) in entity.entity_type.attributes {
if attr.id == Attributes::MAX_HEALTH.id {
max_health = *base as f32;
}
m.insert(attr.id, AttributeInstance::new(*base));
}
std::sync::RwLock::new(m)
},
@@ -351,8 +347,14 @@ impl LivingEntity {
let mut map = self.attributes.write().unwrap();
let inst = map.entry(attribute.id).or_insert_with(|| {
let reg = DEFAULT_ATTRIBUTE_REGISTRY.read().unwrap();
let base = reg.get_base_value(self.entity.entity_type.id, attribute);
let base = self
.entity
.entity_type
.attributes
.iter()
.find(|a| a.0.id == attribute.id)
.unwrap()
.1;
AttributeInstance::new(base)
});
@@ -377,8 +379,13 @@ impl LivingEntity {
}
// Fall back to registry base value if no local instance exists
let reg = DEFAULT_ATTRIBUTE_REGISTRY.read().unwrap();
reg.get_base_value(self.entity.entity_type.id, attribute)
self.entity
.entity_type
.attributes
.iter()
.find(|a| a.0.id == attribute.id)
.unwrap()
.1
}
/// Update or insert the base value for an attribute on this entity.

View File

@@ -1,14 +1,9 @@
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, AtomicI32, Ordering::Relaxed};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::damage::DamageType;
use pumpkin_data::meta_data_type::MetaDataType;
use pumpkin_data::sound::Sound;
use pumpkin_data::tracked_data::TrackedData;
use pumpkin_nbt::compound::NbtCompound;
use pumpkin_protocol::java::client::play::Metadata;
use pumpkin_util::math::position::BlockPos;
use pumpkin_util::math::vector3::Vector3;
use rand::RngExt;
@@ -54,22 +49,19 @@ impl BatEntity {
self.set_roosting_metadata(roosting).await;
}
async fn set_roosting_metadata(&self, roosting: bool) {
let flags: u8 = if roosting { ROOSTING_FLAG } else { 0 };
self.mob_entity
.living_entity
.entity
.send_meta_data(&[Metadata::new(
TrackedData::ID_FLAGS,
MetaDataType::BYTE,
flags,
)])
.await;
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new().add(Attributes::MAX_HEALTH, 6.0)
#[expect(clippy::unused_async)]
async fn set_roosting_metadata(&self, _roosting: bool) {
// TODO
// let flags: u8 = if roosting { ROOSTING_FLAG } else { 0 };
// self.mob_entity
// .living_entity
// .entity
// .send_meta_data(&[Metadata::new(
// TrackedData::ID_FLAGS,
// MetaDataType::BYTE,
// flags,
// )])
// .await;
}
}

View File

@@ -0,0 +1,53 @@
use std::sync::{Arc, Weak};
use pumpkin_data::entity::EntityType;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{
active_target::ActiveTargetGoal, look_around::RandomLookAroundGoal,
look_at_entity::LookAtEntityGoal,
},
mob::{Mob, MobEntity},
};
pub struct BlazeEntity {
entity: Arc<MobEntity>,
}
impl BlazeEntity {
pub async fn new(entity: Entity) -> Arc<Self> {
let entity = Arc::new(MobEntity::new(entity));
let zombie = Self { entity };
let mob_arc = Arc::new(zombie);
let mob_weak: Weak<dyn Mob> = {
let mob_arc: Arc<dyn Mob> = mob_arc.clone();
Arc::downgrade(&mob_arc)
};
{
let mut goal_selector = mob_arc.entity.goals_selector.lock().await;
let mut target_selector = mob_arc.entity.target_selector.lock().await;
// TODO
goal_selector.add_goal(
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
target_selector.add_goal(
2,
ActiveTargetGoal::with_default(&mob_arc.entity, &EntityType::PLAYER, true),
);
};
mob_arc
}
}
impl NBTStorage for BlazeEntity {}
impl Mob for BlazeEntity {
fn get_mob_entity(&self) -> &MobEntity {
&self.entity
}
}

View File

@@ -3,8 +3,6 @@ use std::sync::{
atomic::{AtomicBool, AtomicI32, Ordering},
};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::{
entity::EntityType,
@@ -20,7 +18,7 @@ use crate::entity::{
Entity, EntityBase, EntityBaseFuture, NBTStorage, NbtFuture,
ai::goal::{
active_target::ActiveTargetGoal, creeper_ignite::CreeperIgniteGoal,
look_around::LookAroundGoal, look_at_entity::LookAtEntityGoal,
look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal,
melee_attack::MeleeAttackGoal, revenge::RevengeGoal, swim::SwimGoal,
wander_around::WanderAroundGoal,
},
@@ -74,7 +72,7 @@ impl CreeperEntity {
6,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(6, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(6, Box::new(RandomLookAroundGoal::default()));
target_selector.add_goal(
1,
@@ -117,11 +115,6 @@ impl CreeperEntity {
// TODO: spawn area effect cloud with potion effects
entity.remove().await;
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new().add(Attributes::MOVEMENT_SPEED, 0.25)
}
}
impl NBTStorage for CreeperEntity {

View File

@@ -3,7 +3,6 @@ use std::sync::{
atomic::{AtomicBool, Ordering},
};
use crate::entity::attributes::AttributeBuilder;
use crate::entity::attributes::Modifier;
use crate::entity::attributes::ModifierOperation;
use pumpkin_data::attributes::Attributes;
@@ -36,7 +35,7 @@ use crate::entity::{
ai::{
goal::{
GoalFuture, active_target::ActiveTargetGoal, chase_player::ChasePlayerGoal,
look_around::LookAroundGoal, look_at_entity::LookAtEntityGoal,
look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal,
melee_attack::MeleeAttackGoal, pick_up_block::PickUpBlockGoal,
place_block::PlaceBlockGoal, revenge::RevengeGoal, swim::SwimGoal,
teleport_towards_player::TeleportTowardsPlayerGoal, wander_around::WanderAroundGoal,
@@ -101,7 +100,7 @@ impl EndermanEntity {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
goal_selector.add_goal(10, Box::new(PlaceBlockGoal::new(mob_arc.clone())));
goal_selector.add_goal(11, Box::new(PickUpBlockGoal::new(mob_arc.clone())));
@@ -116,16 +115,6 @@ impl EndermanEntity {
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::ATTACK_DAMAGE, 7.0)
.add(Attributes::FOLLOW_RANGE, 64.0)
.add(Attributes::MOVEMENT_SPEED, 0.3)
.add(Attributes::STEP_HEIGHT, 1.0)
.add(Attributes::MAX_HEALTH, 40.0)
}
pub async fn teleport_randomly(&self) -> bool {
let entity = &self.mob_entity.living_entity.entity;
let pos = entity.pos.load();

View File

@@ -26,6 +26,7 @@ use tokio::sync::Mutex;
use uuid::Uuid;
pub mod bat;
pub mod blaze;
pub mod creeper;
pub mod enderman;
pub mod silverfish;

View File

@@ -1,7 +1,5 @@
use std::sync::Arc;
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use crate::entity::{
@@ -32,14 +30,6 @@ impl SilverfishEntity {
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MAX_HEALTH, 8.0)
.add(Attributes::MOVEMENT_SPEED, 0.25)
.add(Attributes::ATTACK_DAMAGE, 1.0)
}
}
impl NBTStorage for SilverfishEntity {}

View File

@@ -1,13 +1,11 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{
active_target::ActiveTargetGoal, look_around::LookAroundGoal,
active_target::ActiveTargetGoal, look_around::RandomLookAroundGoal,
look_at_entity::LookAtEntityGoal,
},
mob::{Mob, MobEntity},
@@ -41,7 +39,7 @@ impl SkeletonEntityBase {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
target_selector.add_goal(
2,
@@ -51,11 +49,6 @@ impl SkeletonEntityBase {
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new().add(Attributes::MOVEMENT_SPEED, 0.25)
}
}
impl NBTStorage for SkeletonEntityBase {}

View File

@@ -1,13 +1,11 @@
use super::{Mob, MobEntity};
use crate::entity::ai::goal::destroy_egg::DestroyEggGoal;
use crate::entity::ai::goal::look_around::LookAroundGoal;
use crate::entity::ai::goal::look_around::RandomLookAroundGoal;
use crate::entity::ai::goal::zombie_attack::ZombieAttackGoal;
use crate::entity::attributes::AttributeBuilder;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{active_target::ActiveTargetGoal, look_at_entity::LookAtEntityGoal},
};
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use std::sync::{Arc, Weak};
@@ -40,27 +38,29 @@ impl ZombieEntityBase {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
goal_selector.add_goal(3, ZombieAttackGoal::new(1.0, false));
target_selector.add_goal(
2,
ActiveTargetGoal::with_default(&mob_arc.mob_entity, &EntityType::PLAYER, true),
);
target_selector.add_goal(
3,
ActiveTargetGoal::with_default(&mob_arc.mob_entity, &EntityType::VILLAGER, true),
);
target_selector.add_goal(
3,
ActiveTargetGoal::with_default(&mob_arc.mob_entity, &EntityType::IRON_GOLEM, true),
);
target_selector.add_goal(
5,
ActiveTargetGoal::with_default(&mob_arc.mob_entity, &EntityType::TURTLE, true),
);
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MAX_HEALTH, 20.0)
.add(Attributes::MOVEMENT_SPEED, 0.23)
.add(Attributes::ATTACK_DAMAGE, 3.0)
.add(Attributes::FOLLOW_RANGE, 35.0)
.add(Attributes::ARMOR, 2.0)
}
}
impl NBTStorage for ZombieEntityBase {}

View File

@@ -1,7 +1,5 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::{entity::EntityType, item::Item};
use crate::entity::{
@@ -44,14 +42,6 @@ impl CatEntity {
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MOVEMENT_SPEED, 0.3)
.add(Attributes::ATTACK_DAMAGE, 3.0)
.add(Attributes::MAX_HEALTH, 10.0)
}
}
impl NBTStorage for CatEntity {}

View File

@@ -3,8 +3,6 @@ use std::sync::{
atomic::{AtomicI32, Ordering, Ordering::Relaxed},
};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::item_stack::ItemStack;
use pumpkin_data::{entity::EntityType, item::Item};
use rand::RngExt;
@@ -12,7 +10,7 @@ use rand::RngExt;
use crate::entity::{
Entity, EntityBase, EntityBaseFuture, NBTStorage,
ai::goal::{
escape_danger::EscapeDangerGoal, look_around::LookAroundGoal,
escape_danger::EscapeDangerGoal, look_around::RandomLookAroundGoal,
look_at_entity::LookAtEntityGoal, swim::SwimGoal, tempt::TemptGoal,
wander_around::WanderAroundGoal,
},
@@ -58,18 +56,11 @@ impl ChickenEntity {
6,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 6.0),
);
goal_selector.add_goal(7, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(7, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MOVEMENT_SPEED, 0.25)
.add(Attributes::MAX_HEALTH, 4.0)
}
}
impl NBTStorage for ChickenEntity {}

View File

@@ -1,13 +1,11 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::{entity::EntityType, item::Item};
use crate::entity::{
Entity, NBTStorage,
ai::goal::{
escape_danger::EscapeDangerGoal, look_around::LookAroundGoal,
escape_danger::EscapeDangerGoal, look_around::RandomLookAroundGoal,
look_at_entity::LookAtEntityGoal, swim::SwimGoal, tempt::TemptGoal,
wander_around::WanderAroundGoal,
},
@@ -41,18 +39,11 @@ impl CowEntity {
6,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 6.0),
);
goal_selector.add_goal(7, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(7, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MOVEMENT_SPEED, 0.2)
.add(Attributes::MAX_HEALTH, 10.0)
}
}
impl NBTStorage for CowEntity {}

View File

@@ -1,12 +1,10 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{look_around::LookAroundGoal, look_at_entity::LookAtEntityGoal},
ai::goal::{look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal},
mob::{Mob, MobEntity},
};
@@ -32,21 +30,11 @@ impl IronGolemEntity {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::ATTACK_DAMAGE, 15.0)
.add(Attributes::KNOCKBACK_RESISTANCE, 1.0)
.add(Attributes::MOVEMENT_SPEED, 0.25)
.add(Attributes::STEP_HEIGHT, 1.0)
.add(Attributes::MAX_HEALTH, 100.0)
}
}
impl NBTStorage for IronGolemEntity {}

View File

@@ -1,14 +1,12 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use pumpkin_data::item::Item;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{
escape_danger::EscapeDangerGoal, look_around::LookAroundGoal,
escape_danger::EscapeDangerGoal, look_around::RandomLookAroundGoal,
look_at_entity::LookAtEntityGoal, swim::SwimGoal, tempt::TemptGoal,
wander_around::WanderAroundGoal,
},
@@ -47,18 +45,11 @@ impl PigEntity {
7,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 6.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MOVEMENT_SPEED, 0.25)
.add(Attributes::MAX_HEALTH, 10.0)
}
}
impl NBTStorage for PigEntity {}

View File

@@ -3,8 +3,6 @@ use std::sync::{
atomic::{AtomicU8, Ordering},
};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::{
entity::EntityType, item::Item, meta_data_type::MetaDataType, tracked_data::TrackedData,
};
@@ -14,9 +12,9 @@ use pumpkin_protocol::java::client::play::Metadata;
use crate::entity::{
Entity, EntityBaseFuture, NBTStorage, NbtFuture,
ai::goal::{
eat_grass::EatGrassGoal, escape_danger::EscapeDangerGoal, look_around::LookAroundGoal,
look_at_entity::LookAtEntityGoal, swim::SwimGoal, tempt::TemptGoal,
wander_around::WanderAroundGoal,
eat_grass::EatGrassGoal, escape_danger::EscapeDangerGoal,
look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal, swim::SwimGoal,
tempt::TemptGoal, wander_around::WanderAroundGoal,
},
mob::{Mob, MobEntity},
};
@@ -53,7 +51,7 @@ impl SheepEntity {
7,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 6.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
@@ -77,7 +75,7 @@ impl SheepEntity {
.living_entity
.entity
.send_meta_data(&[Metadata::new(
TrackedData::COLOR_ID,
TrackedData::WOOL_ID,
MetaDataType::BYTE,
byte as i8,
)])
@@ -97,13 +95,6 @@ impl SheepEntity {
};
self.set_packed_and_sync(byte).await;
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MOVEMENT_SPEED, 0.23)
.add(Attributes::MAX_HEALTH, 8.0)
}
}
impl NBTStorage for SheepEntity {

View File

@@ -1,12 +1,10 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{look_around::LookAroundGoal, look_at_entity::LookAtEntityGoal},
ai::goal::{look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal},
mob::{Mob, MobEntity},
};
@@ -32,18 +30,11 @@ impl SnowGolemEntity {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::ATTACK_DAMAGE, 0.0)
.add(Attributes::MOVEMENT_SPEED, 0.2)
}
}
impl NBTStorage for SnowGolemEntity {}

View File

@@ -1,13 +1,11 @@
use std::sync::{Arc, Weak};
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::entity::EntityType;
use pumpkin_data::item::Item;
use crate::entity::{
Entity, NBTStorage,
ai::goal::{beg::BegGoal, look_around::LookAroundGoal, look_at_entity::LookAtEntityGoal},
ai::goal::{beg::BegGoal, look_around::RandomLookAroundGoal, look_at_entity::LookAtEntityGoal},
mob::{Mob, MobEntity},
};
@@ -32,19 +30,12 @@ impl WolfEntity {
8,
LookAtEntityGoal::with_default(mob_weak, &EntityType::PLAYER, 8.0),
);
goal_selector.add_goal(8, Box::new(LookAroundGoal::default()));
goal_selector.add_goal(8, Box::new(RandomLookAroundGoal::default()));
goal_selector.add_goal(9, BegGoal::new(8.0, &[&Item::BONE]));
};
mob_arc
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new()
.add(Attributes::MOVEMENT_SPEED, 0.3)
.add(Attributes::MAX_HEALTH, 8.0)
}
}
impl NBTStorage for WolfEntity {}

View File

@@ -28,7 +28,6 @@ use tokio::task::JoinHandle;
use tracing::{debug, warn};
use uuid::Uuid;
use crate::entity::attributes::AttributeBuilder;
use pumpkin_data::attributes::Attributes;
use pumpkin_data::block_properties::{BlockProperties, EnumVariants, HorizontalFacing};
use pumpkin_data::damage::DamageType;
@@ -597,11 +596,6 @@ impl Player {
}
}
#[must_use]
pub fn create_attributes() -> AttributeBuilder {
AttributeBuilder::new().add(Attributes::MOVEMENT_SPEED, 0.1)
}
/// Spawns a task associated with this player-client. All tasks spawned with this method are awaited
/// when the client. This means tasks should complete in a reasonable amount of time or select
/// on `Self::await_close_interrupt` to cancel the task when the client is closed

View File

@@ -5,6 +5,7 @@ use pumpkin_util::math::vector3::Vector3;
use uuid::Uuid;
use crate::entity::boss::ender_dragon::EnderDragonEntity;
use crate::entity::mob::blaze::BlazeEntity;
use crate::entity::mob::zombie::zombie_villager::ZombieVillagerEntity;
use crate::{
entity::{
@@ -59,6 +60,7 @@ pub async fn from_type(
id if id == EntityType::CREEPER.id => CreeperEntity::new(entity).await,
id if id == EntityType::ENDERMAN.id => EndermanEntity::new(entity).await,
id if id == EntityType::BLAZE.id => BlazeEntity::new(entity).await,
id if id == EntityType::CAT.id => CatEntity::new(entity).await,
id if id == EntityType::CHICKEN.id => ChickenEntity::new(entity).await,
id if id == EntityType::COW.id => CowEntity::new(entity).await,
@@ -80,10 +82,10 @@ pub async fn from_type(
id if id == EntityType::SILVERFISH.id => SilverfishEntity::new(entity).await,
// Fallback Entity
_ => {
if entity_type.max_health.is_some() {
Arc::new(LivingEntity::new(entity))
} else {
if entity_type.attributes.is_empty() {
Arc::new(entity)
} else {
Arc::new(LivingEntity::new(entity))
}
}
};

View File

@@ -249,9 +249,6 @@ impl Server {
};
let server = Arc::new(server);
// Initialize attribute registry for all entities
crate::entity::attributes::init_all_attributes();
let server_clone = server.clone();
tokio::spawn(async move {
server_clone