Skip to content

Conversation

@mat-1
Copy link
Collaborator

@mat-1 mat-1 commented Aug 4, 2025

The data_components.py codegen now additionally writes to azalea-inventory/src/default_components/generated.rs with DefaultableComponent impls for every component that has default implementations for any items, by translating Mojang's items.json to Rust values.

It's optimized to generate different impls based on some heuristics, so for some components it'll use a lookup table and for others it'll write a match statement. I don't expect that the codegen will need to be changed for most updates, except for when Mojang adds another more unusual looking components.

Note that this approach has the downside of making it more complicated to get a list of default components for an item (because you'd have to call default_for_item for every DefaultableComponent), but I don't expect this to be a common case (since usually you only care about a single component at a time).

@mat-1 mat-1 merged commit 23b7f20 into main Aug 5, 2025
3 checks passed
@mat-1 mat-1 deleted the default-components branch August 5, 2025 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant