Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VillagerTradesEvent and WandererTradesEvent has no way to access DatapackRegistries. #1527

Open
Lanse505 opened this issue Sep 9, 2024 · 3 comments · May be fixed by #1529
Open

VillagerTradesEvent and WandererTradesEvent has no way to access DatapackRegistries. #1527

Lanse505 opened this issue Sep 9, 2024 · 3 comments · May be fixed by #1529
Labels
enhancement New (or improvement to existing) feature or request

Comments

@Lanse505
Copy link

Lanse505 commented Sep 9, 2024

Created an issue per @sciwhiz12 's recommendation/request.

Feature Suggestion: Provide RegistryAccess for VillagerTradesEvent and WandererTradesEvent

Currently, neither the VillagerTradesEvent nor the WandererTradesEvent has access to a RegistryAccess instance. This limitation affects mods that rely on DatapackRegistry values to create specific ItemStack objects. According to the documentation, both events are triggered during reload by the TagsUpdatedEvent. However, neither event inherits from TagsUpdatedEvent nor receives a reference to RegistryAccess, making it impossible to access data from datapack registries.

Example Use Case

In my current mod, I have a "Drone/Princess/Queen"-variant item that contains all the species information and attributes as part of a Genome object (stored as a DataComponent), which is generated from the IAllele representing the species. Since IAllele is a DatapackRegistry object, I am unable to access the IAllele from the DatapackRegistry using its corresponding ResourceKey<IAllele>.

Proposed Solution

While it is possible to access the server instance through ServerLifecycleHooks, a more elegant solution would be to pass down the RegistryAccess provided by the TagsUpdatedEvent at some point in the event chain. This would make it easier to have access to datapack registries and allow mod developers to utilize DatapackRegistry values more effectively.

@Lanse505 Lanse505 added the enhancement New (or improvement to existing) feature or request label Sep 9, 2024
@ZestyBlaze
Copy link
Contributor

I can actually see this being useful in my mod's case soon too, I can't see this PR being too difficult at all, I'll sketch up a draft PR when I get home

@dhyces
Copy link
Contributor

dhyces commented Sep 9, 2024

While we're adding this to these events, might as well also add RegistryAccess to RegisterBrewingRecipesEvent too (would be nice for me, as I have a mod that needs to be installed on both client and server and would like to add data-pack potion recipes)

@ZestyBlaze ZestyBlaze linked a pull request Sep 9, 2024 that will close this issue
@ZestyBlaze
Copy link
Contributor

@Lanse505 PR for it done, should be merged in a couple days if no other additions or changes are needed

@sciwhiz12 sciwhiz12 linked a pull request Sep 10, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New (or improvement to existing) feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants