Commit Graph

858 Commits

Author SHA1 Message Date
iceiix 87e0726f3f
blocks: split macro into multiple functions, fast! (#267)
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
2020-01-09 20:08:28 -08:00
ice_iix b563ca4394 protocol: atomics replace unsafe for version/debug. Closes #261 2020-01-08 18:57:57 -08:00
ice_iix e834ee2f53 protocol: atomics replace unsafe for version/debug. Closes #261 2020-01-08 18:57:57 -08:00
ice_iix 643de31073 protocol: atomics replace unsafe for version/debug. Closes #261 2020-01-08 18:57:57 -08:00
ice_iix 90f7d9afd9 Update sha-1 and zip dependencies
Closes #263 Bump sha-1 from 0.8.1 to 0.8.2
Closes #265 Bump zip from 0.5.3 to 0.5.4
2020-01-07 19:31:10 -08:00
ice_iix 15499ee95e steven_gl: update gl_generator, khronos_api, libc 2020-01-05 18:45:00 -08:00
iceiix a020ed6f2c
Update to glutin 0.22.0-alpha5, remove wasm_stub (#260)
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
2020-01-05 17:56:32 -08:00
iceiix 9077c22304 Update to reqwest 0.10.0. Closes #259
* Bump reqwest from 0.9.22 to 0.10.0

* Use blocking reqwest API instead of futures, for now
2020-01-05 10:38:21 -08:00
iceiix 8ab981f3ad
Update to reqwest 0.10.0. Closes #259
* Bump reqwest from 0.9.22 to 0.10.0

* Use blocking reqwest API instead of futures, for now
2020-01-05 10:38:21 -08:00
ice_iix b307843d2b Change to PCG random number generator algorithm
See http://www.pcg-random.org/ for benefits of PCG over xorshift
Updates #236 #183
2020-01-05 10:01:44 -08:00
ice_iix 6c32fce5a3 Update rand to 0.7.2 and rand_xorshift 0.2.0. Closes #236, closes #183 2020-01-05 09:49:03 -08:00
ice_iix cfbcf71b40 Bump image from 0.21.3 to 0.22.3. Closes #238 2020-01-05 09:10:59 -08:00
ice_iix 3f5f02db93 Update dependencies: base64, flate2, num-traits, and more (#257)
* 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
2020-01-05 08:00:55 -08:00
ice_iix e04ee876f3 Nightly rust, steven_blocks: reduce optimizations in release. Fixes #184 (#255)
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
2020-01-05 07:16:10 -08:00
ice_iix a833ef7bf5 Remove deprecated Error description, replaced by Display
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
2020-01-04 19:35:18 -08:00
ice_iix e435daf959 Remove deprecated Error description, replaced by Display
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
2020-01-04 19:35:18 -08:00
ice_iix 20bcddfb13 Replace into_iter() -> iter() for arrays, fixes 1.42-nightly warning
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>
2020-01-04 19:33:05 -08:00
ice_iix 8502c031f8 Update to Rust 1.40.0. Closes #253
* Update mem::uninitialized to MaybeUninit

* Update to Rust version 1.40 in AppVeyor

* Update readme for Rust version requirement
2020-01-04 17:26:26 -08:00
ice_iix afa100313c Correct minimum Rust version requirement in readme, updates #235 2020-01-04 17:20:28 -08:00
ice_iix 248c276f3d steven_blocks: update lazy_static to 1.4.0 2020-01-04 12:21:03 -08:00
ice_iix b7a8fbf8f6 steven_blocks: cargo update. Closes #256 2020-01-04 12:19:54 -08:00
ice_iix dd2fb32df1 1.15.1 protocol support (575) (#252)
* Add v1_15_1 for protocol 575

* Update for shifted packet IDs

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=15213#Packets
https://wiki.vg/Pre-release_protocol

* Add SpawnMob packet variant, no metadata

* Add SpawnPlayer packet variant, no metadata

* Add block update actions comments, including beehive

* Add particle packet variant with 64-bit floats

* Add and handle join game and respawn packet variants, with hashed seeds

* Add chunk data packet variant with 3D biomes

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=15213#Chunk_Data
"1024 biome IDs, ordered by x then z then d, in 4×4×4 blocks. Not
present if full chunk is false."

This is a fixed-size array of integers, but Rust doesn't yet support
generics over integers, so the 1024-element array doesn't support
fmt::Debug, hence we wrap it and implement fmt::Debug ourselves.

* Add load_chunk115 to not read chunk data structure biomes

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=15213#Data_structure
2019-12-29 15:55:19 -08:00
ice_iix 2daca512b0 1.15.1 protocol support (575) (#252)
* Add v1_15_1 for protocol 575

* Update for shifted packet IDs

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=15213#Packets
https://wiki.vg/Pre-release_protocol

* Add SpawnMob packet variant, no metadata

* Add SpawnPlayer packet variant, no metadata

* Add block update actions comments, including beehive

* Add particle packet variant with 64-bit floats

* Add and handle join game and respawn packet variants, with hashed seeds

* Add chunk data packet variant with 3D biomes

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=15213#Chunk_Data
"1024 biome IDs, ordered by x then z then d, in 4×4×4 blocks. Not
present if full chunk is false."

This is a fixed-size array of integers, but Rust doesn't yet support
generics over integers, so the 1024-element array doesn't support
fmt::Debug, hence we wrap it and implement fmt::Debug ourselves.

* Add load_chunk115 to not read chunk data structure biomes

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=15213#Data_structure
2019-12-29 15:55:19 -08:00
ice_iix 3da354def4 Update to Rust 1.38.0 in AppVeyor. Closes #235 2019-11-02 15:46:16 -07:00
ice_iix 49f2582a50 Fix warning: `...` range patterns are deprecated 2019-11-02 15:46:10 -07:00
ice_iix c88631b124 Fix bare trait objects warning, add explicit `dyn` 2019-11-02 15:46:06 -07:00
ice_iix 3946f22863 Update serde, image, hex, lazy_static, structopt..
* serde 1.1.0.2, closes #233
* image 0.21.3, closes #221
* hex 0.4.0, closes #225
* lazy_static 1.4.0, closes #217
* structopt 0.3.3, closes #231
  * Requires rustc 1.36+, updated in previous commit
* reqwest 0.9.22, closes #230
* cargo update, closes #219
2019-11-02 14:24:50 -07:00
ice_iix 1b668242d0 Update to Rust 1.36.0 on AppVeyor 2019-11-02 14:18:01 -07:00
ice_iix 7c49ca3c0d Add missing time, nbt{_compound,}_tag command nodes. Fixes #227 2019-11-02 13:43:00 -07:00
ice_iix 6723c75ab4 Add missing time, nbt{_compound,}_tag command nodes. Fixes #227 2019-11-02 13:43:00 -07:00
iceiix 57da39bb79 Fix SpawnPainting parsing 1.13.2-1.14.4, closes #212 (#213)
The packet changed in 1.13.2 but wasn't updated, so we split the packet
variants into SpawnPainting_String for the old version and
SpawnPainting_VarInt for the new version with a 'motive' VarInt field
instead of a String title.

1.9-1.12.2 SpawnPainting_String: https://wiki.vg/index.php?title=Protocol&oldid=14204#Spawn_Painting
1.13.2-1.14.4 SpawnPainting_VarInt: https://wiki.vg/index.php?title=Protocol&oldid=14889#Spawn_Painting
2019-08-17 13:36:07 -07:00
iceiix d24b6cb599
Fix SpawnPainting parsing 1.13.2-1.14.4, closes #212 (#213)
The packet changed in 1.13.2 but wasn't updated, so we split the packet
variants into SpawnPainting_String for the old version and
SpawnPainting_VarInt for the new version with a 'motive' VarInt field
instead of a String title.

1.9-1.12.2 SpawnPainting_String: https://wiki.vg/index.php?title=Protocol&oldid=14204#Spawn_Painting
1.13.2-1.14.4 SpawnPainting_VarInt: https://wiki.vg/index.php?title=Protocol&oldid=14889#Spawn_Painting
2019-08-17 13:36:07 -07:00
ice_iix 80006d9212 Update web-sys, zip, flate2 dependencies
Closes #209 Bump web-sys from 0.3.25 to 0.3.26
Closes #210 Bump zip from 0.5.2 to 0.5.3
Closes #211 Bump flate2 from 1.0.9 to 1.0.11
2019-08-17 13:34:32 -07:00
iceiix 40c7a64c45 1.13+: Fix parsing Teams packet. Closes #205 (#208)
* Add Teams_VarInt packet variant for 1.13+

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150#Teams

* Rename the variant for 1.9-1.12.2 to Teams_u8
2019-08-11 17:46:34 -07:00
iceiix d1f88c9797
1.13+: Fix parsing Teams packet. Closes #205 (#208)
* Add Teams_VarInt packet variant for 1.13+

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14150#Teams

* Rename the variant for 1.9-1.12.2 to Teams_u8
2019-08-11 17:46:34 -07:00
iceiix a095e26a22 1.14.4 protocol support (498) (#207)
* Add protocol 498 for 1.14.4

* Add 0x5c AcknowledgePlayerDigging packet, https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14870#Acknowledge_Player_Digging

* Add new demand field in protocol::Trade

https://wiki.vg/index.php?title=Pre-release_protocol&type=revision&diff=14862&oldid=14856
MC-151282 - Villager trade GUI does not show the correct price on servers if trade demand is high
2019-08-11 17:26:20 -07:00
iceiix 45099165d9
1.14.4 protocol support (498) (#207)
* Add protocol 498 for 1.14.4

* Add 0x5c AcknowledgePlayerDigging packet, https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14870#Acknowledge_Player_Digging

* Add new demand field in protocol::Trade

https://wiki.vg/index.php?title=Pre-release_protocol&type=revision&diff=14862&oldid=14856
MC-151282 - Villager trade GUI does not show the correct price on servers if trade demand is high
2019-08-11 17:26:20 -07:00
ice_iix 862c40c59d Update dependencies: web-sys, reqwest, log, serde
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
2019-08-11 16:18:57 -07:00
ice_iix 9066b19031 Allow Cmd modifier as alternative to Ctrl, closes #206 2019-08-11 16:15:36 -07:00
dependabot[bot] 095ae1f6ab Bump lodash from 4.17.11 to 4.17.15 in /www (#201)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-27 17:50:33 -07:00
iceiix c0849e4a29 1.14.3 protocol support (490) (#194)
* Copy v1_14_3 from v1_14_2

* Add protocol 490 for v1_14_3

* Add missing 1.14 release TradeList packet fields

TradeList only had fields from the prerelease:
19w02a (452): https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14515#Trade_List

add the six missing fields present in the 1.14 release:
1.14 (477): https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14752#Trade_List

Note this breaks 19w02a TradeList parsing, can be fixed by splitting the
packet for 19w02a/1.14 if needed later.

* Add TradeList_WithRestock variant with new can_restock field
2019-07-07 14:58:49 -07:00
iceiix 95a9920cb6
1.14.3 protocol support (490) (#194)
* Copy v1_14_3 from v1_14_2

* Add protocol 490 for v1_14_3

* Add missing 1.14 release TradeList packet fields

TradeList only had fields from the prerelease:
19w02a (452): https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14515#Trade_List

add the six missing fields present in the 1.14 release:
1.14 (477): https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14752#Trade_List

Note this breaks 19w02a TradeList parsing, can be fixed by splitting the
packet for 19w02a/1.14 if needed later.

* Add TradeList_WithRestock variant with new can_restock field
2019-07-07 14:58:49 -07:00
ice_iix 2a3be38407 npm update www dependencies. Closes #182 2019-07-04 15:25:02 -07:00
ice_iix 8c0350eb7c Update web-sys, flate2, structopt, serde/json, and minor deps
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
2019-07-02 19:08:50 -07:00
ice_iix 115560ce82 Update byteorder, serde, image, reqwest
Closes #181, closes #178, closes #179, closes #180
2019-06-10 17:09:19 -07:00
ice_iix eecd5631db Add builds.sr.ht build status badge to readme
Updates #176, replacing Travis-CI due to #173
2019-05-31 09:30:04 -07:00
dependabot-preview[bot] f52913ee86 Bump structopt from 0.2.15 to 0.2.16 (#172)
Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.2.15 to 0.2.16.
- [Release notes](https://github.com/TeXitoi/structopt/releases)
- [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md)
- [Commits](https://github.com/TeXitoi/structopt/compare/v0.2.15...v0.2.16)
2019-05-31 09:24:49 -07:00
iceiix 6d0da658ed
Add .build.yml file for builds.sr.ht SourceHut CI (#176) 2019-05-31 09:23:13 -07:00
ice_iix d729039849 steven_blocks: Use the ? operator instead of * in macro
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.
2019-05-30 18:31:23 -07:00
ice_iix 74d37d7150 Fix redundant imports on rustc 0.35.0. Fixes #175 2019-05-30 18:13:54 -07:00
ice_iix 19948ff397 Fix redundant imports on rustc 0.35.0. Fixes #175 2019-05-30 18:13:54 -07:00
iceiix 75b94356d2 1.14.2 protocol support (485) (#170)
* Add protocol 1.14.2 (485)

* Copy v1_14_2 from v1_14_1

* Update readme for protocol support
2019-05-29 08:22:45 -07:00
iceiix 0fbcb192d8
1.14.2 protocol support (485) (#170)
* Add protocol 1.14.2 (485)

* Copy v1_14_2 from v1_14_1

* Update readme for protocol support
2019-05-29 08:22:45 -07:00
iceiix 8faeb9f5cc wasm: Fix operation not supported on std::fs. Closes #115 (#166)
* Add new web-based std::fs replacement, localstoragefs:

https://github.com/iceiix/localstoragefs

* Add std_or_web to switch between std::fs (native) or localstoragefs (web)

* Update www readme for new missing glutin/winit links, opens issue #171
2019-05-29 08:21:56 -07:00
iceiix 836ab9f126
wasm: Fix operation not supported on std::fs. Closes #115 (#166)
* Add new web-based std::fs replacement, localstoragefs:

https://github.com/iceiix/localstoragefs

* Add std_or_web to switch between std::fs (native) or localstoragefs (web)

* Update www readme for new missing glutin/winit links, opens issue #171
2019-05-29 08:21:56 -07:00
ice_iix 3eee3e9163 Fix dual-license MIT/Apache-2.0 syntax in Cargo.toml 2019-05-29 08:13:38 -07:00
ice_iix d7340007a0 Use super:: relative instead of crate::protocol absolute import paths 2019-05-25 14:09:09 -07:00
ice_iix 367c3e5e09 Use super:: relative instead of crate::protocol absolute import paths 2019-05-25 14:09:09 -07:00
dependabot-preview[bot] ef334643cc Bump num-traits from 0.2.7 to 0.2.8 (#165)
Bumps [num-traits](https://github.com/rust-num/num-traits) from 0.2.7 to 0.2.8.
- [Release notes](https://github.com/rust-num/num-traits/releases)
- [Changelog](https://github.com/rust-num/num-traits/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-traits/compare/num-traits-0.2.7...num-traits-0.2.8)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-05-24 19:00:29 -07:00
ice_iix 1125c3883d Conditionalize wasm_bindgen to fix compile error on wasm32-wasi
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
2019-05-22 18:12:10 -07:00
dependabot[bot] 51aa361bbc Bump num-traits from 0.2.6 to 0.2.7 (#162)
Bumps [num-traits](https://github.com/rust-num/num-traits) from 0.2.6 to 0.2.7.
- [Release notes](https://github.com/rust-num/num-traits/releases)
- [Changelog](https://github.com/rust-num/num-traits/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-traits/compare/num-traits-0.2.6...num-traits-0.2.7)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-05-22 17:29:39 -07:00
ice_iix c6b753bc9a Update to patched glutin wasm_stub allowing compiling for wasi
Includes 1e48d3216e

Progress towards #115, fixes the missing glutin symbols when compiling
with cargo +nightly build --target wasm32-wasi
2019-05-22 17:28:27 -07:00
iceiix fd7add3f17
wasm: log output to browser JavaScript console (#163)
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
2019-05-22 16:12:43 -07:00
ice_iix bdf18cc6d4 Replace println! with log crate facade macros info!, debug!, etc. 2019-05-22 16:01:14 -07:00
ice_iix fd028d41b0 Replace println! with log crate facade macros info!, debug!, etc. 2019-05-22 16:01:14 -07:00
iceiix 8071db668c
Update to glutin 0.21.0. Closes #157 (#160)
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/1 https://github.com/iceiix/winit/pull/2
 - with stubs to compile (but not run, see issue #115)
2019-05-19 17:58:08 -07:00
ice_iix 9ceddc5057 Fix toggling fullscreen with F11 initially. Closes #156 2019-05-19 11:43:36 -07:00
dependabot[bot] 381815ce22 Bump reqwest from 0.9.16 to 0.9.17 (#158)
Bumps [reqwest](https://github.com/seanmonstar/reqwest) from 0.9.16 to 0.9.17.
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.9.16...v0.9.17)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-05-19 11:35:47 -07:00
dependabot[bot] f8e59a74bb Bump wasm-bindgen from 0.2.43 to 0.2.44 (#159)
Bumps [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) from 0.2.43 to 0.2.44.
- [Release notes](https://github.com/rustwasm/wasm-bindgen/releases)
- [Changelog](https://github.com/rustwasm/wasm-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rustwasm/wasm-bindgen/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-05-19 11:35:09 -07:00
iceiix c532c31530 Add support for a modded block: rockwool from Thermal Expansion (#153)
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)
2019-05-15 12:49:57 -07:00
iceiix e9b336192a Add support for a modded block: rockwool from Thermal Expansion (#153)
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)
2019-05-15 12:49:57 -07:00
ice_iix 3bbab7a128 Refactor recipe parsing minecraft: prefix, related to #155 2019-05-15 12:49:50 -07:00
ice_iix 480b865363 Refactor recipe parsing minecraft: prefix, related to #155 2019-05-15 12:49:50 -07:00
dependabot[bot] b244406850 Bump cfg-if from 0.1.7 to 0.1.9 (#154)
Bumps [cfg-if](https://github.com/alexcrichton/cfg-if) from 0.1.7 to 0.1.9.
- [Release notes](https://github.com/alexcrichton/cfg-if/releases)
- [Commits](https://github.com/alexcrichton/cfg-if/compare/0.1.7...0.1.9)

Signed-off-by: dependabot[bot] <support@dependabot.com>
2019-05-15 07:57:45 -07:00
ice_iix 5e0f78d6e2 Update Cargo.lock for steven_blocks for #138
Missed this in the blocks/Cargo.toml update #97 #126 #138, automatic
2019-05-14 17:23:28 -07:00
iceiix 5467304bcf Disable parsing advancements to fix 1.12.2 Forge SevTech crash (#148) (#149)
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
2019-05-13 17:13:22 -07:00
iceiix 8d4d606873
Disable parsing advancements to fix 1.12.2 Forge SevTech crash (#148) (#149)
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
2019-05-13 17:13:22 -07:00
iceiix 1a600c7192 1.14.1 protocol support (480) (#151)
* Copy v1_14_1 from v1_14

* Add protocol 1.14.1 (480)

* Update readme

* 0x08 serverbound is now ClickWindowButton

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14764#Click_Window_Button
2019-05-13 16:45:41 -07:00
iceiix 599227aef2 1.14.1 protocol support (480) (#151)
* Copy v1_14_1 from v1_14

* Add protocol 1.14.1 (480)

* Update readme

* 0x08 serverbound is now ClickWindowButton

https://wiki.vg/index.php?title=Pre-release_protocol&oldid=14764#Click_Window_Button
2019-05-13 16:45:41 -07:00
ice_iix 604a09b3ce Enhance -p/--protocol-version to accept game version string
Now you can pass `-p 1.7.10` as an alternative to `-p 5`, etc
2019-05-13 16:35:39 -07:00
ice_iix 1274a75f81 Enhance -p/--protocol-version to accept game version string
Now you can pass `-p 1.7.10` as an alternative to `-p 5`, etc
2019-05-13 16:35:39 -07:00
ice_iix f15ece0377 Replace read_to_string -> read_to_end to improve UTF-8 deserialization
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
2019-05-12 14:08:53 -07:00
ice_iix 16886110be Replace read_to_string -> read_to_end to improve UTF-8 deserialization
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
2019-05-12 14:08:53 -07:00
ice_iix 10e5d6f441 Replace read_to_string -> read_to_end to improve UTF-8 deserialization
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
2019-05-12 14:08:53 -07:00
iceiix 83c848fa6f Fix packet compression (fixes FTB Beyond, etc.). Closes #146 (#147)
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
2019-05-12 12:15:02 -07:00
iceiix b98ba3afd2
Fix packet compression (fixes FTB Beyond, etc.). Closes #146 (#147)
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
2019-05-12 12:15:02 -07:00
iceiix 2451e780bd Forge 1.8.9-1.12.2 handshake protocol support (#144)
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
2019-05-11 18:37:33 -07:00
iceiix 0cd02fd2da
Forge 1.8.9-1.12.2 handshake protocol support (#144)
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
2019-05-11 18:37:33 -07:00
ice_iix a081c73215 1.7.10: Fix player position too high on login. Closes #87
Adds a new TeleportPlayer_NoGround packet, which is subtly different
from TeleportPlayer_NoConfirm. The flags u8 is replaced with an
on_ground bool, but more importantly the Y position is the eyes
position, so we have to translate to feet position for the client.

1.7.10: https://wiki.vg/index.php?title=Protocol&oldid=6003#Player_Position_And_Look
1.8.9: https://wiki.vg/index.php?title=Protocol&oldid=7368#Player_Position_And_Look
2019-05-11 14:53:42 -07:00
ice_iix ba4a7a9d85 1.7.10: Fix player position too high on login. Closes #87
Adds a new TeleportPlayer_NoGround packet, which is subtly different
from TeleportPlayer_NoConfirm. The flags u8 is replaced with an
on_ground bool, but more importantly the Y position is the eyes
position, so we have to translate to feet position for the client.

1.7.10: https://wiki.vg/index.php?title=Protocol&oldid=6003#Player_Position_And_Look
1.8.9: https://wiki.vg/index.php?title=Protocol&oldid=7368#Player_Position_And_Look
2019-05-11 14:53:42 -07:00
ice_iix a159355751 1.7.10: Fix sending head/feet player position, #87
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
2019-05-11 14:24:41 -07:00
iceiix 0034756339 Fix movement fixed-point packets, misplaced players on 1.7/8 (#140)
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
2019-05-11 13:28:25 -07:00
iceiix c8e13c38bd Fix movement fixed-point packets, misplaced players on 1.7/8 (#140)
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
2019-05-11 13:28:25 -07:00
ice_iix 72d73f529f Change Lengthable trait method names to into_len/from_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`.
2019-05-11 13:03:24 -07:00
ice_iix 87bfb8d2a4 Change Lengthable trait method names to into_len/from_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`.
2019-05-11 13:03:24 -07:00
iceiix 185f3d0297
Update cgmath and collision. Closes #97, closes #126 (#138)
* Update cgmath and collision. Closes #97, closes #126

* Update steven_blocks cgmath/collision

* Run cargo update
2019-05-10 15:39:56 -07:00
ice_iix 99a4e77a11 Update wasm-bindgen and cargo update. Closes #133 2019-05-08 20:01:06 -07:00
ice_iix b1cae32eed Update to rand 0.6.5 and migrate off deprecated methods. Closes #81
* Import from rand_xorshift crate

* Use shuffle/choose from SliceRandom trait

See https://rust-random.github.io/book/update-0.6.html
2019-05-08 19:32:05 -07:00
ice_iix 04246d4c88 Fix non-JSON sign text rendering, such as on 1.7.10. Closes #135
src/format.rs Component from_string() attempts JSON deserialization
using serde_json::from_str, and if it fails falls back to a literal text
string. Call from_string() instead of deserializing in format::Component
read_from() and then from_value(). Note the from_string() comment:

    // Sometimes mojang sends a literal string, so we should interpret it literally
2019-05-08 19:12:36 -07:00
ice_iix de25096a6b Fix non-JSON sign text rendering, such as on 1.7.10. Closes #135
src/format.rs Component from_string() attempts JSON deserialization
using serde_json::from_str, and if it fails falls back to a literal text
string. Call from_string() instead of deserializing in format::Component
read_from() and then from_value(). Note the from_string() comment:

    // Sometimes mojang sends a literal string, so we should interpret it literally
2019-05-08 19:12:36 -07:00