Compare commits
14 Commits
c19af70274
...
e81fab7bf8
Author | SHA1 | Date | |
---|---|---|---|
e81fab7bf8 | |||
dda43999fe | |||
029a80456d | |||
8ad28a43c2 | |||
6600edabe6 | |||
c2d1b415aa | |||
4e5b076b60 | |||
6d8ce9b2be | |||
09543b2dcd | |||
b2d8618bba | |||
2b2cf1d069 | |||
5c052de95d | |||
31e962fb9f | |||
18540aa223 |
199
Cargo.lock
generated
199
Cargo.lock
generated
@ -961,25 +961,6 @@ version = "1.10.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
|
checksum = "f61dac84819c6588b558454b194026eb1f09c293b9036ae9b159e74e73ab6cf9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bzip2"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "49ecfb22d906f800d4fe833b6282cf4dc1c298f5057ca0b5445e5c209735ca47"
|
|
||||||
dependencies = [
|
|
||||||
"bzip2-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bzip2-sys"
|
|
||||||
version = "0.1.13+1.0.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "225bff33b2141874fe80d71e07d6eec4f85c5c216453dd96388240f96e1acc14"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"pkg-config",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "castaway"
|
name = "castaway"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
@ -1206,12 +1187,6 @@ dependencies = [
|
|||||||
"tiny-keccak",
|
"tiny-keccak",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "constant_time_eq"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cpufeatures"
|
name = "cpufeatures"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@ -1221,21 +1196,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crc"
|
|
||||||
version = "3.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "69e6e4d7b33a94f0991c26729976b10ebde1d34c3ee82408fb536164fa10d636"
|
|
||||||
dependencies = [
|
|
||||||
"crc-catalog",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crc-catalog"
|
|
||||||
version = "2.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.4.2"
|
version = "1.4.2"
|
||||||
@ -1302,12 +1262,6 @@ version = "2.8.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
|
checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deflate64"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "da692b8d1080ea3045efaab14434d40468c3d8657e42abddfffca87b428f4c1b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "der"
|
name = "der"
|
||||||
version = "0.7.9"
|
version = "0.7.9"
|
||||||
@ -1319,15 +1273,6 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deranged"
|
|
||||||
version = "0.3.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4"
|
|
||||||
dependencies = [
|
|
||||||
"powerfmt",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "derive_arbitrary"
|
name = "derive_arbitrary"
|
||||||
version = "1.4.1"
|
version = "1.4.1"
|
||||||
@ -1467,10 +1412,12 @@ dependencies = [
|
|||||||
"hyper",
|
"hyper",
|
||||||
"hyper-util",
|
"hyper-util",
|
||||||
"log",
|
"log",
|
||||||
|
"mimalloc",
|
||||||
"mlua",
|
"mlua",
|
||||||
"ncr",
|
"ncr",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"smallvec",
|
||||||
"tokio",
|
"tokio",
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
@ -2204,6 +2151,16 @@ version = "0.2.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libmimalloc-sys"
|
||||||
|
version = "0.1.39"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "23aa6811d3bd4deb8a84dde645f943476d13b248d818edcf8ce0b2f37f036b44"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libz-sys"
|
name = "libz-sys"
|
||||||
version = "1.1.21"
|
version = "1.1.21"
|
||||||
@ -2238,12 +2195,6 @@ dependencies = [
|
|||||||
"scopeguard",
|
"scopeguard",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lockfree-object-pool"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9374ef4228402d4b7e403e5838cb880d9ee663314b0a900d5a6aabf0c213552e"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.26"
|
version = "0.4.26"
|
||||||
@ -2259,16 +2210,6 @@ dependencies = [
|
|||||||
"linked-hash-map",
|
"linked-hash-map",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lzma-rs"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "297e814c836ae64db86b36cf2a557ba54368d03f6afcd7d947c266692f71115e"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder",
|
|
||||||
"crc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "matchers"
|
name = "matchers"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -2300,6 +2241,15 @@ version = "2.7.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mimalloc"
|
||||||
|
version = "0.1.43"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68914350ae34959d83f732418d51e2427a794055d0b9529f48259ac07af65633"
|
||||||
|
dependencies = [
|
||||||
|
"libmimalloc-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
@ -2476,12 +2426,6 @@ dependencies = [
|
|||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-conv"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-format"
|
name = "num-format"
|
||||||
version = "0.4.4"
|
version = "0.4.4"
|
||||||
@ -2596,7 +2540,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
|
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"digest",
|
"digest",
|
||||||
"hmac",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2713,12 +2656,6 @@ dependencies = [
|
|||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "powerfmt"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.20"
|
version = "0.2.20"
|
||||||
@ -3208,12 +3145,6 @@ dependencies = [
|
|||||||
"rand_core",
|
"rand_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simd-adler32"
|
|
||||||
version = "0.3.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simd_cesu8"
|
name = "simd_cesu8"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@ -3442,25 +3373,6 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time"
|
|
||||||
version = "0.3.39"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8"
|
|
||||||
dependencies = [
|
|
||||||
"deranged",
|
|
||||||
"num-conv",
|
|
||||||
"powerfmt",
|
|
||||||
"serde",
|
|
||||||
"time-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time-core"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tiny-keccak"
|
name = "tiny-keccak"
|
||||||
version = "2.0.2"
|
version = "2.0.2"
|
||||||
@ -4183,20 +4095,6 @@ name = "zeroize"
|
|||||||
version = "1.8.1"
|
version = "1.8.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||||
dependencies = [
|
|
||||||
"zeroize_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zeroize_derive"
|
|
||||||
version = "1.4.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerovec"
|
name = "zerovec"
|
||||||
@ -4226,67 +4124,12 @@ version = "2.2.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b280484c454e74e5fff658bbf7df8fdbe7a07c6b2de4a53def232c15ef138f3a"
|
checksum = "b280484c454e74e5fff658bbf7df8fdbe7a07c6b2de4a53def232c15ef138f3a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
"bzip2",
|
|
||||||
"constant_time_eq",
|
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
"deflate64",
|
|
||||||
"displaydoc",
|
"displaydoc",
|
||||||
"flate2",
|
"flate2",
|
||||||
"hmac",
|
|
||||||
"indexmap 2.7.1",
|
"indexmap 2.7.1",
|
||||||
"lzma-rs",
|
|
||||||
"memchr",
|
"memchr",
|
||||||
"pbkdf2",
|
|
||||||
"rand",
|
|
||||||
"sha1",
|
|
||||||
"thiserror 2.0.11",
|
"thiserror 2.0.11",
|
||||||
"time",
|
|
||||||
"zeroize",
|
|
||||||
"zopfli",
|
|
||||||
"zstd",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zopfli"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e5019f391bac5cf252e93bbcc53d039ffd62c7bfb7c150414d61369afe57e946"
|
|
||||||
dependencies = [
|
|
||||||
"bumpalo",
|
|
||||||
"crc32fast",
|
|
||||||
"lockfree-object-pool",
|
|
||||||
"log",
|
|
||||||
"once_cell",
|
|
||||||
"simd-adler32",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zstd"
|
|
||||||
version = "0.13.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a"
|
|
||||||
dependencies = [
|
|
||||||
"zstd-safe",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zstd-safe"
|
|
||||||
version = "7.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f3051792fbdc2e1e143244dc28c60f73d8470e93f3f9cbd0ead44da5ed802722"
|
|
||||||
dependencies = [
|
|
||||||
"zstd-sys",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zstd-sys"
|
|
||||||
version = "2.0.14+zstd.1.5.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8fb060d4926e4ac3a3ad15d864e99ceb5f343c6b34f5bd6d81ae6ed417311be5"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"pkg-config",
|
|
||||||
]
|
]
|
||||||
|
@ -32,12 +32,18 @@ http-body-util = "0"
|
|||||||
hyper = { version = "1", features = ["server"] }
|
hyper = { version = "1", features = ["server"] }
|
||||||
hyper-util = "0"
|
hyper-util = "0"
|
||||||
log = { version = "0" }
|
log = { version = "0" }
|
||||||
|
mimalloc = { version = "0", optional = true }
|
||||||
mlua = { version = "0", features = ["async", "luajit", "send"] }
|
mlua = { version = "0", features = ["async", "luajit", "send"] }
|
||||||
ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] }
|
ncr = { version = "0", features = ["cfb8", "ecb", "gcm"] }
|
||||||
parking_lot = "0"
|
parking_lot = "0"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
smallvec = { version = "1", features = ["write"] }
|
||||||
tokio = { version = "1", features = ["macros"] }
|
tokio = { version = "1", features = ["macros"] }
|
||||||
zip = "2"
|
zip = { version = "2", default-features = false, features = [
|
||||||
|
"deflate-flate2",
|
||||||
|
"flate2",
|
||||||
|
] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
console-subscriber = ["dep:console-subscriber"]
|
console-subscriber = ["dep:console-subscriber"]
|
||||||
|
mimalloc = ["dep:mimalloc"]
|
||||||
|
2
build.rs
2
build.rs
@ -1,3 +1,3 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
built::write_built_file().unwrap();
|
built::write_built_file().expect("appropriate environment variables should have been set");
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
Server = "localhost"
|
Server = "localhost"
|
||||||
Username = "ErrorNoWatcher"
|
Username = "ErrorNoWatcher"
|
||||||
|
HttpAddress = "127.0.0.1:8080"
|
||||||
Owners = { "ErrorNoInternet" }
|
Owners = { "ErrorNoInternet" }
|
||||||
|
|
||||||
for _, module in ipairs({
|
for _, module in ipairs({
|
||||||
|
"lib",
|
||||||
"automation",
|
"automation",
|
||||||
"enum",
|
"enum",
|
||||||
"events",
|
"events",
|
||||||
"inventory",
|
"inventory",
|
||||||
"lib",
|
|
||||||
"movement",
|
"movement",
|
||||||
"utils",
|
"utils",
|
||||||
}) do
|
}) do
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Center = { x = 0, y = 64, z = 0 }
|
Center = { x = 0, y = 64, z = 0 }
|
||||||
Radius = 100
|
Radius = 100
|
||||||
Whitelist = Owners
|
Whitelist = table.shallow_copy(Owners)
|
||||||
Ticks = -1
|
Ticks = -1
|
||||||
|
|
||||||
function check_radius()
|
function check_radius()
|
||||||
|
@ -145,7 +145,7 @@ function interact_bed()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
client:go_to(bed, { type = REACH_BLOCK_POS_GOAL, options = { without_mining = true } })
|
client:go_to({ position = bed, radius = 2 }, { type = RADIUS_GOAL, options = { without_mining = true } })
|
||||||
while client.pathfinder.is_calculating or client.pathfinder.is_executing do
|
while client.pathfinder.is_calculating or client.pathfinder.is_executing do
|
||||||
sleep(500)
|
sleep(500)
|
||||||
end
|
end
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
use crate::build_info;
|
use crate::build_info;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use std::{net::SocketAddr, path::PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
/// A Minecraft utility bot
|
/// A Minecraft utility bot
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version = build_info::version_formatted())]
|
#[command(version = build_info::version_formatted())]
|
||||||
pub struct Arguments {
|
pub struct Arguments {
|
||||||
/// Path to main Lua file
|
/// Path to Lua entrypoint
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
pub script: Option<PathBuf>,
|
pub script: Option<PathBuf>,
|
||||||
|
|
||||||
/// Socket address to bind HTTP server to
|
/// Code to execute after loading script
|
||||||
#[arg(short = 'a', long)]
|
#[arg(short, long)]
|
||||||
pub http_address: Option<SocketAddr>,
|
pub exec: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
http::serve,
|
http::serve,
|
||||||
lua::{client, direction::Direction, player::Player, vec3::Vec3},
|
lua::{client, direction::Direction, player::Player, vec3::Vec3},
|
||||||
particle,
|
particle,
|
||||||
replay::Recorder,
|
replay::recorder::Recorder,
|
||||||
};
|
};
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use azalea::{
|
use azalea::{
|
||||||
@ -16,6 +16,7 @@ use hyper_util::rt::TokioIo;
|
|||||||
use log::{debug, error, info, trace};
|
use log::{debug, error, info, trace};
|
||||||
use mlua::{Error, Function, IntoLuaMulti, Table};
|
use mlua::{Error, Function, IntoLuaMulti, Table};
|
||||||
use ncr::utils::trim_header;
|
use ncr::utils::trim_header;
|
||||||
|
use std::net::SocketAddr;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
@ -164,6 +165,13 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
table.set("passengers", &*packet.passengers)?;
|
table.set("passengers", &*packet.passengers)?;
|
||||||
call_listeners(&state, "set_passengers", table).await;
|
call_listeners(&state, "set_passengers", table).await;
|
||||||
}
|
}
|
||||||
|
ClientboundGamePacket::SetTime(packet) => {
|
||||||
|
let table = state.lua.create_table()?;
|
||||||
|
table.set("day_time", packet.day_time)?;
|
||||||
|
table.set("game_time", packet.game_time)?;
|
||||||
|
table.set("tick_day_time", packet.tick_day_time)?;
|
||||||
|
call_listeners(&state, "set_time", table).await;
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
Event::Init => {
|
Event::Init => {
|
||||||
@ -191,7 +199,11 @@ pub async fn handle_event(client: Client, event: Event, state: State) -> anyhow:
|
|||||||
)?;
|
)?;
|
||||||
call_listeners(&state, "init", ()).await;
|
call_listeners(&state, "init", ()).await;
|
||||||
|
|
||||||
let Some(address) = state.http_address else {
|
let Some(address): Option<SocketAddr> = globals
|
||||||
|
.get::<String>("HttpAddress")
|
||||||
|
.ok()
|
||||||
|
.and_then(|string| string.parse().ok())
|
||||||
|
else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ pub async fn get_block_states(
|
|||||||
lua: Lua,
|
lua: Lua,
|
||||||
(block_names, filter_fn): (Vec<String>, Option<Function>),
|
(block_names, filter_fn): (Vec<String>, Option<Function>),
|
||||||
) -> Result<Vec<u16>> {
|
) -> Result<Vec<u16>> {
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::with_capacity(16);
|
||||||
for block_name in block_names {
|
for block_name in block_names {
|
||||||
for block in
|
for block in
|
||||||
(u32::MIN..u32::MAX).map_while(|possible_id| BlockState::try_from(possible_id).ok())
|
(u32::MIN..u32::MAX).map_while(|possible_id| BlockState::try_from(possible_id).ok())
|
||||||
|
@ -109,11 +109,7 @@ fn id(_lua: &Lua, client: &Client) -> Result<i32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn tab_list(_lua: &Lua, client: &Client) -> Result<Vec<Player>> {
|
fn tab_list(_lua: &Lua, client: &Client) -> Result<Vec<Player>> {
|
||||||
let mut tab_list = Vec::new();
|
Ok(client.tab_list().into_values().map(Player::from).collect())
|
||||||
for (_, player_info) in client.tab_list() {
|
|
||||||
tab_list.push(Player::from(player_info));
|
|
||||||
}
|
|
||||||
Ok(tab_list)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn username(_lua: &Lua, client: &Client) -> Result<String> {
|
fn username(_lua: &Lua, client: &Client) -> Result<String> {
|
||||||
|
@ -56,7 +56,7 @@ pub async fn find_all_entities(
|
|||||||
client: UserDataRef<Client>,
|
client: UserDataRef<Client>,
|
||||||
(): (),
|
(): (),
|
||||||
) -> Result<Vec<Table>> {
|
) -> Result<Vec<Table>> {
|
||||||
let mut matched = Vec::new();
|
let mut matched = Vec::with_capacity(256);
|
||||||
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
for (position, custom_name, kind, uuid, direction, id, owner_uuid, pose) in
|
||||||
get_entities!(client)
|
get_entities!(client)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ pub fn reload(lua: &Lua, sender: Option<String>) -> Result<(), Error> {
|
|||||||
lua.load(
|
lua.load(
|
||||||
&std::fs::read_to_string(
|
&std::fs::read_to_string(
|
||||||
lua.globals()
|
lua.globals()
|
||||||
.get::<String>("script_path")
|
.get::<String>("SCRIPT_PATH")
|
||||||
.map_err(Error::MissingPath)?,
|
.map_err(Error::MissingPath)?,
|
||||||
)
|
)
|
||||||
.map_err(Error::ReadFile)?,
|
.map_err(Error::ReadFile)?,
|
||||||
|
@ -4,7 +4,7 @@ macro_rules! crypt {
|
|||||||
macro_rules! crypt_with {
|
macro_rules! crypt_with {
|
||||||
($algo:ident) => {{
|
($algo:ident) => {{
|
||||||
let encoding = $options.get("encoding").unwrap_or_default();
|
let encoding = $options.get("encoding").unwrap_or_default();
|
||||||
let key = &$options.get::<UserDataRef<AesKey>>("$key")?.inner;
|
let key = &$options.get::<UserDataRef<AesKey>>("key")?.inner;
|
||||||
match encoding {
|
match encoding {
|
||||||
1 => $algo::<Base64Encoding>::$op($text, &key),
|
1 => $algo::<Base64Encoding>::$op($text, &key),
|
||||||
2 => $algo::<Base64rEncoding>::$op($text, &key),
|
2 => $algo::<Base64rEncoding>::$op($text, &key),
|
||||||
|
@ -13,7 +13,7 @@ pub struct Player {
|
|||||||
impl From<PlayerInfo> for Player {
|
impl From<PlayerInfo> for Player {
|
||||||
fn from(p: PlayerInfo) -> Self {
|
fn from(p: PlayerInfo) -> Self {
|
||||||
Self {
|
Self {
|
||||||
display_name: p.display_name.map(|n| n.to_string()),
|
display_name: p.display_name.map(|text| text.to_string()),
|
||||||
gamemode: p.gamemode.to_id(),
|
gamemode: p.gamemode.to_id(),
|
||||||
latency: p.latency,
|
latency: p.latency,
|
||||||
name: p.profile.name,
|
name: p.profile.name,
|
||||||
|
21
src/main.rs
21
src/main.rs
@ -9,6 +9,7 @@ mod lua;
|
|||||||
mod particle;
|
mod particle;
|
||||||
mod replay;
|
mod replay;
|
||||||
|
|
||||||
|
use anyhow::Context;
|
||||||
use arguments::Arguments;
|
use arguments::Arguments;
|
||||||
use azalea::{
|
use azalea::{
|
||||||
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
DefaultBotPlugins, DefaultPlugins, brigadier::prelude::CommandDispatcher, prelude::*,
|
||||||
@ -23,23 +24,23 @@ use commands::{CommandSource, register};
|
|||||||
use futures::lock::Mutex;
|
use futures::lock::Mutex;
|
||||||
use futures_locks::RwLock;
|
use futures_locks::RwLock;
|
||||||
use mlua::{Function, Lua, Table};
|
use mlua::{Function, Lua, Table};
|
||||||
use replay::{Recorder, plugin::RecordPlugin};
|
use replay::{plugin::RecordPlugin, recorder::Recorder};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
env,
|
env,
|
||||||
fs::{OpenOptions, read_to_string},
|
fs::{OpenOptions, read_to_string},
|
||||||
net::SocketAddr,
|
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEFAULT_SCRIPT_PATH: &str = "errornowatcher.lua";
|
#[cfg(feature = "mimalloc")]
|
||||||
|
#[global_allocator]
|
||||||
|
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||||
|
|
||||||
type ListenerMap = Arc<RwLock<HashMap<String, Vec<(String, Function)>>>>;
|
type ListenerMap = Arc<RwLock<HashMap<String, Vec<(String, Function)>>>>;
|
||||||
|
|
||||||
#[derive(Default, Clone, Component)]
|
#[derive(Default, Clone, Component)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
http_address: Option<SocketAddr>,
|
|
||||||
lua: Arc<Lua>,
|
lua: Arc<Lua>,
|
||||||
event_listeners: ListenerMap,
|
event_listeners: ListenerMap,
|
||||||
commands: Arc<CommandDispatcher<Mutex<CommandSource>>>,
|
commands: Arc<CommandDispatcher<Mutex<CommandSource>>>,
|
||||||
@ -51,18 +52,21 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
console_subscriber::init();
|
console_subscriber::init();
|
||||||
|
|
||||||
let args = Arguments::parse();
|
let args = Arguments::parse();
|
||||||
let script_path = args.script.unwrap_or(PathBuf::from(DEFAULT_SCRIPT_PATH));
|
let script_path = args.script.unwrap_or(PathBuf::from("errornowatcher.lua"));
|
||||||
let event_listeners = Arc::new(RwLock::new(HashMap::new()));
|
let event_listeners = Arc::new(RwLock::new(HashMap::new()));
|
||||||
let lua = unsafe { Lua::unsafe_new() };
|
let lua = unsafe { Lua::unsafe_new() };
|
||||||
let globals = lua.globals();
|
let globals = lua.globals();
|
||||||
|
|
||||||
globals.set("script_path", &*script_path)?;
|
|
||||||
lua::register_globals(&lua, &globals, event_listeners.clone())?;
|
lua::register_globals(&lua, &globals, event_listeners.clone())?;
|
||||||
|
globals.set("SCRIPT_PATH", &*script_path)?;
|
||||||
lua.load(
|
lua.load(
|
||||||
read_to_string(script_path)
|
read_to_string(&script_path).with_context(|| format!("failed to read {script_path:?}"))?,
|
||||||
.expect(&(DEFAULT_SCRIPT_PATH.to_owned() + " should be in current directory")),
|
|
||||||
)
|
)
|
||||||
.exec()?;
|
.exec()?;
|
||||||
|
if let Some(code) = args.exec {
|
||||||
|
lua.load(code).exec()?;
|
||||||
|
}
|
||||||
|
|
||||||
let server = globals
|
let server = globals
|
||||||
.get::<String>("Server")
|
.get::<String>("Server")
|
||||||
.expect("Server should be in lua globals");
|
.expect("Server should be in lua globals");
|
||||||
@ -116,7 +120,6 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.add_plugins(DefaultBotPlugins)
|
.add_plugins(DefaultBotPlugins)
|
||||||
.set_handler(events::handle_event)
|
.set_handler(events::handle_event)
|
||||||
.set_state(State {
|
.set_state(State {
|
||||||
http_address: args.http_address,
|
|
||||||
lua: Arc::new(lua),
|
lua: Arc::new(lua),
|
||||||
event_listeners,
|
event_listeners,
|
||||||
commands: Arc::new(commands),
|
commands: Arc::new(commands),
|
||||||
|
@ -1,88 +1,2 @@
|
|||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
|
pub mod recorder;
|
||||||
use crate::build_info;
|
|
||||||
use anyhow::Result;
|
|
||||||
use azalea::{
|
|
||||||
buf::AzaleaWriteVar,
|
|
||||||
prelude::Resource,
|
|
||||||
protocol::packets::{PROTOCOL_VERSION, ProtocolPacket, VERSION_NAME},
|
|
||||||
};
|
|
||||||
use serde_json::json;
|
|
||||||
use std::{
|
|
||||||
fs::File,
|
|
||||||
io::Write,
|
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
|
||||||
};
|
|
||||||
use zip::{ZipWriter, write::SimpleFileOptions};
|
|
||||||
|
|
||||||
#[derive(Resource)]
|
|
||||||
pub struct Recorder {
|
|
||||||
zip_writer: ZipWriter<File>,
|
|
||||||
start_time: u128,
|
|
||||||
server: String,
|
|
||||||
ignore_compression: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Recorder {
|
|
||||||
pub fn new(path: String, server: String, ignore_compression: bool) -> Result<Self> {
|
|
||||||
let mut zip_writer = ZipWriter::new(
|
|
||||||
File::options()
|
|
||||||
.write(true)
|
|
||||||
.create(true)
|
|
||||||
.truncate(true)
|
|
||||||
.open(path)?,
|
|
||||||
);
|
|
||||||
zip_writer.start_file("recording.tmcpr", SimpleFileOptions::default())?;
|
|
||||||
Ok(Self {
|
|
||||||
zip_writer,
|
|
||||||
start_time: SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis(),
|
|
||||||
server,
|
|
||||||
ignore_compression,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn finish(mut self) -> Result<()> {
|
|
||||||
self.zip_writer
|
|
||||||
.start_file("metaData.json", SimpleFileOptions::default())?;
|
|
||||||
self.zip_writer.write_all(
|
|
||||||
json!({
|
|
||||||
"singleplayer": false,
|
|
||||||
"serverName": self.server,
|
|
||||||
"duration": SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() - self.start_time,
|
|
||||||
"date": self.start_time,
|
|
||||||
"mcversion": VERSION_NAME,
|
|
||||||
"fileFormat": "MCPR",
|
|
||||||
"fileFormatVersion": 14,
|
|
||||||
"protocol": PROTOCOL_VERSION,
|
|
||||||
"generator": build_info::version_formatted(),
|
|
||||||
})
|
|
||||||
.to_string()
|
|
||||||
.as_bytes(),
|
|
||||||
)?;
|
|
||||||
self.zip_writer.finish()?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_timestamp(&self) -> Result<[u8; 4]> {
|
|
||||||
Ok(TryInto::<u32>::try_into(
|
|
||||||
SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis() - self.start_time,
|
|
||||||
)?
|
|
||||||
.to_be_bytes())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
|
|
||||||
let mut data = Vec::from(self.get_timestamp()?);
|
|
||||||
data.extend(TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes());
|
|
||||||
data.extend(raw_packet);
|
|
||||||
self.zip_writer.write_all(&data)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn save_packet<T: ProtocolPacket>(&mut self, packet: &T) -> Result<()> {
|
|
||||||
let mut raw_packet = Vec::new();
|
|
||||||
packet.id().azalea_write_var(&mut raw_packet)?;
|
|
||||||
packet.write(&mut raw_packet)?;
|
|
||||||
self.save_raw_packet(&raw_packet)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use super::Recorder;
|
use super::recorder::Recorder;
|
||||||
use azalea::{
|
use azalea::{
|
||||||
ecs::{event::EventReader, system::Query},
|
ecs::{event::EventReader, system::Query},
|
||||||
packet_handling::{
|
packet_handling::{
|
||||||
@ -36,7 +36,7 @@ fn record_login_packets(
|
|||||||
) {
|
) {
|
||||||
if let Some(mut recorder) = recorder {
|
if let Some(mut recorder) = recorder {
|
||||||
for event in events.read() {
|
for event in events.read() {
|
||||||
if recorder.ignore_compression
|
if recorder.should_ignore_compression
|
||||||
&& let ClientboundLoginPacket::LoginCompression(_) = *event.packet
|
&& let ClientboundLoginPacket::LoginCompression(_) = *event.packet
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
87
src/replay/recorder.rs
Normal file
87
src/replay/recorder.rs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
use crate::build_info;
|
||||||
|
use anyhow::Result;
|
||||||
|
use azalea::{
|
||||||
|
buf::AzaleaWriteVar,
|
||||||
|
prelude::Resource,
|
||||||
|
protocol::packets::{PROTOCOL_VERSION, ProtocolPacket, VERSION_NAME},
|
||||||
|
};
|
||||||
|
use serde_json::json;
|
||||||
|
use smallvec::SmallVec;
|
||||||
|
use std::{
|
||||||
|
fs::File,
|
||||||
|
io::Write,
|
||||||
|
time::{Instant, SystemTime, UNIX_EPOCH},
|
||||||
|
};
|
||||||
|
use zip::{ZipWriter, write::SimpleFileOptions};
|
||||||
|
|
||||||
|
#[derive(Resource)]
|
||||||
|
pub struct Recorder {
|
||||||
|
zip_writer: ZipWriter<File>,
|
||||||
|
start: Instant,
|
||||||
|
server: String,
|
||||||
|
pub should_ignore_compression: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Recorder {
|
||||||
|
pub fn new(path: String, server: String, should_ignore_compression: bool) -> Result<Self> {
|
||||||
|
let mut zip_writer = ZipWriter::new(
|
||||||
|
File::options()
|
||||||
|
.write(true)
|
||||||
|
.create(true)
|
||||||
|
.truncate(true)
|
||||||
|
.open(path)?,
|
||||||
|
);
|
||||||
|
zip_writer.start_file("recording.tmcpr", SimpleFileOptions::default())?;
|
||||||
|
Ok(Self {
|
||||||
|
zip_writer,
|
||||||
|
start: Instant::now(),
|
||||||
|
server,
|
||||||
|
should_ignore_compression,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn finish(mut self) -> Result<()> {
|
||||||
|
let elapsed = self.start.elapsed();
|
||||||
|
|
||||||
|
self.zip_writer
|
||||||
|
.start_file("metaData.json", SimpleFileOptions::default())?;
|
||||||
|
self.zip_writer.write_all(
|
||||||
|
json!({
|
||||||
|
"singleplayer": false,
|
||||||
|
"serverName": self.server,
|
||||||
|
"duration": elapsed.as_millis(),
|
||||||
|
"date": (SystemTime::now().duration_since(UNIX_EPOCH)? - elapsed).as_millis(),
|
||||||
|
"mcversion": VERSION_NAME,
|
||||||
|
"fileFormat": "MCPR",
|
||||||
|
"fileFormatVersion": 14,
|
||||||
|
"protocol": PROTOCOL_VERSION,
|
||||||
|
"generator": format!("errornowatcher {}", build_info::version_formatted()),
|
||||||
|
})
|
||||||
|
.to_string()
|
||||||
|
.as_bytes(),
|
||||||
|
)?;
|
||||||
|
self.zip_writer.finish()?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_timestamp(&self) -> Result<[u8; 4]> {
|
||||||
|
Ok(TryInto::<u32>::try_into(self.start.elapsed().as_millis())?.to_be_bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_raw_packet(&mut self, raw_packet: &[u8]) -> Result<()> {
|
||||||
|
let mut data = Vec::with_capacity(raw_packet.len() + 8);
|
||||||
|
data.extend(self.get_timestamp()?);
|
||||||
|
data.extend(&TryInto::<u32>::try_into(raw_packet.len())?.to_be_bytes());
|
||||||
|
data.extend(raw_packet);
|
||||||
|
self.zip_writer.write_all(&data)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save_packet<T: ProtocolPacket>(&mut self, packet: &T) -> Result<()> {
|
||||||
|
let mut raw_packet = SmallVec::<[u8; 256]>::new();
|
||||||
|
packet.id().azalea_write_var(&mut raw_packet)?;
|
||||||
|
packet.write(&mut raw_packet)?;
|
||||||
|
self.save_raw_packet(&raw_packet)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user