mirror of
https://github.com/Pumpkin-MC/Pumpkin.git
synced 2026-08-30 20:14:23 +00:00
* refactor: less manual BlockMetadata impls * refactor: added BlockId type BlockId is a wrapper for u16: it is valid for any u16 that is the id of a Block. - Changed the Block.id field type to BlockId - added named BlockId constants - BlockMetadata::ids() now returns Box<[BlockId]> - adjusted pumpkin-macros to use BlockId constants - fixed some methods that were comparing blockstate ids or item ids (u16) against block ids (previously u16) TODO: check if unsafe blocks can be removed; The compiler might understand that BlockId is always a valid index into mappings::TYPE_FROM_RAW_ID * refactor: added BlockStateId type A BlockStateId is a safe wrapper around the numerical index of a BlockState in pumpkin-data. They help avoiding validity checks (outside of IO and, currently, plugins), and make it easier for other contributors to reason about what they're comparing; BlockStateIds, BlockIds or Item ids (still u16). pumpkin-data::BlockStateId replaces RawBlockState and BlockStateId from pumpkin-world. - added the BlockStateId wrapper type - made (almost; plugins) every function interacting with block states or block state ids use the wrapper type - changed codegen logic to create/work with BlockStateIds - made ChunkPalette parsing check BlockStateId validity (pumpkin-world::chunk::format::ChunkSectionBlockStates) TODO: check if unsafe blocks can be removed; The compiler might understand that BlockStateId is always a valid index into mappings::BLOCK_ID_FROM_STATE_ID and mappings::STATE_FROM_STATE_ID * refactor: imports changed every use pumpkin_world::BlockStateId to pumpkin_data::BlockStateId * refactor: Block- & BlockStateId finishing touches; - rebased on latest mater - ensure there are no bound checks on Block(State)Id conversions, making them extremely cheap - this required unsafe std::hint::assert_unchecked annotations because the compiler is (occasionally) stupid - on debug builds the bound checks still exist because of ub_checks (see rust unstable book for the feature of the same name) - added Safety notes to hopefully prevent anyone from enabling the creation of invalid Block(State)Ids in the future - fixed a benchmark
21 lines
373 B
TOML
21 lines
373 B
TOML
[package]
|
|
name = "pumpkin-macros"
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
license.workspace = true
|
|
|
|
[lib]
|
|
proc-macro = true
|
|
|
|
[dependencies]
|
|
proc-macro-error2.workspace = true
|
|
pumpkin-data = { workspace = true, features = ["block", "tag"] }
|
|
|
|
heck.workspace = true
|
|
quote.workspace = true
|
|
syn.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|