Registry overhaul (WIP)#51
Conversation
| impl BlockStateId { | ||
| /// Do NOT use this by yourself. Instead use the block macro `block!("stone")` the item to block | ||
| /// map | ||
| #[inline(always)] |
There was a problem hiding this comment.
Don't force inline, the compiler is pretty good at figuring out when it will help and can blow up compile time if used wrong
There was a problem hiding this comment.
absolutely correct. my bad
| // --- Getters (Using State IDs) --- | ||
|
|
||
| #[inline(always)] | ||
| fn base_id(state_id: u32) -> u32 { |
There was a problem hiding this comment.
for these can we use impl Into<u32> so we can pass in blockstateids without having to convert?
There was a problem hiding this comment.
this would actually be much more ergonomic than what i was thinking. thank you
| reg.state_to_block | ||
| .get(state_id as usize) | ||
| .copied() | ||
| .unwrap_or(0) |
There was a problem hiding this comment.
for the fallbacks can we warn please
|
|
||
| // --- Getters (Using State IDs) --- | ||
|
|
||
| #[inline(always)] |
There was a problem hiding this comment.
forcing inline on these is a really bad idea as they will expand to a lot of code and cause compile time problems later down the line
| || name.ends_with("_roots") | ||
| } | ||
|
|
||
| pub fn init(json_string: &str) { |
There was a problem hiding this comment.
for this entire thing, could we move it to something like PHF and do this at compile time? Might not be feasible but could result in better startup and runtime performance
There was a problem hiding this comment.
reading up on it again, PHF is strictly for mapping strings to values and is kinda useless for mapping state IDs to other IDs. We can definitely do compile time generation instead of what i'm doing here though.
| max_durability: Option<u16>, | ||
| } | ||
|
|
||
| struct ItemRegistry { |
There was a problem hiding this comment.
Why not just have all the fields in 1 vec?
There was a problem hiding this comment.
this would be a trap for ECS. you're suggesting an AoS (array of structs) but we want an SoA (struct of arrays) because it maximizes cache locality
for integer-to-value lookups, i'll just generate a flat &[T] array at compile time
No description provided.