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.
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)
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.
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
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