Commit Graph

56 Commits

Author SHA1 Message Date
Nathan Ruiz ee8e6cb9f3 Fix formatting 2022-10-30 21:46:21 +00:00
Nathan Ruiz d601ec3907 Add data to blocks required for digging 2022-09-27 07:07:22 +00:00
ice_iix a90a6af7c2 Update to Rust 2021 2021-12-24 09:32:56 -08:00
ice_iix 9ae87f9340 Update to Rust 1.53.0 2021-06-18 19:32:09 -07:00
iceiix abbc58b9ef
deps: update reqwest, wasm-bindgen, serde_json, image (#516)
* Bump reqwest to 0.11.1, closes #504

* Bump wasm-bindgen to 0.2.71, closes #513

* Bump serde_json to 1.0.64, closes #514

* Bump image to 0.23.14, closes #515

* cargo update
2021-03-06 16:47:38 -08:00
iceiix 7dcbac2a5d
Update dependencies: serde, log, rand, flate2, image (#502)
* cargo update all modules

* Bump serde to 1.0.123. Closes #496

* Bump wasm-bindgen to 0.2.70. Closes #497

* Bump log to 0.4.14. Closes #498

* Bump rand to 0.8.3. Closes #499

* Bump flate2 to 1.0.20. Closes #500!

* Bump image to 0.23.13. Closes #501
2021-02-06 13:49:49 -08:00
iceiix 72aec0c6a2
blocks: fix hier block shift (#489), add tests (#492)
* blocks: fix soul fire/soil, exclude from <1.13, fixing #489 

* blocks: add unit tests for #467 #469 #474
2021-01-20 17:07:27 -08:00
iceiix 49274e7e52 blocks: add 1.16.1/2+ new blocks/states (#474)
Adds _some _new blocks and block states, building on the version-
dependent block support added in #469. Notably, fixes grass on 1.16.4.

1.16.1+ (protocol_version >= 735)
* Add NetherGoldOre
* Add SoulFire
* Add SoulSoil, Basalt
* Add PolishedBasalt, SoulTorch, SoulWallTorch
* Add Chain

1.16.2+ (protocol_version >= 751)
* Add Chain axis states
2021-01-14 16:47:41 -08:00
iceiix 8ca12a69ce
blocks: versioned block states, fixes world on fire #467 (#469)
Since the unflattening in 1.13.x, block IDs are no longer stable across versions, and
can be shifted by the addition of new block states. To get the right block IDs across
multiple protocol versions, add a new `offsets` token to `define_blocks!`, which
is similar to `offset` (used post-flattening, compare to `data` used pre-flattening),
but accepts a protocol_version argument to enable block states _per-version_:

* Add 'offsets' for protocol_version-specific blockstates

As part of this change, by_vanilla_id is now a method of a VanillaIDMap instance,
instead of a method of Block, so it can know the protocol version. Previously, the
ID map was lazily computed statically, once, but this change allows it to be
computed based on protocol version:

* Move by_vanilla_id to VanillaIDMap instance

Tools to help debug blocks:

* Add DEBUG_BLOCKS environment variable to dump block states
* Add dump_block command-line tool

The block `offset`s were previously only correct for 1.13.2, to take advantage of
the new version-specific `offsets` capability, blocks were updated for 1.14.x:

1.14+ (protocol_version >= 477):
* Add NoteBlock instruments
* Add FlowerPot and RedFlowerVariant cornflower, wither rose, lily of the valley
* Add StandingSign wood variants
* Add WallSign tree variants
* Add StoneSlab smooth stone, cut sandstone, cut red sandstone

This fixes #467, where grass was misinterpreted as fire on 1.14+ because of the
ID shifts caused by NoteBlock, among other block misassignments (though not 100%).
2021-01-13 19:50:05 -08:00
iceiix 63716499f2
1.13.2+: fix TallGrassVariant block state offsets (#468)
Fixes tallgrass showing up as dead bushes and also ferns. The flattened
IDs are in a different order than the pre-flattening data values, as observed
by enabling the commented-out block state logging.
2021-01-10 16:12:43 -08:00
ice_iix ff90d8af6a Use `matches!` for bool match (clippy match_like_matches_macro) 2020-10-10 16:22:46 -07:00
ice_iix 6747ae176e blocks: fix redundant_field_names in macro 2020-06-28 18:24:28 -07:00
ice_iix d64316e8c8 blocks: fix clippy::precedence use + not | 2020-06-28 18:14:09 -07:00
ice_iix c255edd944 blocks: allow clippy::collapsible_if, represents data flow 2020-06-28 17:50:55 -07:00
ice_iix d9a7015dc8 blocks: fix useless_format, use .as_string() 2020-06-28 17:49:07 -07:00
ice_iix f69b27ce74 blocks: allow clippy::identity_op because 1 << 0 is self-documenting bitfield 2020-06-28 17:48:18 -07:00
ice_iix 842b4d8a54 blocks: fix missing panic_params in TreeVariant 2020-06-28 17:46:49 -07:00
ice_iix ac1dad12df blocks: fix redundant_field_names
cat src/lib.rs|perl -pe's/\b(\w+): \1\b/$1/g'|sponge src/lib.rs
2020-06-28 17:45:15 -07:00
iceiix 518b6a07f8
Reformat all source with cargo fmt (#335) 2020-06-21 12:17:24 -07:00
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 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 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 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 fd028d41b0 Replace println! with log crate facade macros info!, debug!, etc. 2019-05-22 16:01:14 -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 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 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
dependabot[bot] 18217c2849 Bump collision from 0.18.0 to 0.19.0 (#95)
Required for #92 WebAssembly support, since it fixes the deprecated rustc-serialize dependency:

https://github.com/iceiix/stevenarella/pull/92#issuecomment-453775934

* Bump collision from 0.18.0 to 0.19.0

Bumps [collision](https://github.com/rustgd/collision-rs) from 0.18.0 to 0.19.0.
- [Release notes](https://github.com/rustgd/collision-rs/releases)
- [Changelog](https://github.com/rustgd/collision-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rustgd/collision-rs/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* blocks/Cargo.toml: Bump collision to 0.19.0
2019-01-19 07:47:46 -08:00
ice_iix 67841f9b2e Fix missing pre-flattening blocks (deadbush, etc.). Closes #89
Blocks not present after "the flattening" (1.13.2) were not registered
for older versions (hierarchical, pre-1.13). This wasn't noticed when
implementing #67 since almost all blocks pre-flattening also have
flattened IDs. The exceptions are when the blocks were removed or moved,
such as dead bush - hierarchical id 32, which is now a block state of
tallgrass instead. But it is still needed pre-flattening, due a logic
error these were skipped.

Fix pre-flattening block ID registration by moving the conditional
clause for vanilla_id outside of the offset conditional.
2019-01-12 10:40:57 -08:00
iceiix 11f2d2ae13 1.13.2 (404) multiprotocol support (#67)
Adds support for 1.13.2 protocol (404)
Expands https://github.com/iceiix/steven/issues/18 Enhance protocol support

Metadata:

* Support 1.13.2 slot data format, bool and varint item id, optional damage (moved to NBT)

https://wiki.vg/index.php?title=Slot_Data&type=revision&diff=14363&oldid=7835

Packets:

* Add 1.13.2 packets, and implement all the command data parsers

https://wiki.vg/Command_Data#Parsers

* Send new plugin channel minecraft:brand

https://wiki.vg/Plugin_channels#minecraft:brand

* Add 1.13.2 metadata format, with shifted IDs

https://wiki.vg/Entity_metadata#Entity_Metadata_Format

* Implement particle entity metadata

* Add structures for 16 new packets

Blocks: The Flattening:

* Assign flattened IDs in correct order using new 'offset' macro token

* Assign hierarchical (pre-flattening) block IDs sequentially by counting Some data

* Split VANILLA_ID_MAP into flat/hier struct, to support before and after the flattening

* Extend travis build time to 20 minutes because the blocks macro takes a long time

* Support both flat/hier blocks by passing protocol_version to by_vanilla_id

Add block states and offsets for all blocks, replacing metadata for 1.13+:

* Add stripped logs and what was Log2 to Log
* Add the Wood blocks, should be called bark, previously Axis::None Log
* Add leaves distance and offset
* Add jungle/acacia to Leaves moved from Leaves2
* Add dispenser offsets, direction
* Add note block states
* Add offset None to Missing253 and Missing254, no holes in block states of 1.13.2
* Add bed colors
* Add seagrass, tall seagrass, remove redundant deadgrass, and piston offset
* Add torch, TNT, fire offsets, remove slabs
* Add furnance offset, merges lit into a property
* Add pressure plate offsets, new pressure plates, redstone ore/lit merged
* Add lever offsets, new directions from ceiling/floor, rename LeverDirections
* Add redstone torch offsets, new blocks since lit/unlit is now merged, and standing/wall is split
* Change lever to split face/facing, rm LeverDirection, add AttachedFace
* Add stone button offsets, face/facing similar to lever
* Move face/facing data and variant to AttachedFace, reuse for lever/stonebutton
* Add data_with_facing_and_powered() to AttachedFace, for lever/stonebutton
* Add wooden button offsets each wood
* Add pumpkin without a face
* Add carved pumpkin, portal offsets
* Add lit pumpkin (as jack-o-lantern) offsets after carved pumpkin
* Add repeater offsets, merged into Repeater
* Change brown mushroom block to booleans instead of MushroomVariant
* Add mushroom block offsets, red/brown mushroom blocks, and a new mushroom stem block
* Add command block, cobblestone walls, and flower pot offsets
Empty flower pot, and potted plants including saplings. Rename
variant DarkOak to DarkOakSaplings because it is a sapling, and
remove the duplicate Dandelion variant which causes duplicate blocks.
* Increase recursion limit in steven_blocks
* Add colored banner offsets
* Add wooden slab including double slab, in a different position for pre-1.13 and 1.13
* StoneSlabVariant::Wood -> StoneSlabVariant::PetrifiedWood
* Add fence_gate_offset() for wooden fence gates
* Add frosted ice age, offset
* Add new blocks: kelp, turtle egg, coral, coral fans, sea pickle, blue ice, smooth stone
* Add new blocks: conduit, void air, cave aid, bubble column, last of the 1.13 blocks
2018-12-28 21:22:58 -08:00
iceiix bf8d913d19
Add new blocks up to 1.12 (#68)
* Add observer block
Added in 1.11: https://minecraft.gamepedia.com/Observer

* Add shulker box blocks, using wool for models for now
Added in 1.12: https://minecraft.gamepedia.com/Shulker_Box

* Add glazed terracotta
Added in 1.12: https://minecraft.gamepedia.com/Glazed_Terracotta

* Add concrete and concrete powder
Both were added in 1.12:
https://minecraft.gamepedia.com/Concrete
https://minecraft.gamepedia.com/Concrete_Powder

* Add structure block
https://minecraft.gamepedia.com/Structure_Block
2018-12-22 14:34:06 -08:00
iceiix 797b20aaf9
Add new blocks up to 1.10 (#69)
* Update blocks/Cargo.lock

* Add magma block

Turns out magma was added way back in 1.10: https://minecraft.gamepedia.com/Magma_Block

* Add nether wart block and red nether brick

Both were added in 1.10:
https://minecraft.gamepedia.com/Nether_Wart_Block
https://minecraft.gamepedia.com/Nether_Bricks#History

* Add bone blocks

Added in 1.10, and they have orientation similar to logs:
https://minecraft.gamepedia.com/Bone_Block

* Add structure void

Added in 1.10, invisible but not a barrier:
https://minecraft.gamepedia.com/Structure_Block#Structure_void
2018-12-17 19:20:51 -08:00
ice_iix 9b31646a8d Disable three stylistic Clippy warnings, var names/params, never loop
This allows the tool to continue and emit a bunch more warnings
2018-11-04 15:01:44 -08:00
ice_iix d111497a50 Use if let instead of match to fix clippy warning 2018-11-04 14:39:08 -08:00
ice_iix b4514a8500 Fix clippy warnings: passed by reference, but would be more efficient if passed by value
https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#trivially_copy_pass_by_ref

i = 0
ll = map(lambda x: int(x.strip()), file("/tmp/lines").readlines())
ll2 = map(lambda x: int(x.strip()), file("/tmp/lines2").readlines())
for line in file("/Users/admin/games/rust/steven/blocks/src/lib.rs").readlines():
    i += 1
    line = line[:-1]

    if i in ll:
        line = line.replace("&self", "self")

    if i in ll2:
        line = line.replace("*self", "self")

    print line
2018-11-04 14:31:46 -08:00
ice_iix ca14ea595b Fix clippy warnings: casting u8 to f64 may become silently lossy if types change
https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#cast_lossless
2018-11-04 14:21:10 -08:00
ice_iix 411e4f69a6 Remove unnecessary 'extern crate's in Rust 2018 edition, import macros
https://rust-lang-nursery.github.io/edition-guide/print.html#no-more-extern-crate
https://rust-lang-nursery.github.io/edition-guide/rust-2018/macros/macro-changes.html
https://github.com/iceiix/steven/pull/13#issuecomment-435702507
2018-11-04 12:39:23 -08:00
ice_iix 0d8696286c Update Cargo.tomls to Rust edition 2018, fix crate imports. Closes #13 2018-11-04 12:15:34 -08:00
ice_iix 80c740c1c5 Update to cgmath 0.16.1, collision 0.18.0
https://github.com/iceiix/steven/issues/4
2018-10-27 18:11:26 -07:00
ice_iix 5ce9bf3fa3 Update to lazy_static 1.1.0 in blocks/Cargo.toml
https://github.com/iceiix/steven/issues/4
2018-10-27 17:21:57 -07:00
ice_iix be46377842 Remove unused macros and imports to appease compiler warnings
https://github.com/iceiix/steven/issues/1
2018-09-29 23:52:47 -07:00
Kevin Sillerud a9cb7654e4 Use a old mirror for collision-rs (Fixes #66) 2017-03-16 10:43:42 +01:00
Thinkofname 2cc00f086b Implement collisions for stairs 2016-04-21 22:39:34 +01:00
Thinkofname 287867dbcd Add a collidable flag to Material 2016-04-21 21:47:39 +01:00
Thinkofname 1c898b594e Fix door collisions 2016-04-21 20:57:50 +01:00
Thinkofname bb5032fd30 Remove the steven_id system 2016-04-20 21:52:04 +01:00
Scetch 7588b20bd0 Block fixes and some cleanup. 2016-04-20 14:54:32 -04:00
Scetch dab2c3fc89 Default block material to solid. 2016-04-13 10:50:08 -04:00
Thinkofname a7c586b2e9 Optimize the types used for blocks.
Reduces the size of a block from 16 bytes -> 8 bytes on my 64 bit machine.
2016-04-09 13:48:42 +01:00
Scetch 64ec2e4d3b Cleaning up blocks a little bit. 2016-04-08 11:30:41 -04:00
Scetch b037fb1e5c Fix layered snow collision 2016-04-07 14:55:47 -04:00
Thinkofname c117f28b2a Block entity support, implement signs 2016-04-04 22:08:24 +01:00
Scetch 7c31332dc8 Implement more block collisions. 2016-04-03 23:55:20 -04:00
Thinkofname 98ecd348c6 Replace usages of x,y,z for block positions with Position 2016-04-03 20:53:40 +01:00
Thinkofname 92d773bd72 Move blocks into its own crate to speed up compile times 2016-04-03 18:26:52 +01:00