1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 14:26:04 +00:00

handle_block_interact_event

This commit is contained in:
mat 2023-02-26 15:43:53 -06:00
commit 7143ca4420
33 changed files with 1662 additions and 1684 deletions

509
Cargo.lock generated
View file

@ -61,6 +61,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "android_log-sys"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e"
[[package]]
name = "anyhow"
version = "1.0.69"
@ -177,7 +183,6 @@ dependencies = [
"azalea-world",
"bevy_tasks",
"derive_more",
"env_logger 0.10.0",
"futures",
"futures-lite",
"log",
@ -197,7 +202,7 @@ dependencies = [
"azalea-buf",
"azalea-crypto",
"chrono",
"env_logger 0.9.3",
"env_logger",
"log",
"num-bigint",
"reqwest",
@ -285,10 +290,10 @@ dependencies = [
"azalea-protocol",
"azalea-registry",
"azalea-world",
"bevy_log",
"bevy_tasks",
"bevy_time",
"derive_more",
"env_logger 0.9.3",
"futures",
"log",
"nohash-hasher",
@ -345,7 +350,7 @@ dependencies = [
"proc-macro2",
"quote",
"syn",
"toml 0.7.1",
"toml 0.7.2",
]
[[package]]
@ -567,6 +572,22 @@ dependencies = [
"syn",
]
[[package]]
name = "bevy_log"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c480bac54cf4ae76edc3ae9ae3fa7c5e1b385e7f2111ef5ec3fd00cf3a7998b"
dependencies = [
"android_log-sys",
"bevy_app",
"bevy_ecs",
"bevy_utils",
"console_error_panic_hook",
"tracing-log",
"tracing-subscriber",
"tracing-wasm",
]
[[package]]
name = "bevy_macro_utils"
version = "0.9.1"
@ -700,18 +721,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "bstr"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
"regex-automata",
"serde",
]
[[package]]
name = "bumpalo"
version = "3.12.0"
@ -818,28 +827,22 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "console_error_panic_hook"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
"cfg-if",
"wasm-bindgen",
]
[[package]]
name = "convert_case"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
[[package]]
name = "core-foundation"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpufeatures"
version = "0.2.5"
@ -949,13 +952,12 @@ dependencies = [
[[package]]
name = "csv"
version = "1.1.6"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1"
checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359"
dependencies = [
"bstr",
"csv-core",
"itoa 0.4.8",
"itoa",
"ryu",
"serde",
]
@ -1044,19 +1046,6 @@ dependencies = [
"termcolor",
]
[[package]]
name = "env_logger"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0"
dependencies = [
"humantime",
"is-terminal",
"log",
"regex",
"termcolor",
]
[[package]]
name = "erased-serde"
version = "0.3.24"
@ -1066,27 +1055,6 @@ dependencies = [
"serde",
]
[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
"cc",
"libc",
]
[[package]]
name = "event-listener"
version = "2.5.3"
@ -1095,9 +1063,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
[[package]]
name = "fastrand"
version = "1.8.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499"
checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be"
dependencies = [
"instant",
]
@ -1124,21 +1092,6 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "form_urlencoded"
version = "1.1.0"
@ -1286,9 +1239,9 @@ dependencies = [
[[package]]
name = "gimli"
version = "0.27.1"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "221996f774192f0f718773def8201c4ae31f02616a54ccfc2d358bb0e5cefdec"
checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4"
[[package]]
name = "glam"
@ -1359,21 +1312,15 @@ dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "856b5cb0902c2b6d65d5fd97dfa30f9b70c7538e770b98eab5ed52d8db923e01"
[[package]]
name = "http"
version = "0.2.8"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
dependencies = [
"bytes",
"fnv",
"itoa 1.0.5",
"itoa",
]
[[package]]
@ -1420,7 +1367,7 @@ dependencies = [
"http-body",
"httparse",
"httpdate",
"itoa 1.0.5",
"itoa",
"pin-project-lite",
"socket2",
"tokio",
@ -1430,16 +1377,16 @@ dependencies = [
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
name = "hyper-rustls"
version = "0.23.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c"
dependencies = [
"bytes",
"http",
"hyper",
"native-tls",
"rustls",
"tokio",
"tokio-native-tls",
"tokio-rustls",
]
[[package]]
@ -1494,34 +1441,12 @@ dependencies = [
"web-sys",
]
[[package]]
name = "io-lifetimes"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
dependencies = [
"libc",
"windows-sys 0.45.0",
]
[[package]]
name = "ipnet"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146"
[[package]]
name = "is-terminal"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef"
dependencies = [
"hermit-abi 0.3.0",
"io-lifetimes",
"rustix",
"windows-sys 0.45.0",
]
[[package]]
name = "itertools"
version = "0.10.5"
@ -1531,12 +1456,6 @@ dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "itoa"
version = "1.0.5"
@ -1570,12 +1489,6 @@ version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]]
name = "linux-raw-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
[[package]]
name = "lock_api"
version = "0.4.9"
@ -1604,6 +1517,15 @@ dependencies = [
"linked-hash-map",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "matches"
version = "0.1.10"
@ -1642,32 +1564,14 @@ dependencies = [
[[package]]
name = "mio"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys 0.42.0",
]
[[package]]
name = "native-tls"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
dependencies = [
"lazy_static",
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
"windows-sys 0.45.0",
]
[[package]]
@ -1676,15 +1580,6 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "nom8"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8"
dependencies = [
"memchr",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
@ -1803,9 +1698,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.17.0"
version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]]
name = "oorandom"
@ -1813,51 +1708,6 @@ version = "11.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
[[package]]
name = "openssl"
version = "0.10.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b102428fd03bc5edf97f62620f7298614c45cedf287c271e7ed450bbaf83f2e1"
dependencies = [
"bitflags",
"cfg-if",
"foreign-types",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23bbbf7854cd45b83958ebe919f0e8e516793727652e27fda10a8384cfc790b7"
dependencies = [
"autocfg",
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "overload"
version = "0.1.1"
@ -1904,9 +1754,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "petgraph"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143"
checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
dependencies = [
"fixedbitset",
"indexmap",
@ -1924,12 +1774,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "plotters"
version = "0.3.4"
@ -2069,6 +1913,9 @@ name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
@ -2076,15 +1923,6 @@ version = "0.6.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi",
]
[[package]]
name = "reqwest"
version = "0.11.14"
@ -2100,28 +1938,45 @@ dependencies = [
"http",
"http-body",
"hyper",
"hyper-tls",
"hyper-rustls",
"ipnet",
"js-sys",
"log",
"mime",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls",
"rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
"tokio",
"tokio-native-tls",
"tokio-rustls",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots",
"winreg",
]
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winapi",
]
[[package]]
name = "rsa_public_encrypt_pkcs1"
version = "0.4.0"
@ -2149,17 +2004,24 @@ dependencies = [
]
[[package]]
name = "rustix"
version = "0.36.8"
name = "rustls"
version = "0.20.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
checksum = "fff78fc74d175294f4e83b28343315ffcfb114b156f0185e9741cb5570f50e2f"
dependencies = [
"bitflags",
"errno",
"io-lifetimes",
"libc",
"linux-raw-sys",
"windows-sys 0.45.0",
"log",
"ring",
"sct",
"webpki",
]
[[package]]
name = "rustls-pemfile"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d194b56d58803a43635bdc398cd17e383d6f71f9182b9a192c127ca42494a59b"
dependencies = [
"base64",
]
[[package]]
@ -2177,15 +2039,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "schannel"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3"
dependencies = [
"windows-sys 0.42.0",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
@ -2193,26 +2046,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "security-framework"
version = "2.8.2"
name = "sct"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254"
checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4"
dependencies = [
"bitflags",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4"
dependencies = [
"core-foundation-sys",
"libc",
"ring",
"untrusted",
]
[[package]]
@ -2253,11 +2093,11 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.92"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7434af0dc1cbd59268aa98b4c22c131c0584d2232f6fb166efb993e2832e896a"
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
dependencies = [
"itoa 1.0.5",
"itoa",
"ryu",
"serde",
]
@ -2278,7 +2118,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa 1.0.5",
"itoa",
"ryu",
"serde",
]
@ -2305,9 +2145,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.4.0"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"
dependencies = [
"libc",
]
@ -2326,9 +2166,9 @@ dependencies = [
[[package]]
name = "slab"
version = "0.4.7"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef"
checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d"
dependencies = [
"autocfg",
]
@ -2353,30 +2193,22 @@ dependencies = [
]
[[package]]
name = "syn"
version = "1.0.107"
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]]
name = "syn"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if",
"fastrand",
"libc",
"redox_syscall",
"remove_dir_all",
"winapi",
]
[[package]]
name = "termcolor"
version = "1.2.0"
@ -2428,10 +2260,11 @@ dependencies = [
[[package]]
name = "thread_local"
version = "1.1.4"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
dependencies = [
"cfg-if",
"once_cell",
]
@ -2492,20 +2325,21 @@ dependencies = [
]
[[package]]
name = "tokio-native-tls"
version = "0.3.0"
name = "tokio-rustls"
version = "0.23.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b"
checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59"
dependencies = [
"native-tls",
"rustls",
"tokio",
"webpki",
]
[[package]]
name = "tokio-util"
version = "0.7.4"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bb2e075f03b3d66d8d8785356224ba688d2906a371015e225beeb65ca92c740"
checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2"
dependencies = [
"bytes",
"futures-core",
@ -2526,9 +2360,9 @@ dependencies = [
[[package]]
name = "toml"
version = "0.7.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "772c1426ab886e7362aedf4abc9c0d1348a979517efedfc25862944d10137af0"
checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6"
dependencies = [
"serde",
"serde_spanned",
@ -2547,15 +2381,15 @@ dependencies = [
[[package]]
name = "toml_edit"
version = "0.19.1"
version = "0.19.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90a238ee2e6ede22fb95350acc78e21dc40da00bb66c0334bde83de4ed89424e"
checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825"
dependencies = [
"indexmap",
"nom8",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]]
@ -2614,14 +2448,29 @@ version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "tracing-wasm"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4575c663a174420fa2d78f4108ff68f65bf2fbb7dd89f33749b6e826b3626e07"
dependencies = [
"tracing",
"tracing-subscriber",
"wasm-bindgen",
]
[[package]]
name = "trust-dns-proto"
version = "0.22.0"
@ -2710,6 +2559,12 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "url"
version = "2.3.1"
@ -2737,12 +2592,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.4"
@ -2858,6 +2707,25 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "webpki"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.22.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87"
dependencies = [
"webpki",
]
[[package]]
name = "winapi"
version = "0.3.9"
@ -2970,6 +2838,15 @@ version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
[[package]]
name = "winnow"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658"
dependencies = [
"memchr",
]
[[package]]
name = "winreg"
version = "0.10.1"

View file

@ -9,18 +9,21 @@ version = "0.6.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
azalea-buf = {path = "../azalea-buf", version = "^0.6.0" }
azalea-crypto = {path = "../azalea-crypto", version = "^0.6.0" }
chrono = {version = "0.4.22", default-features = false}
azalea-buf = { path = "../azalea-buf", version = "^0.6.0" }
azalea-crypto = { path = "../azalea-crypto", version = "^0.6.0" }
chrono = { version = "0.4.22", default-features = false }
log = "0.4.17"
num-bigint = "0.4.3"
reqwest = {version = "0.11.12", features = ["json"]}
serde = {version = "1.0.145", features = ["derive"]}
reqwest = { version = "0.11.12", default-features = false, features = [
"json",
"rustls-tls",
] }
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0.86"
thiserror = "1.0.37"
tokio = {version = "1.24.2", features = ["fs"]}
uuid = {version = "^1.1.2", features = ["serde"]}
tokio = { version = "1.24.2", features = ["fs"] }
uuid = { version = "^1.1.2", features = ["serde"] }
[dev-dependencies]
env_logger = "0.9.3"
tokio = {version = "1.24.2", features = ["full"]}
tokio = { version = "1.24.2", features = ["full"] }

View file

@ -22,6 +22,8 @@ azalea-protocol = { path = "../azalea-protocol", version = "0.6.0" }
azalea-registry = { path = "../azalea-registry", version = "0.6.0" }
azalea-world = { path = "../azalea-world", version = "0.6.0" }
azalea-inventory = { path = "../azalea-inventory", version = "0.1.0" }
bevy_log = "0.9.1"
bevy_tasks = "0.9.1"
bevy_time = "0.9.1"
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
futures = "0.3.25"
@ -34,7 +36,3 @@ thiserror = "^1.0.34"
tokio = { version = "^1.24.2", features = ["sync"] }
typemap_rev = "0.3.0"
uuid = "^1.1.2"
bevy_tasks = "0.9.1"
[dev-dependencies]
env_logger = "0.9.1"

View file

@ -1,49 +0,0 @@
//! A simple bot that repeats chat messages sent by other players.
use azalea_client::{Account, Client, Event};
#[tokio::main]
async fn main() {
env_logger::init();
// deadlock detection, you can safely delete this block if you're not trying to
// debug deadlocks in azalea
{
use parking_lot::deadlock;
use std::thread;
use std::time::Duration;
thread::spawn(move || loop {
thread::sleep(Duration::from_secs(10));
let deadlocks = deadlock::check_deadlock();
if deadlocks.is_empty() {
continue;
}
println!("{} deadlocks detected", deadlocks.len());
for (i, threads) in deadlocks.iter().enumerate() {
println!("Deadlock #{i}");
for t in threads {
println!("Thread Id {:#?}", t.thread_id());
println!("{:#?}", t.backtrace());
}
}
});
}
let account = Account::offline("bot");
// or let account = Account::microsoft("email").await;
let (client, mut rx) = Client::join(&account, "localhost").await.unwrap();
while let Some(event) = rx.recv().await {
match &event {
Event::Chat(m) => {
if let (Some(sender), content) = m.split_sender_and_content() {
if sender == client.profile.name {
continue; // ignore our own messages
}
client.chat(&content);
};
}
_ => {}
}
}
}

View file

@ -19,7 +19,10 @@ use std::{
};
use uuid::Uuid;
use crate::{client::Client, local_player::SendPacketEvent};
use crate::{
client::Client,
local_player::{handle_send_packet_event, SendPacketEvent},
};
/// A chat packet, either a system message or a chat message.
#[derive(Debug, Clone, PartialEq)]
@ -155,15 +158,12 @@ impl Plugin for ChatPlugin {
app.add_event::<SendChatEvent>()
.add_event::<SendChatKindEvent>()
.add_event::<ChatReceivedEvent>()
.add_system(
handle_send_chat_event
.label("handle_send_chat_event")
.after("packet"),
)
.add_system(handle_send_chat_event.label("handle_send_chat_event"))
.add_system(
handle_send_chat_kind_event
.label("handle_send_chat_kind_event")
.after("handle_send_chat_event"),
.after(handle_send_chat_event)
.after(handle_send_packet_event),
);
}
}

View file

@ -21,7 +21,7 @@ use azalea_ecs::{
bundle::Bundle,
component::Component,
entity::Entity,
schedule::{IntoSystemDescriptor, Schedule, Stage, SystemSet},
schedule::{IntoSystemDescriptor, ReportExecutionOrderAmbiguities, Schedule, Stage, SystemSet},
AppTickExt,
};
use azalea_ecs::{ecs::Ecs, TickPlugin};
@ -50,6 +50,7 @@ use azalea_world::{
entity::{EntityPlugin, Local, WorldName},
PartialWorld, World, WorldContainer,
};
use bevy_log::LogPlugin;
use log::{debug, error};
use parking_lot::{Mutex, RwLock};
use std::{collections::HashMap, fmt::Debug, io, net::SocketAddr, sync::Arc};
@ -65,6 +66,9 @@ pub type ClientInformation = ServerboundClientInformationPacket;
/// To make a new client, use either [`azalea::ClientBuilder`] or
/// [`Client::join`].
///
/// Note that `Client` is inaccessible from systems (i.e. plugins), but you can
/// achieve everything that client can do with events.
///
/// [`azalea::ClientBuilder`]: https://docs.rs/azalea/latest/azalea/struct.ClientBuilder.html
#[derive(Clone)]
pub struct Client {
@ -205,14 +209,6 @@ impl Client {
let (packet_writer_sender, packet_writer_receiver) = mpsc::unbounded_channel();
let mut local_player = crate::local_player::LocalPlayer::new(
entity,
packet_writer_sender,
// default to an empty world, it'll be set correctly later when we
// get the login packet
Arc::new(RwLock::new(World::default())),
);
// start receiving packets
let packet_receiver = packet_handling::PacketReceiver {
packets: Arc::new(Mutex::new(Vec::new())),
@ -225,8 +221,16 @@ impl Client {
.clone()
.write_task(write_conn, packet_writer_receiver),
);
local_player.tasks.push(read_packets_task);
local_player.tasks.push(write_packets_task);
let local_player = crate::local_player::LocalPlayer::new(
entity,
packet_writer_sender,
// default to an empty world, it'll be set correctly later when we
// get the login packet
Arc::new(RwLock::new(World::default())),
read_packets_task,
write_packets_task,
);
ecs.entity_mut(entity).insert(JoinedClientBundle {
local_player,
@ -469,6 +473,8 @@ impl Client {
}
/// Get a HashMap of all the players in the tab list.
///
/// Internally, this fetches the `players` field in [`LocalPlayer`].
pub fn players(&mut self) -> HashMap<Uuid, PlayerInfo> {
self.local_player(&mut self.ecs.lock()).players.clone()
}
@ -495,36 +501,31 @@ impl Plugin for AzaleaPlugin {
app.add_tick_system_set(
SystemSet::new()
.with_system(send_position)
.with_system(update_in_loaded_chunk)
.with_system(send_position.after("ai_step"))
.with_system(update_in_loaded_chunk.before(send_position).after("travel"))
.with_system(
local_player_ai_step
.before("ai_step")
.after("sprint_listener"),
.before(azalea_physics::ai_step)
.label("ai_step"),
),
);
// fire the Death event when the player dies.
app.add_system(death_event.after("tick").after("packet"));
app.add_system(death_event);
// walk and sprint event listeners
app.add_system(walk_listener.label("walk_listener").before("travel"))
app.add_system(walk_listener.label("walk_listener"))
.add_system(
sprint_listener
.label("sprint_listener")
.before("travel")
.before("walk_listener"),
);
// add GameProfileComponent when we get an AddPlayerEvent
app.add_system(
retroactively_add_game_profile_component
.after("tick")
.after("packet"),
);
app.add_system(retroactively_add_game_profile_component.after("update_indexes"));
app.add_event::<SendPacketEvent>()
.add_system(handle_send_packet_event.after("tick").after("packet"));
.add_system(handle_send_packet_event);
app.init_resource::<WorldContainer>();
}
@ -545,6 +546,9 @@ pub fn init_ecs_app() -> App {
// you might be able to just drop the lock or put it in its own scope to fix
let mut app = App::new();
app.insert_resource(ReportExecutionOrderAmbiguities);
app.add_plugins(DefaultPlugins);
app
}
@ -607,9 +611,10 @@ pub struct DefaultPlugins;
impl PluginGroup for DefaultPlugins {
fn build(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add(LogPlugin::default())
.add(TickPlugin::default())
.add(AzaleaPlugin)
.add(PacketHandlerPlugin)
.add(AzaleaPlugin)
.add(EntityPlugin)
.add(PhysicsPlugin)
.add(EventPlugin)

View file

@ -2,18 +2,29 @@
use azalea_ecs::{
app::{App, CoreStage, Plugin},
component::Component,
entity::Entity,
event::EventReader,
system::Commands,
event::{EventReader, EventWriter},
query::Changed,
schedule::IntoSystemDescriptor,
system::{Commands, Query},
AppTickExt,
};
use derive_more::Deref;
use crate::client::JoinedClientBundle;
use crate::{client::JoinedClientBundle, movement::send_position, LocalPlayer};
pub struct DisconnectPlugin;
impl Plugin for DisconnectPlugin {
fn build(&self, app: &mut App) {
app.add_event::<DisconnectEvent>()
.add_system_to_stage(CoreStage::PostUpdate, handle_disconnect);
.add_system_to_stage(CoreStage::PostUpdate, handle_disconnect)
.add_tick_system(
update_read_packets_task_running_component
.before(disconnect_on_read_packets_ended)
.before(send_position),
)
.add_tick_system(disconnect_on_read_packets_ended);
}
}
@ -29,3 +40,28 @@ pub fn handle_disconnect(mut commands: Commands, mut events: EventReader<Disconn
commands.entity(*entity).remove::<JoinedClientBundle>();
}
}
#[derive(Component, Clone, Copy, Debug, Deref)]
pub struct ReadPacketsTaskRunning(bool);
fn update_read_packets_task_running_component(
mut commands: Commands,
local_player: Query<(Entity, &LocalPlayer)>,
) {
for (entity, local_player) in &local_player {
let running = !local_player.read_packets_task.is_finished();
commands
.entity(entity)
.insert(ReadPacketsTaskRunning(running));
}
}
fn disconnect_on_read_packets_ended(
local_player: Query<(Entity, &ReadPacketsTaskRunning), Changed<ReadPacketsTaskRunning>>,
mut disconnect_events: EventWriter<DisconnectEvent>,
) {
for (entity, &read_packets_task_running) in &local_player {
if !*read_packets_task_running {
disconnect_events.send(DisconnectEvent { entity });
}
}
}

View file

@ -7,7 +7,7 @@ use azalea_ecs::{
app::{App, Plugin},
component::Component,
event::EventReader,
query::{Added, Changed},
query::Added,
system::Query,
AppTickExt,
};
@ -21,7 +21,7 @@ use tokio::sync::mpsc;
use crate::{
chat::{ChatPacket, ChatReceivedEvent},
packet_handling::{
AddPlayerEvent, DeathEvent, KeepAliveEvent, PacketReceiver, RemovePlayerEvent,
AddPlayerEvent, DeathEvent, KeepAliveEvent, PacketEvent, RemovePlayerEvent,
UpdatePlayerEvent,
},
PlayerInfo,
@ -62,6 +62,23 @@ pub enum Event {
Chat(ChatPacket),
/// Happens 20 times per second, but only when the world is loaded.
Tick,
/// We received a packet from the server.
///
/// ```
/// # use azalea_client::Event;
/// # use azalea_protocol::packets::game::ClientboundGamePacket;
/// # async fn example(event: Event) {
/// # match event {
/// Event::Packet(packet) => match *packet {
/// ClientboundGamePacket::Login(_) => {
/// println!("login packet");
/// }
/// _ => {}
/// },
/// # _ => {}
/// # }
/// # }
/// ```
Packet(Arc<ClientboundGamePacket>),
/// A player joined the game (or more specifically, was added to the tab
/// list).
@ -133,13 +150,14 @@ fn tick_listener(query: Query<&LocalPlayerEvents>) {
}
}
fn packet_listener(query: Query<(&LocalPlayerEvents, &PacketReceiver), Changed<PacketReceiver>>) {
for (local_player_events, packet_receiver) in &query {
for packet in packet_receiver.packets.lock().iter() {
local_player_events
.send(Event::Packet(packet.clone().into()))
.unwrap();
}
fn packet_listener(query: Query<&LocalPlayerEvents>, mut events: EventReader<PacketEvent>) {
for event in events.iter() {
let local_player_events = query
.get(event.entity)
.expect("Non-localplayer entities shouldn't be able to receive add player events");
local_player_events
.send(Event::Packet(Arc::new(event.packet.clone())))
.unwrap();
}
}

View file

@ -1,4 +1,4 @@
use azalea_core::BlockPos;
use azalea_core::{BlockPos, Direction};
use azalea_ecs::{
app::{App, Plugin},
entity::Entity,
@ -7,7 +7,7 @@ use azalea_ecs::{
};
use azalea_protocol::packets::game::{
serverbound_interact_packet::InteractionHand,
serverbound_use_item_on_packet::ServerboundUseItemOnPacket,
serverbound_use_item_on_packet::{BlockHitResult, ServerboundUseItemOnPacket},
};
use log::warn;
@ -52,17 +52,25 @@ fn handle_block_interact_event(
query: Query<&LocalPlayer>,
) {
for event in events.iter() {
let Ok(local_player) = query.get(event.entity) else {
let Ok( local_player) = query.get(event.entity) else {
warn!("Sent BlockInteractEvent for entity that isn't LocalPlayer");
continue;
};
// TODO: check to make sure we're within the world border
local_player.write_packet(ServerboundUseItemOnPacket {
hand: InteractionHand::MainHand,
block_hit: BlockHitResult,
sequence: 0,
})
local_player.write_packet(
ServerboundUseItemOnPacket {
hand: InteractionHand::MainHand,
block_hit: BlockHitResult {
block_pos: event.position,
direction: Direction::Up,
location: event.position.center(),
inside: false,
},
sequence: 0,
}
.get(),
)
}
}

View file

@ -46,9 +46,11 @@ pub struct LocalPlayer {
/// world. (Only relevant if you're using a shared world, i.e. a swarm)
pub world: Arc<RwLock<World>>,
/// A list of async tasks that are running and will stop running when this
/// LocalPlayer is dropped or disconnected with [`Self::disconnect`]
pub(crate) tasks: Vec<JoinHandle<()>>,
/// A task that reads packets from the server. The client is disconnected
/// when this task ends.
pub(crate) read_packets_task: JoinHandle<()>,
/// A task that writes packets from the server.
pub(crate) write_packets_task: JoinHandle<()>,
}
/// Component for entities that can move and sprint. Usually only in
@ -87,6 +89,8 @@ impl LocalPlayer {
entity: Entity,
packet_writer: mpsc::UnboundedSender<ServerboundGamePacket>,
world: Arc<RwLock<World>>,
read_packets_task: JoinHandle<()>,
write_packets_task: JoinHandle<()>,
) -> Self {
let client_information = ClientInformation::default();
@ -102,12 +106,13 @@ impl LocalPlayer {
Some(entity),
))),
tasks: Vec::new(),
read_packets_task,
write_packets_task,
}
}
/// Write a packet directly to the server.
pub fn write_packet(&mut self, packet: ServerboundGamePacket) {
pub fn write_packet(&self, packet: ServerboundGamePacket) {
self.packet_writer
.send(packet)
.expect("write_packet shouldn't be able to be called if the connection is closed");
@ -117,9 +122,8 @@ impl LocalPlayer {
impl Drop for LocalPlayer {
/// Stop every active task when the `LocalPlayer` is dropped.
fn drop(&mut self) {
for task in &self.tasks {
task.abort();
}
self.read_packets_task.abort();
self.write_packets_task.abort();
}
}
@ -180,7 +184,7 @@ pub fn handle_send_packet_event(
mut query: Query<&mut LocalPlayer>,
) {
for event in send_packet_events.iter() {
if let Ok(mut local_player) = query.get_mut(event.entity) {
if let Ok(local_player) = query.get_mut(event.entity) {
local_player.write_packet(event.packet.clone());
}
}

File diff suppressed because it is too large Load diff

View file

@ -13,12 +13,16 @@ use crate::{packet_handling::AddPlayerEvent, GameProfileComponent};
/// A player in the tab list.
#[derive(Debug, Clone)]
pub struct PlayerInfo {
/// Information about the player's Minecraft account, including their
/// username.
pub profile: GameProfile,
/// The player's UUID.
pub uuid: Uuid,
pub gamemode: GameType,
pub latency: i32,
/// The player's display name in the tab list.
/// The player's display name in the tab list, but only if it's different
/// from the player's normal username. Use `player_info.profile.name` to get
/// the player's actual username.
pub display_name: Option<FormattedText>,
}

View file

@ -19,7 +19,7 @@ pub fn derive_resource(input: TokenStream) -> TokenStream {
let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl();
TokenStream::from(quote! {
impl #impl_generics #azalea_ecs_path::system::BevyResource for #struct_name #type_generics #where_clause {
impl #impl_generics #azalea_ecs_path::system::_BevyResource for #struct_name #type_generics #where_clause {
}
})
}
@ -44,7 +44,7 @@ pub fn derive_component(input: TokenStream) -> TokenStream {
let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl();
TokenStream::from(quote! {
impl #impl_generics #azalea_ecs_path::component::BevyComponent for #struct_name #type_generics #where_clause {
impl #impl_generics #azalea_ecs_path::component::_BevyComponent for #struct_name #type_generics #where_clause {
type Storage = #storage;
}
})

View file

@ -151,13 +151,13 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
match field_kind {
BundleFieldKind::Component => {
field_component_ids.push(quote! {
<#field_type as #ecs_path::bundle::BevyBundle>::component_ids(components, storages, &mut *ids);
<#field_type as #ecs_path::bundle::_BevyBundle>::component_ids(components, storages, &mut *ids);
});
field_get_components.push(quote! {
self.#field.get_components(&mut *func);
});
field_from_components.push(quote! {
#field: <#field_type as #ecs_path::bundle::BevyBundle>::from_components(ctx, &mut *func),
#field: <#field_type as #ecs_path::bundle::_BevyBundle>::from_components(ctx, &mut *func),
});
}
@ -174,7 +174,7 @@ pub fn derive_bundle(input: TokenStream) -> TokenStream {
TokenStream::from(quote! {
/// SAFETY: ComponentId is returned in field-definition-order. [from_components] and [get_components] use field-definition-order
unsafe impl #impl_generics #ecs_path::bundle::BevyBundle for #struct_name #ty_generics #where_clause {
unsafe impl #impl_generics #ecs_path::bundle::_BevyBundle for #struct_name #ty_generics #where_clause {
fn component_ids(
components: &mut #ecs_path::component::Components,
storages: &mut #ecs_path::storage::Storages,
@ -488,7 +488,9 @@ pub fn derive_stage_label(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as DeriveInput);
let mut trait_path = azalea_ecs_path();
trait_path.segments.push(format_ident!("schedule").into());
trait_path.segments.push(format_ident!("StageLabel").into());
trait_path
.segments
.push(format_ident!("_BevyStageLabel").into());
derive_label(input, &trait_path, "stage_label")
}

View file

@ -38,6 +38,7 @@ impl Default for BevyManifest {
impl BevyManifest {
pub fn maybe_get_path(&self, name: &str) -> Option<syn::Path> {
const AZALEA: &str = "azalea";
const AZALEA_ECS: &str = "azalea_ecs";
const BEVY_ECS: &str = "bevy_ecs";
const BEVY: &str = "bevy";
@ -57,6 +58,8 @@ impl BevyManifest {
return Some(Self::parse_str(dep_package(dep).unwrap_or(name)));
} else if let Some(dep) = deps.get(AZALEA) {
dep_package(dep).unwrap_or(AZALEA)
} else if let Some(dep) = deps.get(AZALEA_ECS) {
dep_package(dep).unwrap_or(AZALEA_ECS)
} else if let Some(dep) = deps.get(BEVY_ECS) {
dep_package(dep).unwrap_or(BEVY_ECS)
} else if let Some(dep) = deps.get(BEVY) {

View file

@ -29,14 +29,14 @@ pub mod component {
// we do this because re-exporting Component would re-export the macro as well,
// which is bad (since we have our own Component macro)
// instead, we have to do this so Component is a trait alias and the original
// impl-able trait is still available as BevyComponent
// impl-able trait is still available as _BevyComponent
pub trait Component = bevy_ecs::component::Component;
pub use bevy_ecs::component::Component as BevyComponent;
pub use bevy_ecs::component::Component as _BevyComponent;
}
pub mod bundle {
pub use azalea_ecs_macros::Bundle;
pub trait Bundle = bevy_ecs::bundle::Bundle;
pub use bevy_ecs::bundle::Bundle as BevyBundle;
pub use bevy_ecs::bundle::Bundle as _BevyBundle;
}
pub mod system {
pub use azalea_ecs_macros::Resource;
@ -44,10 +44,19 @@ pub mod system {
Command, Commands, EntityCommands, Query, Res, ResMut, SystemState,
};
pub trait Resource = bevy_ecs::system::Resource;
pub use bevy_ecs::system::Resource as BevyResource;
pub use bevy_ecs::system::Resource as _BevyResource;
}
pub mod schedule {
pub use azalea_ecs_macros::StageLabel;
pub use bevy_ecs::schedule::{
IntoRunCriteria, IntoSystemDescriptor, ReportExecutionOrderAmbiguities, Schedule, Stage,
SystemSet, SystemStage,
};
pub trait StageLabel = bevy_ecs::schedule::StageLabel;
pub use bevy_ecs::schedule::StageLabel as _BevyStageLabel;
}
pub use bevy_app as app;
pub use bevy_ecs::{entity, event, ptr, query, schedule, storage};
pub use bevy_ecs::{entity, event, ptr, query, storage};
use app::{App, CoreStage, Plugin};
use bevy_ecs::schedule::*;

View file

@ -10,7 +10,7 @@ use azalea_ecs::{
entity::Entity,
event::{EventReader, EventWriter},
query::With,
schedule::{IntoSystemDescriptor, SystemSet},
schedule::IntoSystemDescriptor,
system::{Query, Res},
AppTickExt,
};
@ -30,18 +30,12 @@ impl Plugin for PhysicsPlugin {
.add_system(
force_jump_listener
.label("force_jump_listener")
.after("ai_step"),
.after("walk_listener")
.after("sprint_listener")
.before(azalea_world::entity::update_bounding_box),
)
.add_tick_system_set(
SystemSet::new()
.with_system(ai_step.label("ai_step"))
.with_system(
travel
.label("travel")
.after("ai_step")
.after("force_jump_listener"),
),
);
.add_tick_system(travel.label("travel").after(ai_step))
.add_tick_system(ai_step.label("ai_step"));
}
}

View file

@ -79,10 +79,7 @@ impl Display for ServerAddress {
#[cfg(test)]
mod tests {
use std::{
io::Cursor,
time::{SystemTime, UNIX_EPOCH},
};
use std::io::Cursor;
use crate::{
packets::{

View file

@ -15,7 +15,7 @@ pub struct ServerboundClientInformationPacket {
/// Whether the messages sent from the server should have colors. Note that
/// many servers ignore this and always send colored messages.
pub chat_colors: bool,
pub model_customisation: ModelCustomization,
pub model_customization: ModelCustomization,
pub main_hand: HumanoidArm,
pub text_filtering_enabled: bool,
/// Whether the client should show up as "Anonymous Player" in the server
@ -30,7 +30,7 @@ impl Default for ServerboundClientInformationPacket {
view_distance: 8,
chat_visibility: ChatVisibility::default(),
chat_colors: true,
model_customisation: ModelCustomization::default(),
model_customization: ModelCustomization::default(),
main_hand: HumanoidArm::Right,
text_filtering_enabled: false,
allows_listing: false,
@ -149,7 +149,7 @@ mod tests {
view_distance: 24,
chat_visibility: ChatVisibility::Hidden,
chat_colors: false,
model_customisation: ModelCustomization {
model_customization: ModelCustomization {
cape: false,
jacket: false,
left_sleeve: true,

View file

@ -264,6 +264,7 @@ mod tests {
use crate::packets::game::ClientboundGamePacket;
use std::io::Cursor;
#[test]
fn test_read_packet() {
let mut buf: Cursor<&[u8]> = Cursor::new(&[
56, 64, 85, 58, 141, 138, 71, 146, 193, 64, 88, 0, 0, 0, 0, 0, 0, 64, 60, 224, 105, 34,

View file

@ -9,14 +9,16 @@ version = "0.6.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
azalea-block = {path = "../azalea-block", default-features = false, version = "^0.6.0"}
azalea-buf = {path = "../azalea-buf", version = "^0.6.0"}
azalea-chat = {path = "../azalea-chat", version = "^0.6.0"}
azalea-core = {path = "../azalea-core", version = "^0.6.0", features = ["bevy_ecs"]}
azalea-ecs = {version = "0.6.0", path = "../azalea-ecs"}
azalea-nbt = {path = "../azalea-nbt", version = "^0.6.0"}
azalea-registry = {path = "../azalea-registry", version = "^0.6.0"}
derive_more = {version = "0.99.17", features = ["deref", "deref_mut"]}
azalea-block = { path = "../azalea-block", default-features = false, version = "^0.6.0" }
azalea-buf = { path = "../azalea-buf", version = "^0.6.0" }
azalea-chat = { path = "../azalea-chat", version = "^0.6.0" }
azalea-core = { path = "../azalea-core", version = "^0.6.0", features = [
"bevy_ecs",
] }
azalea-ecs = { version = "0.6.0", path = "../azalea-ecs" }
azalea-nbt = { path = "../azalea-nbt", version = "^0.6.0" }
azalea-registry = { path = "../azalea-registry", version = "^0.6.0" }
derive_more = { version = "0.99.17", features = ["deref", "deref_mut"] }
enum-as-inner = "0.5.1"
log = "0.4.17"
nohash-hasher = "0.2.0"

View file

@ -36,52 +36,45 @@ use super::Local;
pub struct EntityPlugin;
impl Plugin for EntityPlugin {
fn build(&self, app: &mut App) {
app.add_system_set(
SystemSet::new()
.after("tick")
.after("packet")
.with_system(update_entity_chunk_positions)
.with_system(remove_despawned_entities_from_indexes)
.with_system(update_bounding_box)
.with_system(add_dead)
.with_system(
add_updates_received
.after("deduplicate_entities")
.after("deduplicate_local_entities")
.label("add_updates_received"),
)
.with_system(
update_uuid_index
.label("update_uuid_index")
.after("deduplicate_local_entities")
.after("deduplicate_entities"),
)
.with_system(debug_detect_updates_received_on_local_entities)
.with_system(
update_entity_by_id_index
.label("update_entity_by_id_index")
.after("deduplicate_entities"),
)
.with_system(debug_new_entity),
// entities get added pre-update
// added to indexes during update (done by this plugin)
// modified during update
// despawned post-update (done by this plugin)
app.add_system_set_to_stage(
CoreStage::PreUpdate,
SystemSet::new().with_system(remove_despawned_entities_from_indexes),
)
.add_system_set_to_stage(
CoreStage::PostUpdate,
SystemSet::new()
.with_system(deduplicate_entities.label("deduplicate_entities"))
.with_system(
deduplicate_local_entities
.label("deduplicate_local_entities")
.before("update_uuid_index")
.before("update_entity_by_id_index"),
),
.with_system(deduplicate_local_entities.label("deduplicate_entities")),
)
.add_system_set(
SystemSet::new()
.with_system(update_entity_chunk_positions)
.with_system(update_uuid_index.label("update_indexes"))
.with_system(update_entity_by_id_index.label("update_indexes")),
)
.add_system_set(
SystemSet::new()
.with_system(add_updates_received.label("add_updates_received"))
.with_system(debug_new_entity)
.with_system(debug_detect_updates_received_on_local_entities)
.with_system(add_dead)
.with_system(update_bounding_box),
)
.init_resource::<EntityInfos>();
}
}
fn debug_new_entity(query: Query<Entity, Added<MinecraftEntityId>>) {
for entity in query.iter() {
debug!("new entity: {:?}", entity);
fn debug_new_entity(query: Query<(Entity, Option<&Local>), Added<MinecraftEntityId>>) {
for (entity, local) in query.iter() {
if local.is_some() {
debug!("new local entity: {:?}", entity);
} else {
debug!("new entity: {:?}", entity);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufWritable};
use azalea_buf::{BufReadError, McBufReadable, McBufVarReadable, McBufVarWritable, McBufWritable};
use std::io::{Cursor, Write};
use crate::BitStorage;
@ -227,13 +227,13 @@ impl McBufWritable for Palette {
fn write_into(&self, buf: &mut impl Write) -> Result<(), std::io::Error> {
match self {
Palette::SingleValue(value) => {
value.write_into(buf)?;
value.var_write_into(buf)?;
}
Palette::Linear(values) => {
values.write_into(buf)?;
values.var_write_into(buf)?;
}
Palette::Hashmap(values) => {
values.write_into(buf)?;
values.var_write_into(buf)?;
}
Palette::Global => {}
}

View file

@ -82,8 +82,8 @@ pub fn deduplicate_entities(
}
commands.entity(new_entity).despawn();
info!(
"Entity with id {id:?} / {new_entity:?} already existed in the world, merging it with {old_entity:?}"
);
"Entity with id {id:?} / {new_entity:?} already existed in the world, merging it with {old_entity:?}"
);
break;
}
} else {
@ -127,15 +127,20 @@ pub fn deduplicate_local_entities(
pub fn update_uuid_index(
mut entity_infos: ResMut<EntityInfos>,
query: Query<(Entity, &EntityUuid), Changed<EntityUuid>>,
query: Query<(Entity, &EntityUuid, Option<&Local>), Changed<EntityUuid>>,
) {
for (entity, &uuid) in query.iter() {
for (entity, &uuid, local) in query.iter() {
// only add it if it doesn't already exist in
// entity_infos.entity_by_uuid
// if entity_infos.entity_by_uuid.contains_key(&uuid) {
// warn!("Entity with UUID {uuid:?} already existed in the world, not adding
// to index (ecs id: {entity:?})", uuid=*uuid); continue;
// }
if local.is_none() {
if let Some(old_entity) = entity_infos.entity_by_uuid.get(&uuid) {
debug!(
"Entity with UUID {uuid:?} already existed in the world, not adding to
index (old ecs id: {old_entity:?} / new ecs id: {entity:?})"
);
continue;
}
}
entity_infos.entity_by_uuid.insert(*uuid, entity);
}
}
@ -208,18 +213,24 @@ impl Default for PartialWorld {
/// System to keep the entity_by_id index up-to-date.
pub fn update_entity_by_id_index(
mut query: Query<(Entity, &MinecraftEntityId, &WorldName), Changed<MinecraftEntityId>>,
mut query: Query<
(Entity, &MinecraftEntityId, &WorldName, Option<&Local>),
Changed<MinecraftEntityId>,
>,
world_container: Res<WorldContainer>,
) {
for (entity, id, world_name) in query.iter_mut() {
for (entity, id, world_name, local) in query.iter_mut() {
let world_lock = world_container.get(world_name).unwrap();
let mut world = world_lock.write();
// if let Some(old_entity) = world.entity_by_id.get(id) {
// warn!(
// "Entity with ID {id:?} already existed in the world, not adding to
// index (old ecs id: {old_entity:?} / new ecs id: {entity:?})" );
// continue;
// }
if local.is_none() {
if let Some(old_entity) = world.entity_by_id.get(id) {
debug!(
"Entity with ID {id:?} already existed in the world, not adding to
index (old ecs id: {old_entity:?} / new ecs id: {entity:?})"
);
continue;
}
}
world.entity_by_id.insert(*id, entity);
debug!("Added {entity:?} to {world_name:?} with {id:?}.");
}

View file

@ -36,5 +36,3 @@ thiserror = "^1.0.37"
tokio = "^1.24.2"
uuid = "1.2.2"
[dev-dependencies]
env_logger = "^0.10.0"

View file

@ -83,4 +83,25 @@ Also note that just because something is an entity in the ECS doesn't mean that
See the [Bevy Cheatbook](https://bevy-cheatbook.github.io/programming/ecs-intro.html) to learn more about Bevy ECS (and the ECS paradigm in general).
# Debugging
Azalea uses several relatively complex features of Rust, which may make debugging certain issues more tricky if you're not familiar with them.
## Logging
One of the most useful tools for debugging issues is logging. The default log level is `info`, but you can make it show more or less information by changing the log level. Enabling logging is done with `RUST_LOG=debug cargo run` on Linux/bash or `set RUST_LOG=debug && cargo run` on Windows. The log levels are `trace`, `debug`, `info`, `warn`, and `error`, in ascending priority.
If it's a crash/panic and you believe it has to do with parsing a packet, you might want to set the level to `trace` since that'll make it show the first few hundred bytes of every packet received. This may produce a lot of logs, so pipe it into a file with `&> azalea.log` (on Linux).
Note: If you get a `SetLoggerError`, it's because you have multiple loggers. Azalea comes with a logger by default, see [`bevy_log`] for more information.
## Deadlocks
If your code is simply hanging, it might be a deadlock. Copy the deadlock block in [`azalea/examples/testbot.rs`](https://github.com/mat-1/azalea/blob/main/azalea/examples/testbot.rs) to the beginning of your code and it'll print a long backtrace if a deadlock is detected.
## Backtraces
Backtraces are also useful, though they're sometimes hard to read and don't always contain the actual location of the error. Run your code with `RUST_BACKTRACE=1` to enable full backtraces. If it's very long, often searching for the keyword "azalea" will help you filter out unrelated things and find the actual source of the issue.
[`azalea_client`]: https://docs.rs/azalea-client
[`bevy_log`]: https://docs.rs/bevy_log

View file

@ -4,8 +4,6 @@ use azalea::prelude::*;
#[tokio::main]
async fn main() {
env_logger::init();
let account = Account::offline("bot");
// or let account = Account::microsoft("email").await;

View file

@ -10,6 +10,7 @@ use azalea::pathfinder::BlockPosGoal;
use azalea::{prelude::*, swarm::prelude::*, BlockPos, GameProfileComponent, WalkDirection};
use azalea::{Account, Client, Event};
use azalea_protocol::packets::game::serverbound_client_command_packet::ServerboundClientCommandPacket;
use azalea_protocol::packets::game::ClientboundGamePacket;
use std::time::Duration;
#[derive(Default, Clone, Component)]
@ -20,13 +21,10 @@ struct SwarmState {}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
env_logger::init();
{
use parking_lot::deadlock;
use std::thread;
use std::time::Duration;
// Create a background thread which checks for deadlocks every 10s
thread::spawn(move || loop {
thread::sleep(Duration::from_secs(10));
@ -49,7 +47,7 @@ async fn main() -> anyhow::Result<()> {
let mut accounts = Vec::new();
let mut states = Vec::new();
for i in 0..1 {
for i in 0..5 {
accounts.push(Account::offline(&format!("bot{i}")));
states.push(State::default());
}
@ -157,6 +155,12 @@ async fn handle(mut bot: Client, event: Event, _state: State) -> anyhow::Result<
action: azalea_protocol::packets::game::serverbound_client_command_packet::Action::PerformRespawn,
}.get());
}
Event::Packet(packet) => match *packet {
ClientboundGamePacket::Login(_) => {
println!("login packet");
}
_ => {}
},
_ => {}
}

View file

@ -20,9 +20,13 @@ impl Plugin for BotPlugin {
fn build(&self, app: &mut App) {
app.add_event::<LookAtEvent>()
.add_event::<JumpEvent>()
.add_system(insert_bot.before("deduplicate_entities"))
.add_system(look_at_listener)
.add_system(jump_listener.label("jump_listener").before("ai_step"))
.add_system(insert_bot)
.add_system(
look_at_listener
.before("force_jump_listener")
.before(azalea_world::entity::update_bounding_box),
)
.add_system(jump_listener.label("jump_listener"))
.add_tick_system(stop_jumping.after("ai_step"));
}
}

View file

@ -36,10 +36,10 @@ impl Plugin for PathfinderPlugin {
fn build(&self, app: &mut App) {
app.add_event::<GotoEvent>()
.add_event::<PathFoundEvent>()
.add_tick_system(tick_execute_path.before("walk_listener"))
.add_tick_system(tick_execute_path.before("ai_step"))
.add_system(goto_listener)
.add_system(add_default_pathfinder.after("deduplicate_entities"))
.add_system(handle_tasks)
.add_system(add_default_pathfinder)
.add_system(handle_tasks.before(path_found_listener))
.add_system(path_found_listener);
}
}

View file

@ -162,14 +162,14 @@ impl From<EntityDataValue> for UpdateMetadataError {
metadata_type_data = metadata_types[type_id]
rust_type = metadata_type_data['type']
code.append(f'#[derive(Component, Deref, DerefMut)]')
code.append(f'#[derive(Component, Deref, DerefMut, Clone)]')
code.append(f'pub struct {struct_name}(pub {rust_type});')
else:
# if it's a bitfield just make a struct for each bit
for mask, name in name_or_bitfield.items():
name = maybe_rename_field(name, index)
struct_name = upper_first_letter(to_camel_case(name))
code.append(f'#[derive(Component, Deref, DerefMut)]')
code.append(f'#[derive(Component, Deref, DerefMut, Clone, Copy)]')
code.append(f'pub struct {struct_name}(pub bool);')
# add the entity struct and Bundle struct

View file

@ -54,7 +54,7 @@ def determine_python_command():
def try_python_command(version):
return os.system(f'{version} --version') == 0
for version in ('python3.9', 'python3.8', 'python3', 'python'):
for version in (sys.executable, 'python3.9', 'python3.8', 'python3', 'python'):
if try_python_command(version):
python_command = version
return version