Merge branch 'master' into 1.19
This commit is contained in:
commit
496a7dd427
|
@ -1,7 +0,0 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: cargo
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: daily
|
||||
open-pull-requests-limit: 10
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
# TODO: refactor toolchain version
|
||||
toolchain: 1.58.1
|
||||
toolchain: 1.64.0
|
||||
components: clippy, rustfmt
|
||||
default: true
|
||||
- name: Install dependencies
|
||||
|
@ -60,7 +60,7 @@ jobs:
|
|||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.58.1
|
||||
toolchain: 1.64.0
|
||||
components: clippy, rustfmt
|
||||
default: true
|
||||
- name: Build binary
|
||||
|
@ -105,7 +105,7 @@ jobs:
|
|||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.58.1
|
||||
toolchain: 1.64.0
|
||||
components: clippy, rustfmt
|
||||
default: true
|
||||
- name: Build binary
|
||||
|
@ -161,7 +161,7 @@ jobs:
|
|||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
# TODO: refactor toolchain version
|
||||
toolchain: 1.58.1
|
||||
toolchain: 1.64.0
|
||||
components: clippy, rustfmt
|
||||
default: true
|
||||
- name: Install wasm-pack
|
||||
|
|
|
@ -482,6 +482,12 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "cty"
|
||||
version = "0.2.2"
|
||||
|
@ -623,16 +629,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.4.2"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "14cc0e06fb5f67e5d6beadf3a382fec9baca1aa751c6d5368fdeee7e5932c215"
|
||||
checksum = "8eb5f255b5980bb0c8cf676b675d1a99be40f316881444f44e0462eaf5df5ded"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"deflate",
|
||||
"flume",
|
||||
"half",
|
||||
"inflate",
|
||||
"lebe",
|
||||
"miniz_oxide 0.6.2",
|
||||
"smallvec 1.9.0",
|
||||
"threadpool",
|
||||
]
|
||||
|
@ -653,7 +658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
"miniz_oxide 0.5.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -815,9 +820,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.7"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
|
||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
|
@ -878,7 +883,7 @@ dependencies = [
|
|||
"once_cell",
|
||||
"osmesa-sys",
|
||||
"parking_lot",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.0",
|
||||
"wayland-client",
|
||||
"wayland-egl",
|
||||
"winapi",
|
||||
|
@ -945,9 +950,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.2"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
checksum = "ad6a9459c9c30b177b925162351f97e7d967c7ea8bab3b8352805327daf45554"
|
||||
dependencies = [
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
|
@ -1069,9 +1077,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.3"
|
||||
version = "0.24.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e30ca2ecf7666107ff827a8e481de6a132a9b687ed3bb20bb1c144a36c00964"
|
||||
checksum = "bd8e4fb07cf672b1642304e731ef8a6a4c7891d67bb4fd4f5ce58cd6ed86803c"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
|
@ -1096,15 +1104,6 @@ dependencies = [
|
|||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inflate"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
|
@ -1146,9 +1145,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.59"
|
||||
version = "0.3.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2"
|
||||
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
|
||||
dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
@ -1167,9 +1166,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7efd1d698db0759e6ef11a7cd44407407399a910c774dd804c64c032da7826ff"
|
||||
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
|
@ -1272,6 +1271,15 @@ dependencies = [
|
|||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.4"
|
||||
|
@ -1321,7 +1329,7 @@ dependencies = [
|
|||
"jni-sys",
|
||||
"ndk-sys",
|
||||
"num_enum",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.5.0",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
|
@ -1732,7 +1740,7 @@ dependencies = [
|
|||
"bitflags",
|
||||
"crc32fast",
|
||||
"deflate",
|
||||
"miniz_oxide",
|
||||
"miniz_oxide 0.5.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1947,6 +1955,15 @@ dependencies = [
|
|||
"rand_core 0.3.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
|
||||
dependencies = [
|
||||
"cty",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raw-window-handle"
|
||||
version = "0.5.0"
|
||||
|
@ -2020,9 +2037,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.11"
|
||||
version = "0.11.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92"
|
||||
checksum = "431949c384f4e2ae07605ccaa56d1d9d2ecdb5cadd4f9577ccfab29f2e5149fc"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
|
@ -2036,10 +2053,10 @@ dependencies = [
|
|||
"hyper-tls",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"mime",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"serde",
|
||||
|
@ -2146,18 +2163,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.142"
|
||||
version = "1.0.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e590c437916fb6b221e1d00df6e3294f3fccd70ca7e92541c475d6ed6ef5fee2"
|
||||
checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.142"
|
||||
version = "1.0.147"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34b5b8d809babe02f538c2cfec6f2c1ed10804c0e5a6a041a049a4f5588ccc2e"
|
||||
checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2166,9 +2183,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.83"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
|
||||
checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
|
@ -2706,9 +2723,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.82"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
|
||||
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"wasm-bindgen-macro",
|
||||
|
@ -2716,9 +2733,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.82"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f"
|
||||
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
|
@ -2743,9 +2760,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.82"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602"
|
||||
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
|
@ -2753,9 +2770,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.82"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da"
|
||||
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -2766,9 +2783,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.82"
|
||||
version = "0.2.83"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a"
|
||||
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
||||
|
||||
[[package]]
|
||||
name = "wayland-client"
|
||||
|
@ -2855,9 +2872,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.59"
|
||||
version = "0.3.60"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1"
|
||||
checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
|
@ -2936,9 +2953,9 @@ checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
|
|||
|
||||
[[package]]
|
||||
name = "winit"
|
||||
version = "0.27.1"
|
||||
version = "0.27.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9b91360f15eb89d0bfee05d3c5981408320fe709f84953d3d90b276fc5962c7"
|
||||
checksum = "37f64802920c4c35d12a53dad5e0c55bbc3004d8dc4f2e4dd64ad02c5665d7aa"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cocoa",
|
||||
|
@ -2955,7 +2972,8 @@ dependencies = [
|
|||
"once_cell",
|
||||
"parking_lot",
|
||||
"percent-encoding",
|
||||
"raw-window-handle",
|
||||
"raw-window-handle 0.4.3",
|
||||
"raw-window-handle 0.5.0",
|
||||
"sctk-adwaita",
|
||||
"smithay-client-toolkit",
|
||||
"wasm-bindgen",
|
||||
|
@ -3032,9 +3050,9 @@ checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
|
|||
|
||||
[[package]]
|
||||
name = "zip"
|
||||
version = "0.6.2"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf225bcf73bb52cbb496e70475c7bd7a3f769df699c0020f6c7bd9a96dcf0b8d"
|
||||
checksum = "537ce7411d25e54e8ae21a7ce0b15840e7bfcff15b51d697ec3266cc76bdf080"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"crc32fast",
|
||||
|
|
20
Cargo.toml
20
Cargo.toml
|
@ -3,7 +3,7 @@ name = "stevenarella"
|
|||
version = "0.0.1"
|
||||
authors = [ "Thinkofdeath <thinkofdeath@spigotmc.org>", "iceiix <ice_ix@protonmail.ch>" ]
|
||||
edition = "2021"
|
||||
rust-version = "1.58.1"
|
||||
rust-version = "1.64.0"
|
||||
resolver = "2"
|
||||
description = "Multi-protocol multi-platform Minecraft-compatible client"
|
||||
repository = "https://github.com/iceiix/stevenarella"
|
||||
|
@ -29,16 +29,16 @@ opt-level = 1
|
|||
|
||||
[dependencies]
|
||||
cfg-if = "1.0.0"
|
||||
wasm-bindgen = "0.2.81"
|
||||
winit = "0.27.0"
|
||||
wasm-bindgen = "0.2.83"
|
||||
winit = "0.27.4"
|
||||
glow = "0.11.2"
|
||||
byteorder = "1.4.3"
|
||||
serde = "1.0.142"
|
||||
serde_json = "1.0.83"
|
||||
serde = "1.0.147"
|
||||
serde_json = "1.0.87"
|
||||
flate2 = { version = "1.0.24", features = ["rust_backend"], default-features = false }
|
||||
zip = { version = "0.6.2", features = ["deflate"], default-features = false }
|
||||
image = "0.24.3"
|
||||
getrandom = { version = "0.2.7", features = ["js"] }
|
||||
zip = { version = "0.6.3", features = ["deflate"], default-features = false }
|
||||
image = "0.24.4"
|
||||
getrandom = { version = "0.2.8", features = ["js"] }
|
||||
rand = "0.8.5"
|
||||
rand_pcg = "0.3.1"
|
||||
base64 = "0.13.0"
|
||||
|
@ -54,12 +54,12 @@ dirs = "4.0.0"
|
|||
# clippy = "*"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
reqwest = { version = "0.11.11", features = [ "blocking" ]}
|
||||
reqwest = { version = "0.11.12", features = [ "blocking" ]}
|
||||
glutin = "0.29.0"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
console_error_panic_hook = "0.1.7"
|
||||
web-sys = "0.3.59"
|
||||
web-sys = "0.3.60"
|
||||
|
||||
[dependencies.steven_resources]
|
||||
path = "./resources"
|
||||
|
|
|
@ -70,7 +70,7 @@ from [GitHub Actions](https://actions-badge.atrox.dev/iceiix/stevenarella/goto?r
|
|||
|
||||
## Dependencies
|
||||
|
||||
Requires Rust stable version 1.58.1 or newer.
|
||||
Requires Rust stable version 1.64.0 or newer.
|
||||
|
||||
**Debian/Ubuntu**
|
||||
|
||||
|
|
1040
blocks/src/lib.rs
1040
blocks/src/lib.rs
File diff suppressed because it is too large
Load Diff
|
@ -5,8 +5,8 @@ authors = [ "Thinkofdeath <thinkofdeath@spigotmc.org>", "iceiix <ice_ix@protonma
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = "1.0.142"
|
||||
serde_json = "1.0.83"
|
||||
serde = "1.0.147"
|
||||
serde_json = "1.0.87"
|
||||
hex = "0.4.3"
|
||||
sha-1 = "0.9.7"
|
||||
aes = "0.7.4"
|
||||
|
@ -14,7 +14,7 @@ cfb8 = "0.7.1"
|
|||
byteorder = "1.4.3"
|
||||
log = { version = "0.4.17", features = ["std"] }
|
||||
flate2 = { version = "1.0.24", features = ["rust_backend"], default-features = false }
|
||||
num-traits = "0.2.14"
|
||||
num-traits = "0.2.15"
|
||||
instant = "0.1.12"
|
||||
|
||||
[dependencies.steven_shared]
|
||||
|
@ -26,4 +26,4 @@ path = "../std_or_web"
|
|||
version = "0"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
reqwest = { version = "0.11.11", features = [ "blocking" ]}
|
||||
reqwest = { version = "0.11.12", features = [ "blocking" ]}
|
||||
|
|
|
@ -948,19 +948,36 @@ impl fmt::Debug for VarLong {
|
|||
impl Serializable for Position {
|
||||
fn read_from<R: io::Read>(buf: &mut R) -> Result<Position, Error> {
|
||||
let pos = buf.read_u64::<BigEndian>()?;
|
||||
Ok(Position::new(
|
||||
((pos as i64) >> 38) as i32,
|
||||
((pos as i64) & 0xFFF) as i32,
|
||||
((pos as i64) << 26 >> 38) as i32,
|
||||
))
|
||||
let protocol_version = current_protocol_version();
|
||||
if protocol_version < 477 {
|
||||
Ok(Position::new(
|
||||
((pos as i64) >> 38) as i32,
|
||||
(((pos as i64) >> 26) & 0xFFF) as i32,
|
||||
((pos as i64) << 38 >> 38) as i32,
|
||||
))
|
||||
} else {
|
||||
Ok(Position::new(
|
||||
((pos as i64) >> 38) as i32,
|
||||
((pos as i64) << 52 >> 52) as i32,
|
||||
((pos as i64) << 26 >> 38) as i32,
|
||||
))
|
||||
}
|
||||
}
|
||||
fn write_to<W: io::Write>(&self, buf: &mut W) -> Result<(), Error> {
|
||||
let pos = (((self.x as u64) & 0x3FFFFFF) << 38)
|
||||
| ((self.y as u64) & 0xFFF)
|
||||
| (((self.z as u64) & 0x3FFFFFF) << 12);
|
||||
let pos;
|
||||
let protocol_version = current_protocol_version();
|
||||
if protocol_version < 477 {
|
||||
pos = (((self.x as u64) & 0x3FFFFFF) << 38)
|
||||
| (((self.y as u64) & 0xFFF) << 26)
|
||||
| ((self.z as u64) & 0x3FFFFFF);
|
||||
} else {
|
||||
pos = (((self.x as u64) & 0x3FFFFFF) << 38)
|
||||
| ((self.y as u64) & 0xFFF)
|
||||
| (((self.z as u64) & 0x3FFFFFF) << 12);
|
||||
}
|
||||
|
||||
buf.write_u64::<BigEndian>(pos)?;
|
||||
Result::Ok(())
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base",
|
||||
"schedule:monthly"
|
||||
]
|
||||
}
|
|
@ -135,7 +135,7 @@ impl Var for CVar<String> {
|
|||
}
|
||||
|
||||
fn deserialize(&self, input: &str) -> Box<dyn Any> {
|
||||
Box::new((&input[1..input.len() - 1]).to_owned())
|
||||
Box::new(input[1..input.len() - 1].to_owned())
|
||||
}
|
||||
|
||||
fn description(&self) -> &'static str {
|
||||
|
@ -370,7 +370,7 @@ impl Console {
|
|||
}
|
||||
}
|
||||
|
||||
let mut file = &record.file().unwrap_or("").replace("\\", "/")[..];
|
||||
let mut file = &record.file().unwrap_or("").replace('\\', "/")[..];
|
||||
if let Some(pos) = file.rfind("src/") {
|
||||
file = &file[pos + 4..];
|
||||
}
|
||||
|
|
|
@ -603,7 +603,7 @@ impl ComponentMem {
|
|||
drop_func: Box::new(|data| unsafe {
|
||||
let mut val = mem::MaybeUninit::<T>::uninit();
|
||||
ptr::copy(data as *mut T, val.as_mut_ptr(), 1);
|
||||
mem::drop(val);
|
||||
val.assume_init_drop();
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
use steven_blocks as block;
|
||||
use steven_protocol::protocol::packet;
|
||||
pub mod block_entity;
|
||||
pub mod player;
|
||||
|
||||
|
@ -23,6 +25,8 @@ pub fn add_systems(m: &mut ecs::Manager) {
|
|||
m.add_render_system(sys);
|
||||
let sys = systems::LightEntity::new(m);
|
||||
m.add_render_system(sys);
|
||||
let sys = systems::ApplyDigging::new(m);
|
||||
m.add_render_system(sys);
|
||||
|
||||
block_entity::add_systems(m);
|
||||
}
|
||||
|
@ -161,3 +165,36 @@ impl Light {
|
|||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct DiggingState {
|
||||
pub block: block::Block,
|
||||
pub position: shared::Position,
|
||||
pub face: shared::Direction,
|
||||
pub start: std::time::Instant,
|
||||
pub finished: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Digging {
|
||||
pub last: Option<DiggingState>,
|
||||
pub current: Option<DiggingState>,
|
||||
}
|
||||
|
||||
impl Digging {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct MouseButtons {
|
||||
pub left: bool,
|
||||
pub right: bool,
|
||||
}
|
||||
|
||||
impl MouseButtons {
|
||||
pub fn new() -> Self {
|
||||
Default::default()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::{
|
||||
Bounds, GameInfo, Gravity, Light, Position, Rotation, TargetPosition, TargetRotation, Velocity,
|
||||
Bounds, Digging, GameInfo, Gravity, Light, MouseButtons, Position, Rotation, TargetPosition,
|
||||
TargetRotation, Velocity,
|
||||
};
|
||||
use crate::ecs;
|
||||
use crate::format;
|
||||
|
@ -43,6 +44,8 @@ pub fn create_local(m: &mut ecs::Manager) -> ecs::Entity {
|
|||
);
|
||||
m.add_component_direct(entity, PlayerModel::new("", false, false, true));
|
||||
m.add_component_direct(entity, Light::new());
|
||||
m.add_component_direct(entity, Digging::new());
|
||||
m.add_component_direct(entity, MouseButtons::new());
|
||||
entity
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
use std::sync::Arc;
|
||||
use std::sync::RwLock;
|
||||
|
||||
use super::*;
|
||||
use crate::ecs;
|
||||
use crate::render;
|
||||
use crate::shared::Position as BPos;
|
||||
use crate::world;
|
||||
use cgmath::InnerSpace;
|
||||
use log::debug;
|
||||
use steven_protocol::protocol;
|
||||
use steven_protocol::protocol::Conn;
|
||||
|
||||
pub struct ApplyVelocity {
|
||||
filter: ecs::Filter,
|
||||
|
@ -285,3 +291,186 @@ impl ecs::System for LightEntity {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ApplyDigging {
|
||||
filter: ecs::Filter,
|
||||
mouse_buttons: ecs::Key<MouseButtons>,
|
||||
digging: ecs::Key<Digging>,
|
||||
conn: ecs::Key<Arc<RwLock<Option<Conn>>>>,
|
||||
}
|
||||
|
||||
impl ApplyDigging {
|
||||
pub fn new(m: &mut ecs::Manager) -> Self {
|
||||
let mouse_buttons = m.get_key();
|
||||
let digging = m.get_key();
|
||||
Self {
|
||||
filter: ecs::Filter::new().with(mouse_buttons).with(digging),
|
||||
mouse_buttons,
|
||||
digging,
|
||||
conn: m.get_key(),
|
||||
}
|
||||
}
|
||||
|
||||
fn send_packet(&self, conn: &mut Conn, target: &DiggingState, state: i32) {
|
||||
match state {
|
||||
0 => debug!("Send start dig packet {:?}", target),
|
||||
1 => debug!("Send cancel dig packet {:?}", target),
|
||||
2 => debug!("Send finish dig packet {:?}", target),
|
||||
n => panic!("Invalid dig state {}", n),
|
||||
}
|
||||
|
||||
match conn.protocol_version {
|
||||
// 1.7.10
|
||||
5 => conn
|
||||
.write_packet(packet::play::serverbound::PlayerDigging_u8_u8y {
|
||||
status: state as u8,
|
||||
x: target.position.x,
|
||||
y: target.position.y as u8,
|
||||
z: target.position.z,
|
||||
face: target.face.index() as u8,
|
||||
})
|
||||
.unwrap(),
|
||||
// 1.8.9 or v15w39c
|
||||
47 | 74 => conn
|
||||
.write_packet(packet::play::serverbound::PlayerDigging_u8 {
|
||||
status: state as u8,
|
||||
location: target.position,
|
||||
face: target.face.index() as u8,
|
||||
})
|
||||
.unwrap(),
|
||||
// 1.9+
|
||||
_ => conn
|
||||
.write_packet(packet::play::serverbound::PlayerDigging {
|
||||
status: protocol::VarInt(state),
|
||||
location: target.position,
|
||||
face: target.face.index() as u8,
|
||||
})
|
||||
.unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
fn next_state(
|
||||
&self,
|
||||
last: &Option<DiggingState>,
|
||||
mouse_buttons: &MouseButtons,
|
||||
target: Option<(
|
||||
shared::Position,
|
||||
block::Block,
|
||||
shared::Direction,
|
||||
Vector3<f64>,
|
||||
)>,
|
||||
) -> Option<DiggingState> {
|
||||
// Figure out the next state
|
||||
if !mouse_buttons.left {
|
||||
return None;
|
||||
}
|
||||
|
||||
match (last, target) {
|
||||
// Started digging
|
||||
(None, Some((position, block, face, _))) => Some(DiggingState {
|
||||
block,
|
||||
face,
|
||||
position,
|
||||
start: std::time::Instant::now(),
|
||||
finished: false,
|
||||
}),
|
||||
(Some(current), Some((position, block, face, _))) => {
|
||||
// Continue digging
|
||||
if position == current.position {
|
||||
return last.clone();
|
||||
}
|
||||
|
||||
// Start digging a different block.
|
||||
Some(DiggingState {
|
||||
block,
|
||||
face,
|
||||
position,
|
||||
start: std::time::Instant::now(),
|
||||
finished: false,
|
||||
})
|
||||
}
|
||||
// Not pointing at any target
|
||||
(_, None) => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_finished(&self, state: &DiggingState) -> bool {
|
||||
let mining_time = state.block.get_mining_time(&None);
|
||||
match mining_time {
|
||||
Some(mining_time) => {
|
||||
let finish_time = state.start + mining_time;
|
||||
finish_time > std::time::Instant::now()
|
||||
}
|
||||
None => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ecs::System for ApplyDigging {
|
||||
fn filter(&self) -> &ecs::Filter {
|
||||
&self.filter
|
||||
}
|
||||
|
||||
fn update(
|
||||
&mut self,
|
||||
m: &mut ecs::Manager,
|
||||
world: &mut world::World,
|
||||
renderer: &mut render::Renderer,
|
||||
) {
|
||||
use crate::server::target::{test_block, trace_ray};
|
||||
use cgmath::EuclideanSpace;
|
||||
|
||||
let world_entity = m.get_world();
|
||||
let mut conn = m
|
||||
.get_component(world_entity, self.conn)
|
||||
.unwrap()
|
||||
.write()
|
||||
.unwrap();
|
||||
let conn = match conn.as_mut() {
|
||||
Some(conn) => conn,
|
||||
// Don't keep processing digging operations if the connection was
|
||||
// closed.
|
||||
None => return,
|
||||
};
|
||||
|
||||
let target = trace_ray(
|
||||
world,
|
||||
4.0,
|
||||
renderer.camera.pos.to_vec(),
|
||||
renderer.view_vector.cast().unwrap(),
|
||||
test_block,
|
||||
);
|
||||
|
||||
for e in m.find(&self.filter) {
|
||||
let mouse_buttons = m.get_component(e, self.mouse_buttons).unwrap();
|
||||
let digging = m.get_component_mut(e, self.digging).unwrap();
|
||||
|
||||
// Update last and current state
|
||||
std::mem::swap(&mut digging.last, &mut digging.current);
|
||||
digging.current = self.next_state(&digging.last, mouse_buttons, target);
|
||||
|
||||
// Handle digging packets
|
||||
match (&digging.last, &mut digging.current) {
|
||||
// Start the new digging operation.
|
||||
(None, Some(current)) => self.send_packet(conn, current, 0),
|
||||
// Cancel the previous digging operation.
|
||||
(Some(last), None) if !last.finished => self.send_packet(conn, last, 1),
|
||||
// Move to digging a new block
|
||||
(Some(last), Some(current)) if last.position != current.position => {
|
||||
// Cancel the previous digging operation.
|
||||
if !current.finished {
|
||||
self.send_packet(conn, last, 1);
|
||||
}
|
||||
// Start the new digging operation.
|
||||
self.send_packet(conn, current, 0);
|
||||
}
|
||||
// Finish the new digging operation.
|
||||
(Some(_), Some(current)) if !self.is_finished(current) && !current.finished => {
|
||||
self.send_packet(conn, current, 2);
|
||||
current.finished = true;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
36
src/main.rs
36
src/main.rs
|
@ -369,8 +369,7 @@ fn main2() {
|
|||
|
||||
let textures = renderer.get_textures();
|
||||
let default_protocol_version = protocol::versions::protocol_name_to_protocol_version(
|
||||
opt.default_protocol_version
|
||||
.unwrap_or_else(|| "".to_string()),
|
||||
opt.default_protocol_version.unwrap_or_default(),
|
||||
);
|
||||
let mut game = Game {
|
||||
server: server::Server::dummy_server(resource_manager.clone()),
|
||||
|
@ -630,6 +629,11 @@ fn handle_window_event<T>(
|
|||
event: winit::event::Event<T>,
|
||||
) -> bool {
|
||||
use winit::event::*;
|
||||
let cursor_grab_mode = if cfg!(target_os = "macos") {
|
||||
winit::window::CursorGrabMode::Locked
|
||||
} else {
|
||||
winit::window::CursorGrabMode::Confined
|
||||
};
|
||||
match event {
|
||||
Event::MainEventsCleared => return true,
|
||||
Event::DeviceEvent {
|
||||
|
@ -659,9 +663,7 @@ fn handle_window_event<T>(
|
|||
use std::f64::consts::PI;
|
||||
|
||||
if game.focused {
|
||||
window
|
||||
.set_cursor_grab(winit::window::CursorGrabMode::Locked)
|
||||
.unwrap();
|
||||
window.set_cursor_grab(cursor_grab_mode).unwrap();
|
||||
window.set_cursor_visible(false);
|
||||
if let Some(player) = game.server.player {
|
||||
let rotation = game
|
||||
|
@ -719,9 +721,7 @@ fn handle_window_event<T>(
|
|||
&& !game.screen_sys.is_current_closable()
|
||||
{
|
||||
game.focused = true;
|
||||
window
|
||||
.set_cursor_grab(winit::window::CursorGrabMode::Locked)
|
||||
.unwrap();
|
||||
window.set_cursor_grab(cursor_grab_mode).unwrap();
|
||||
window.set_cursor_visible(false);
|
||||
} else if !game.focused {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
|
@ -738,9 +738,25 @@ fn handle_window_event<T>(
|
|||
height,
|
||||
);
|
||||
}
|
||||
|
||||
if game.focused {
|
||||
game.server.on_left_mouse_button(false);
|
||||
}
|
||||
}
|
||||
(ElementState::Pressed, MouseButton::Left) => {
|
||||
if game.focused {
|
||||
game.server.on_left_mouse_button(true);
|
||||
}
|
||||
}
|
||||
(ElementState::Released, MouseButton::Right) => {
|
||||
if game.focused {
|
||||
game.server.on_right_mouse_button(false);
|
||||
game.server.on_right_click(&mut game.renderer);
|
||||
}
|
||||
}
|
||||
(ElementState::Pressed, MouseButton::Right) => {
|
||||
if game.focused {
|
||||
game.server.on_right_mouse_button(true);
|
||||
game.server.on_right_click(&mut game.renderer);
|
||||
}
|
||||
}
|
||||
|
@ -783,9 +799,7 @@ fn handle_window_event<T>(
|
|||
screen::SettingsMenu::new(game.vars.clone(), true),
|
||||
));
|
||||
} else if game.screen_sys.is_current_closable() {
|
||||
window
|
||||
.set_cursor_grab(winit::window::CursorGrabMode::Locked)
|
||||
.unwrap();
|
||||
window.set_cursor_grab(cursor_grab_mode).unwrap();
|
||||
window.set_cursor_visible(false);
|
||||
game.focused = true;
|
||||
game.screen_sys.pop_screen();
|
||||
|
|
|
@ -42,7 +42,7 @@ pub mod target;
|
|||
|
||||
pub struct Server {
|
||||
uuid: protocol::UUID,
|
||||
conn: Option<protocol::Conn>,
|
||||
conn: Arc<RwLock<Option<protocol::Conn>>>,
|
||||
protocol_version: i32,
|
||||
forge_mods: Vec<forge::ForgeMod>,
|
||||
read_queue: Option<mpsc::Receiver<Result<packet::Packet, protocol::Error>>>,
|
||||
|
@ -62,6 +62,7 @@ pub struct Server {
|
|||
// Entity accessors
|
||||
game_info: ecs::Key<entity::GameInfo>,
|
||||
player_movement: ecs::Key<entity::player::PlayerMovement>,
|
||||
mouse_buttons: ecs::Key<entity::MouseButtons>,
|
||||
gravity: ecs::Key<entity::Gravity>,
|
||||
position: ecs::Key<entity::Position>,
|
||||
target_position: ecs::Key<entity::TargetPosition>,
|
||||
|
@ -179,7 +180,7 @@ impl Server {
|
|||
forge_mods,
|
||||
protocol::UUID::from_str(&val.uuid).unwrap(),
|
||||
resources,
|
||||
Some(write),
|
||||
Arc::new(RwLock::new(Some(write))),
|
||||
Some(rx),
|
||||
));
|
||||
}
|
||||
|
@ -196,7 +197,7 @@ impl Server {
|
|||
forge_mods,
|
||||
val.uuid,
|
||||
resources,
|
||||
Some(write),
|
||||
Arc::new(RwLock::new(Some(write))),
|
||||
Some(rx),
|
||||
));
|
||||
}
|
||||
|
@ -216,7 +217,7 @@ impl Server {
|
|||
forge_mods,
|
||||
val.uuid,
|
||||
resources,
|
||||
Some(write),
|
||||
Arc::new(RwLock::new(Some(write))),
|
||||
Some(rx),
|
||||
));
|
||||
}
|
||||
|
@ -380,7 +381,7 @@ impl Server {
|
|||
forge_mods,
|
||||
uuid,
|
||||
resources,
|
||||
Some(write),
|
||||
Arc::new(RwLock::new(Some(write))),
|
||||
Some(rx),
|
||||
))
|
||||
}
|
||||
|
@ -408,7 +409,7 @@ impl Server {
|
|||
vec![],
|
||||
protocol::UUID::default(),
|
||||
resources,
|
||||
None,
|
||||
Arc::new(RwLock::new(None)),
|
||||
None,
|
||||
);
|
||||
let mut rng = rand::thread_rng();
|
||||
|
@ -496,7 +497,7 @@ impl Server {
|
|||
forge_mods: Vec<forge::ForgeMod>,
|
||||
uuid: protocol::UUID,
|
||||
resources: Arc<RwLock<resources::Manager>>,
|
||||
conn: Option<protocol::Conn>,
|
||||
conn: Arc<RwLock<Option<protocol::Conn>>>,
|
||||
read_queue: Option<mpsc::Receiver<Result<packet::Packet, protocol::Error>>>,
|
||||
) -> Server {
|
||||
let mut entities = ecs::Manager::new();
|
||||
|
@ -505,6 +506,7 @@ impl Server {
|
|||
let world_entity = entities.get_world();
|
||||
let game_info = entities.get_key();
|
||||
entities.add_component(world_entity, game_info, entity::GameInfo::new());
|
||||
entities.add_component(world_entity, entities.get_key(), conn.clone());
|
||||
|
||||
let version = resources.read().unwrap().version();
|
||||
Server {
|
||||
|
@ -528,6 +530,7 @@ impl Server {
|
|||
// Entity accessors
|
||||
game_info,
|
||||
player_movement: entities.get_key(),
|
||||
mouse_buttons: entities.get_key(),
|
||||
gravity: entities.get_key(),
|
||||
position: entities.get_key(),
|
||||
target_position: entities.get_key(),
|
||||
|
@ -551,7 +554,7 @@ impl Server {
|
|||
}
|
||||
|
||||
pub fn disconnect(&mut self, reason: Option<format::Component>) {
|
||||
self.conn = None;
|
||||
self.conn.write().unwrap().take();
|
||||
self.disconnect_reason = reason;
|
||||
if let Some(player) = self.player.take() {
|
||||
self.entities.remove_entity(player);
|
||||
|
@ -560,7 +563,7 @@ impl Server {
|
|||
}
|
||||
|
||||
pub fn is_connected(&self) -> bool {
|
||||
self.conn.is_some()
|
||||
self.conn.read().unwrap().is_some()
|
||||
}
|
||||
|
||||
pub fn tick(&mut self, renderer: &mut render::Renderer, delta: f64) {
|
||||
|
@ -676,6 +679,7 @@ impl Server {
|
|||
UpdateBlockEntity_VarInt => on_block_entity_update_varint,
|
||||
UpdateBlockEntity_u8 => on_block_entity_update_u8,
|
||||
UpdateBlockEntity_Data => on_block_entity_update_data,
|
||||
UpdateLight_Arrays => on_update_light_arrays,
|
||||
UpdateSign => on_sign_update,
|
||||
UpdateSign_u16 => on_sign_update_u16,
|
||||
PlayerInfo => on_player_info,
|
||||
|
@ -709,12 +713,12 @@ impl Server {
|
|||
Err(err) => panic!("Err: {:?}", err),
|
||||
}
|
||||
// Disconnected
|
||||
if self.conn.is_none() {
|
||||
if self.conn.read().unwrap().is_none() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if self.conn.is_some() {
|
||||
if self.conn.read().unwrap().is_some() {
|
||||
self.read_queue = Some(rx);
|
||||
}
|
||||
}
|
||||
|
@ -846,6 +850,24 @@ impl Server {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn on_left_mouse_button(&mut self, pressed: bool) {
|
||||
if let Some(player) = self.player {
|
||||
if let Some(mouse_buttons) = self.entities.get_component_mut(player, self.mouse_buttons)
|
||||
{
|
||||
mouse_buttons.left = pressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_right_mouse_button(&mut self, pressed: bool) {
|
||||
if let Some(player) = self.player {
|
||||
if let Some(mouse_buttons) = self.entities.get_component_mut(player, self.mouse_buttons)
|
||||
{
|
||||
mouse_buttons.right = pressed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_right_click(&mut self, renderer: &mut render::Renderer) {
|
||||
use crate::shared::Direction;
|
||||
if self.player.is_some() {
|
||||
|
@ -953,8 +975,9 @@ impl Server {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn write_packet<T: protocol::PacketType>(&mut self, p: T) {
|
||||
let _ = self.conn.as_mut().unwrap().write_packet(p); // TODO handle errors
|
||||
pub fn write_packet<T: protocol::PacketType>(&self, p: T) {
|
||||
let mut conn = self.conn.write().unwrap();
|
||||
let _ = conn.as_mut().unwrap().write_packet(p); // TODO handle errors
|
||||
}
|
||||
|
||||
fn on_keep_alive_i64(
|
||||
|
@ -1101,15 +1124,13 @@ impl Server {
|
|||
|
||||
// TODO: remove wrappers and directly call on Conn
|
||||
fn write_fmlhs_plugin_message(&mut self, msg: &forge::FmlHs) {
|
||||
let _ = self.conn.as_mut().unwrap().write_fmlhs_plugin_message(msg); // TODO handle errors
|
||||
let mut conn = self.conn.write().unwrap();
|
||||
let _ = conn.as_mut().unwrap().write_fmlhs_plugin_message(msg); // TODO handle errors
|
||||
}
|
||||
|
||||
fn write_plugin_message(&mut self, channel: &str, data: &[u8]) {
|
||||
let _ = self
|
||||
.conn
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.write_plugin_message(channel, data); // TODO handle errors
|
||||
let mut conn = self.conn.write().unwrap();
|
||||
let _ = conn.as_mut().unwrap().write_plugin_message(channel, data); // TODO handle errors
|
||||
}
|
||||
|
||||
fn on_game_join_worldnames_ishard_simdist_hasdeath(
|
||||
|
@ -2055,13 +2076,12 @@ impl Server {
|
|||
let z = block_entity.1.get("z").unwrap().as_int().unwrap();
|
||||
if let Some(tile_id) = block_entity.1.get("id") {
|
||||
let tile_id = tile_id.as_str().unwrap();
|
||||
let action;
|
||||
match tile_id {
|
||||
let action = match tile_id {
|
||||
// Fake a sign update
|
||||
"Sign" => action = 9,
|
||||
"Sign" => 9,
|
||||
// Not something we care about, so break the loop
|
||||
_ => continue,
|
||||
}
|
||||
};
|
||||
self.on_block_entity_update_u8(packet::play::clientbound::UpdateBlockEntity_u8 {
|
||||
location: Position::new(x, y, z),
|
||||
action,
|
||||
|
@ -2081,17 +2101,48 @@ impl Server {
|
|||
chunk_data: packet::play::clientbound::ChunkData_AndLight,
|
||||
) {
|
||||
self.world
|
||||
.load_chunk117(
|
||||
.load_chunk118(
|
||||
chunk_data.chunk_x,
|
||||
chunk_data.chunk_z,
|
||||
true,
|
||||
0xffff, // world height/16 (256/16 = 16) bits
|
||||
16, // TODO: get all bitmasks
|
||||
chunk_data.data.data,
|
||||
)
|
||||
.unwrap();
|
||||
//self.load_block_entities(chunk_data.block_entities.data); // TODO: load entities
|
||||
// TODO: update light
|
||||
|
||||
// Set block light data
|
||||
self.world.set_light_data(
|
||||
chunk_data.chunk_x,
|
||||
chunk_data.chunk_z,
|
||||
world::LightType::Block,
|
||||
chunk_data.block_light_mask.data,
|
||||
chunk_data.block_light_arrays.data,
|
||||
);
|
||||
|
||||
// Set sky light data
|
||||
self.world.set_light_data(
|
||||
chunk_data.chunk_x,
|
||||
chunk_data.chunk_z,
|
||||
world::LightType::Sky,
|
||||
chunk_data.sky_light_mask.data,
|
||||
chunk_data.sky_light_arrays.data,
|
||||
);
|
||||
|
||||
// Clear block light data
|
||||
self.world.clear_light_data(
|
||||
chunk_data.chunk_x,
|
||||
chunk_data.chunk_z,
|
||||
world::LightType::Block,
|
||||
chunk_data.empty_block_light_mask.data,
|
||||
);
|
||||
|
||||
// Clear sky light data
|
||||
self.world.clear_light_data(
|
||||
chunk_data.chunk_x,
|
||||
chunk_data.chunk_z,
|
||||
world::LightType::Sky,
|
||||
chunk_data.empty_sky_light_mask.data,
|
||||
);
|
||||
}
|
||||
|
||||
fn on_chunk_data_biomes3d_bitmasks(
|
||||
|
@ -2104,7 +2155,6 @@ impl Server {
|
|||
chunk_data.chunk_z,
|
||||
true,
|
||||
chunk_data.bitmasks.data[0] as u64, // TODO: get all bitmasks
|
||||
16, // TODO: get all bitmasks
|
||||
chunk_data.data.data,
|
||||
)
|
||||
.unwrap();
|
||||
|
@ -2352,6 +2402,45 @@ impl Server {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn on_update_light_arrays(
|
||||
&mut self,
|
||||
light_update: packet::play::clientbound::UpdateLight_Arrays,
|
||||
) {
|
||||
// Clear block light data
|
||||
self.world.clear_light_data(
|
||||
light_update.chunk_x.0,
|
||||
light_update.chunk_z.0,
|
||||
world::LightType::Block,
|
||||
light_update.empty_block_light_mask.data,
|
||||
);
|
||||
|
||||
// Clear sky light data
|
||||
self.world.clear_light_data(
|
||||
light_update.chunk_x.0,
|
||||
light_update.chunk_z.0,
|
||||
world::LightType::Sky,
|
||||
light_update.empty_sky_light_mask.data,
|
||||
);
|
||||
|
||||
// Set block light data
|
||||
self.world.set_light_data(
|
||||
light_update.chunk_x.0,
|
||||
light_update.chunk_z.0,
|
||||
world::LightType::Block,
|
||||
light_update.block_light_mask.data,
|
||||
light_update.block_light_arrays.data,
|
||||
);
|
||||
|
||||
// Set sky light data
|
||||
self.world.set_light_data(
|
||||
light_update.chunk_x.0,
|
||||
light_update.chunk_z.0,
|
||||
world::LightType::Sky,
|
||||
light_update.sky_light_mask.data,
|
||||
light_update.sky_light_arrays.data,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
|
|
|
@ -115,12 +115,9 @@ impl Stevenkey {
|
|||
}
|
||||
|
||||
pub fn get_by_keycode(keycode: VirtualKeyCode, vars: &console::Vars) -> Option<Stevenkey> {
|
||||
for steven_key in Stevenkey::values() {
|
||||
if keycode as i64 == *vars.get(steven_key.get_cvar()) {
|
||||
return Some(steven_key);
|
||||
}
|
||||
}
|
||||
None
|
||||
Stevenkey::values()
|
||||
.into_iter()
|
||||
.find(|steven_key| keycode as i64 == *vars.get(steven_key.get_cvar()))
|
||||
}
|
||||
|
||||
pub fn get_cvar(&self) -> console::CVar<i64> {
|
||||
|
|
|
@ -99,7 +99,7 @@ impl Logo {
|
|||
let mut texts = String::new();
|
||||
file.read_to_string(&mut texts).unwrap();
|
||||
for line in texts.lines() {
|
||||
text_strings.push(line.to_owned().replace("\r", ""));
|
||||
text_strings.push(line.to_owned().replace('\r', ""));
|
||||
}
|
||||
}
|
||||
let mut r: rand_pcg::Pcg32 =
|
||||
|
|
|
@ -1494,6 +1494,8 @@ impl Button {
|
|||
}
|
||||
}
|
||||
|
||||
type SubmitFunc = dyn Fn(&mut TextBox, &mut crate::Game);
|
||||
|
||||
element! {
|
||||
ref TextBoxRef
|
||||
pub struct TextBox {
|
||||
|
@ -1505,7 +1507,7 @@ element! {
|
|||
priv text: Option<TextRef>,
|
||||
priv was_focused: bool,
|
||||
priv cursor_tick: f64,
|
||||
priv submit_funcs: Vec<Box<dyn Fn(&mut TextBox, &mut crate::Game)>>,
|
||||
priv submit_funcs: Vec<Box<SubmitFunc>>,
|
||||
}
|
||||
builder TextBoxBuilder {
|
||||
hardcode button = None,
|
||||
|
|
723
src/world/mod.rs
723
src/world/mod.rs
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue