Closes#276 Bump serde_json from 1.0.44 to 1.0.45
Closes#274 Bump structopt from 0.3.7 to 0.3.8
Closes#273 Bump image from 0.22.3 to 0.22.4
Closes#272 Bump rand from 0.7.2 to 0.7.3
Closes#270 Bump num-traits from 0.2.10 to 0.2.11
Closes#269 Bump reqwest from 0.10.0 to 0.10.1
Completes the move of the protocol implementation into a new
crate, named steven_protocol, in the protocol/ subdirectory.
* Add Cargo.toml for steven_protocol
* Add steven_protocol entrypoint in protocol/src/lib.rs
* Use steven_protocol in main
* Remove protocol in main, replaced by steven_protocol
* Remove unused dependencies moved into steven_protocol
Improves fix for #184, whereas #255 reduced optimizations,
we now address the underlying compiler limitation and split out
the one massive lazy_static! initialization function, into
one function per block in the block_registration_functions module.
Previous build time, with opt-level=1:
% time cargo build --release
Compiling steven_blocks v0.0.1
Finished release [optimized] target(s) in 21.24s
cargo build --release 31.80s user 0.71s system 152% cpu 21.276 total
With this change, opt-level=3 and the function splitting fix:
% time cargo build --release
Compiling steven_blocks v0.0.1
Finished release [optimized] target(s) in 30.80s
cargo build --release 40.26s user 0.86s system 133% cpu 30.850 total
Full optimizations are expectedly slightly slower, but this is still
much much _much_ faster than before this refactoring, where this crate
would take up to an unbelievable 5 hours (and tens of GB of RAM). Long
story short, we're now back to full optimizations and stable Rust.
Thanks to dtolnay on the Rust programming language forum for suggesting
this technique, https://users.rust-lang.org/t/5-hours-to-compile-macro-what-can-i-do/36508/2
Update from glutin 0.21.x fork to glutin 0.22.0-alpha5 and corresponding
compatible version of winit. This removes our custom temporary wasm_stub
branches, back to mainline glutin and winit, and is a step towards WebAssembly
compatibility, most importantly merging the game loop and event loops as
required by winit _which now supports wasm_. Not yet functional on the web
because other web dependencies have to be added, see #171 and #34, but native
functionality is preserved.
* Update for 0.22 glutin API changes:
* Move game logic into event loop, run() replacing poll_events()
* Specify fullscreen Borderless mode
* Pass generic parameter of Event through handle_window_event
* hidpi_factor() replaces get_hidpi_factor()
* with_inner_size() replaces with_dimensions()
* No longer need to unwrap() LogicalSize
* set_cursor_grab/visible() replaces grab/hide_cursor()
* Fix modifiers deprecated warnings by destructuring only event fields we use, ignoring the rest with '..'
* Remove unnecessary mutability from events_loop
* Listen for ModifiersChanged event, fixing deprecated modifiers field
* Change to stdweb for web backend, replacing web-sys
* Pin to glutin =0.22.0-alpha5 and winit =0.20.0-alpha6
* Closes#237 Bump base64 from 0.10.1 to 0.11.0
* Closes#241 Bump flate2 from 1.0.12 to 1.0.13
* Closes#245 Bump num-traits from 0.2.8 to 0.2.10
* Closes#248 Bump serde_json from 1.0.41 to 1.0.44
* Closes#249 Bump serde from 1.0.102 to 1.0.104
* Closes#251 Bump web-sys from 0.3.30 to 0.3.33
* Closes#254 Bump structopt from 0.3.3 to 0.3.7
* Bump cfg-if from 0.1.9 to 0.1.10
* `cargo update` all modules
Reduce to "basic optimizations" for the steven_blocks module, so it
doesn't take hours of time and gigabytes of memory to compile. The main
program and other code still builds with full optimizations in release
mode, to accomplish this, the profile-overrides feature is required so
we also switch to nightly Rust (to be switched to 1.41+ in #258).
* Update to rustc 1.42.0-nightly (760ce94c6 2020-01-04)
* Update builds.sr.ht to use +nightly
* Override opt-level=1 for steven_blocks using profile-overrides
The Display trait is already implemented, so this is only a code
deletion. Fixes 1.42-nightly warning:
warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
--> src/protocol/mod.rs:981:40
|
981 | Error::IOError(ref e) => e.description(),
| ^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
The Display trait is already implemented, so this is only a code
deletion. Fixes 1.42-nightly warning:
warning: use of deprecated item 'std::error::Error::description': use the Display impl or to_string()
--> src/protocol/mod.rs:981:40
|
981 | Error::IOError(ref e) => e.description(),
| ^^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default
warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
--> src/entity/player.rs:363:11
|
363 | ].into_iter().enumerate() {
| ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
Closes#196 Bump web-sys from 0.3.24 to 0.3.25
Closes#200 Bump reqwest from 0.9.18 to 0.9.19
Closes#202 Bump log from 0.4.6 to 0.4.8
Closes#203 Bump serde from 1.0.94 to 1.0.98
Closes#187 Bump web-sys from 0.3.22 to 0.3.24
Closes#188 Bump flate2 from 1.0.7 to 1.0.9
Closes#189 Bump structopt from 0.2.16 to 0.2.18
Closes#190 Bump serde from 1.0.92 to 1.0.94
Closes#192 Bump serde_json from 1.0.39 to 1.0.40
`cargo update` updates smallvec (and others) used by collision:
Closes#193 [Security] Bump smallvec from 0.6.9 to 0.6.10
Previously, only the * and + operators were available, for 0 or more and
1 or more, respectively, so steven_blocks used * for optional tokens
even though only one would be expected in most cases.
Rust version 1.32.0 added a new operator, ?, for zero or one:
https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1320-2019-01-17
> You can now use the ? operator in macro definitions. The ? operator allows
> you to specify zero or one repetitions similar to the * and + operators.
https://github.com/rust-lang/rust/pull/56245/
Change to use ? instead of * for these optional repetitions.
Found this while investigating #174.
From investigation for #115, now three targets:
- wasm32-unknown-unknown: build with `wasm-pack build`, uses
the #[wasm_bindgen] directive on main()
- wasm32-wasi: build with `cargo +nightly build --target wasm32-wasi`,
requires normal main()
- native targets: same as wasm32-wasi
Logging from the `log` facade goes to the colorized in-game GUI console (opened with the backtick key), as well as standard output using `println!` on the native build. To make this work on the wasm build, web-sys is used to access the `console` object, to call `console.log`, `console.warn`, and so on corresponding to the log levels. Extends #92, fails later (see also #115) but now outputs the starting up message:
[main.rs:206][INFO] Starting steven
* Add println! logging to console.log on wasm
* Initialize logger before config (called 'console variables' for some reason) to avoid having to disable it to reach the first logging statement
* Add web-sys crate for browser console access, wasm32-only
* Refactor logger to call println_level on both web/native
* Add multiple log levels, console.warn etc., matching console_log crate
https://github.com/iamcodemaker/console_log#details
Updating the glutin dependency to a 0.21.0-based branch, based on the migration guide at:
https://gentz.rocks/posts/glutin-v0-21-0-migration-guide/
* Remove glutin::ContextTrait
* Create window with ContextBuilder instead of WindowedContext::new
* Add .window() accessor on WindowContext, since it now dereferences to Context
In order to not break wasm32-unknown-unknown compilation, a minor fork is used of glutin v0.21.0 and a corresponding version of winit: https://github.com/iceiix/glutin/pull/1https://github.com/iceiix/winit/pull/2
- with stubs to compile (but not run, see issue #115)
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:
https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)
This makes use of the Forge handshake (#88#134#144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.
Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.
* Add `modid` macro token, skipped from vanilla mappings
* Add ThermalExpansionRockwool block (1.7.10)
* Register modded blocks by modid->[data], and lookup block metadata
* Save block IDs from ModIdData/RegistryData to World modded_block_ids
* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item
* Add ThermalFoundation's Rockwool (1.12.2)
The first in support for modded content, a simple custom block: "rockwool" from the Thermal Expansion and Thermal Foundation mods for Forge:
https://ftb.gamepedia.com/Rockwool_(Thermal_Expansion_3)
This makes use of the Forge handshake (#88#134#144), matching the mod block names from the negotiation to numeric identifiers in the world to steven_blocks. Rockwool was chosen due to ease of implementation, it looks like wool from vanilla (except is fire-proof), and by supporting it the groundwork necessary is laid for more sophisticated mod support.
Tested with Thermal Expansion on 1.7.10, 1.10.2 (FTB Beyond), and 1.12.2 Forge servers.
* Add `modid` macro token, skipped from vanilla mappings
* Add ThermalExpansionRockwool block (1.7.10)
* Register modded blocks by modid->[data], and lookup block metadata
* Save block IDs from ModIdData/RegistryData to World modded_block_ids
* Add namespaced mod ids for ModIdData, \u{1}=block \u{2}=item
* Add ThermalFoundation's Rockwool (1.12.2)
Leave the advancements packet as an opaque blob for now instead of trying to deserialize it, because it apparently is changed on some modded servers - see https://github.com/iceiix/stevenarella/issues/148
Leave the advancements packet as an opaque blob for now instead of trying to deserialize it, because it apparently is changed on some modded servers - see https://github.com/iceiix/stevenarella/issues/148
See c1692e950a
There are two more instances, encountered when debugging #148
> Instead of read_to_string(), use read_to_end() to read into a buffer,
> then convert using String::from_utf8() and unwrap it. This gives a
> better error message when UTF-8 fails to decode.
which includes the offending bytes that can't be converted
See c1692e950a
There are two more instances, encountered when debugging #148
> Instead of read_to_string(), use read_to_end() to read into a buffer,
> then convert using String::from_utf8() and unwrap it. This gives a
> better error message when UTF-8 fails to decode.
which includes the offending bytes that can't be converted
See c1692e950a
There are two more instances, encountered when debugging #148
> Instead of read_to_string(), use read_to_end() to read into a buffer,
> then convert using String::from_utf8() and unwrap it. This gives a
> better error message when UTF-8 fails to decode.
which includes the offending bytes that can't be converted
Previously, the zlib compressor was initialized once, lazily, then reused for each packet by resetting the stream. This didn't properly emit the zlib headers, so packet compression was broken and caused "java.util.zip.DataFormatException: incorrect header check" on the server. Since packets are only compressed above a threshold, this problem manifested itself only on larger servers, such as 1.10.2 FTB Beyond and Skyfactory 3, and 1.12.2 SevTech: Ages, which require sending a large ModList above the compression threshold enabled by the server. Change to instead recreate the zlib compressor, each time it is used as to capture the full header. For symmetry, the decompressor is also recreated each time.
* Removes self.compression_write and self.compression_read instance variables
* Remove self.compression_write, initialize with cursor
* Log compressing/decompressing packets in network debug mode
Previously, the zlib compressor was initialized once, lazily, then reused for each packet by resetting the stream. This didn't properly emit the zlib headers, so packet compression was broken and caused "java.util.zip.DataFormatException: incorrect header check" on the server. Since packets are only compressed above a threshold, this problem manifested itself only on larger servers, such as 1.10.2 FTB Beyond and Skyfactory 3, and 1.12.2 SevTech: Ages, which require sending a large ModList above the compression threshold enabled by the server. Change to instead recreate the zlib compressor, each time it is used as to capture the full header. For symmetry, the decompressor is also recreated each time.
* Removes self.compression_write and self.compression_read instance variables
* Remove self.compression_write, initialize with cursor
* Log compressing/decompressing packets in network debug mode
Adds support for connecting to Forge servers from 1.8.9 up to 1.12.2.
(1.7.10 was already supported with #134#88)
Tested on:
- 1.8.9 + forge 11.15.1.2318 + ironchest
- 1.10.2 + forge 12.18.3.2511 + ironchest
- 1.11.2 + forge 13.20.1.2588 + ironchest
- 1.12.2 + forge 14.23.5.2837 + ironchest
Changes:
* Parse and handle FmlHs::RegistryData packet for 1.8+
* Fix RegistryData acknowledgement phase WaitingServerComplete
* Fix acknowledgement phase for 1.7.10 ModIdData too, somehow it worked accidentally
* Append \0FML\0 to end of server hostname if Forge mods detected
https://wiki.vg/Minecraft_Forge_Handshake#Connection_to_a_forge_server
Adds support for connecting to Forge servers from 1.8.9 up to 1.12.2.
(1.7.10 was already supported with #134#88)
Tested on:
- 1.8.9 + forge 11.15.1.2318 + ironchest
- 1.10.2 + forge 12.18.3.2511 + ironchest
- 1.11.2 + forge 13.20.1.2588 + ironchest
- 1.12.2 + forge 14.23.5.2837 + ironchest
Changes:
* Parse and handle FmlHs::RegistryData packet for 1.8+
* Fix RegistryData acknowledgement phase WaitingServerComplete
* Fix acknowledgement phase for 1.7.10 ModIdData too, somehow it worked accidentally
* Append \0FML\0 to end of server hostname if Forge mods detected
https://wiki.vg/Minecraft_Forge_Handshake#Connection_to_a_forge_server
1.8+ removes the player head position, and sends only the feet position.
We store the feet position internally in the client, so the head
position has to be calculated, normally 1.62 units higher. Previously
the calculation was reversed, which caused the client to show its
position as 1.62 units higher than the server, and the server would
correct the position when the client descends to the ground.
1.7.10: https://wiki.vg/index.php?title=Protocol&oldid=6003#Player_Position
1.8.9: https://wiki.vg/index.php?title=Protocol&oldid=7368#Player_Position
Movement packets were handled incorrectly, because although the fields are specified as integers they are actually fixed-point values, which need to be converted to floating-point before use. These fields were converted with `as f64`, but they actually need to be scaled. To fix this add several new types, FixedPoint5 for 5-bit fractional fixed-point and FixedPoint12 for 12-bit. Both are parameterized by an integer type: FixedPoint5<i32> and FixedPoint5<i8> for 1.7.10/1.8.9, FixedPoint12<i16> for 1.9+. This moves the calculation into the packet field parsing, so it no longer has to be calculated in src/server/mod.rs since the scaling is taken care of as part of the field type. This fixes the long-standing invisible or actually misplaced players bug on 1.7.10 and 1.8.9, closes#139.
* Add new FixedPoint5<T> type for 1.7/8, https://wiki.vg/Data_types#Fixed-point_numbers
* Add FixedPoint12<i16> for 1.9+, moving type conversion into packet type
https://wiki.vg/index.php?title=Protocol#Entity_Relative_Move
* Add num-traits 0.2.6 dependency for NumCast to use instead of From
* Use FixedPoint5<i32> in spawn object, experience orb, global entity, mob, player, teleport
* Use FixedPoint5<i8> and FixedPoint12<i16> in entity move, look and move
* Update packet handling bouncer functions, using f64::from for each conversion
Movement packets were handled incorrectly, because although the fields are specified as integers they are actually fixed-point values, which need to be converted to floating-point before use. These fields were converted with `as f64`, but they actually need to be scaled. To fix this add several new types, FixedPoint5 for 5-bit fractional fixed-point and FixedPoint12 for 12-bit. Both are parameterized by an integer type: FixedPoint5<i32> and FixedPoint5<i8> for 1.7.10/1.8.9, FixedPoint12<i16> for 1.9+. This moves the calculation into the packet field parsing, so it no longer has to be calculated in src/server/mod.rs since the scaling is taken care of as part of the field type. This fixes the long-standing invisible or actually misplaced players bug on 1.7.10 and 1.8.9, closes#139.
* Add new FixedPoint5<T> type for 1.7/8, https://wiki.vg/Data_types#Fixed-point_numbers
* Add FixedPoint12<i16> for 1.9+, moving type conversion into packet type
https://wiki.vg/index.php?title=Protocol#Entity_Relative_Move
* Add num-traits 0.2.6 dependency for NumCast to use instead of From
* Use FixedPoint5<i32> in spawn object, experience orb, global entity, mob, player, teleport
* Use FixedPoint5<i8> and FixedPoint12<i16> in entity move, look and move
* Update packet handling bouncer functions, using f64::from for each conversion
std::convert::From<usize> cannot be used here because we cannot
implement bool<->usize conversions, due to Rust's orphan rules:
http://smallcultfollowing.com/babysteps/blog/2015/01/14/little-orphan-impls/
"prevent you from implementing external traits for external types"
Nonetheless, Lengthable used the same methods as From. This is allowed
but can require disambiguation if both are used, no longer strictly
needed for #140 but to reduce confusion and improve clarity, renamed
`from` to `from_len` and `into` to `into_len`.
std::convert::From<usize> cannot be used here because we cannot
implement bool<->usize conversions, due to Rust's orphan rules:
http://smallcultfollowing.com/babysteps/blog/2015/01/14/little-orphan-impls/
"prevent you from implementing external traits for external types"
Nonetheless, Lengthable used the same methods as From. This is allowed
but can require disambiguation if both are used, no longer strictly
needed for #140 but to reduce confusion and improve clarity, renamed
`from` to `from_len` and `into` to `into_len`.