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

Registry resource conditions #3752

Merged
merged 4 commits into from
May 20, 2024

Conversation

SquidDev
Copy link
Contributor

@SquidDev SquidDev commented May 2, 2024

This adds support for resource conditions within dynamic registries.

The registry-contains condition (and all other conditions) have access to the parent registries but not registries in the current ServerDynamicRegistryType. In practice, this means conditions can reference the STATIC registries, but not dynamic registries (WORLDGEN) or loot tables (RELOADABLE).

For datagen, this adds additional overrides to FabricDynamicRegistryProvider.Entries to add items with resource conditions. This is a bit of a divergence from the other resource condition generators (which use FabricDataGenHelper.consumeConditions), but I think this makes more sense here.

entries.add(
  RegistryKey.of(MY_REGISTRY, new Identifier("my_mod", "my_object")), new MyObject(),
  ResourceConditions.allModsLoaded("another_mod")
);

Closes #3632.

 - Add matching overloads for all add(...) methods which take a varargs
   list of ResourceConditions.

 - Add an additional overload for registering RegistryEntry.References
   directly. This makes it a little easier to register directly from a
   RegistryBuilder.
@modmuss50 modmuss50 added enhancement New feature or request last call If you care, make yourself heard right away! labels May 13, 2024
@modmuss50
Copy link
Member

Looks good, ill add to last call, 1 or 2 trivial things to be looked at before merging. Thanks :)

@apple502j
Copy link
Contributor

Are there any registries where this might fail? I don't remember if there was one that didn't tolerate additional keys, probably zero but maybe we should check,

@modmuss50 modmuss50 added the merge me please Pull requests that are ready to merge label May 19, 2024
@modmuss50 modmuss50 merged commit a5d5299 into FabricMC:1.20.6 May 20, 2024
4 checks passed
modmuss50 pushed a commit that referenced this pull request May 20, 2024
* Add resource conditions to dynamic registries

* Support conditions in FabricDynamicRegistryProvider

 - Add matching overloads for all add(...) methods which take a varargs
   list of ResourceConditions.

 - Add an additional overload for registering RegistryEntry.References
   directly. This makes it a little easier to register directly from a
   RegistryBuilder.

* Throw error if we cannot add resource conditions

* Rename EntryWithConditions to ConditionalEntry

(cherry picked from commit a5d5299)
@SquidDev SquidDev deleted the registry-resource-conditions branch May 20, 2024 08:49
@SquidDev
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request last call If you care, make yourself heard right away! merge me please Pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Suggestion] Resource Conditions support for dynamic registries
4 participants