-
-
Notifications
You must be signed in to change notification settings - Fork 179
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
Allow Datapack Registry to be configured by RegistryBuilder #1447
Allow Datapack Registry to be configured by RegistryBuilder #1447
Conversation
|
Why do you need to configure dp regs with registrybuilder? |
Sorry but I noticed that the doc of the ModifyRegistriesEvent said that it cannot be used to modify datapack registries. Also, even if this event works, it cannot add default value for the datapack registry cuz the generated registry is MappedRegistry instead of DefaultedMappedRegistry. |
Ah, so your usecase is adding default values to the registry? I suppose that's fine, but if you add the consumer to the registry data, please make it the last parameter of the record. |
Okay, I just added a new commit to make the consumer the last parameter. |
src/main/java/net/neoforged/neoforge/registries/RegistryBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/net/neoforged/neoforge/registries/DataPackRegistryEvent.java
Outdated
Show resolved
Hide resolved
I don't think letting a datapack registry be a Allowing the configuration through registry builder satisfies requirements from #1158, which is (or rather, might be?) useful, but use of a default key is a footgun. |
Indeed, the default object may be removed. But it also allow datapacks to change a hardcoded default state, making the datapack behavior more flexible. Also, modifying default object isn’t quite common, and the default value is disabled at default, so if you want to add a default value, you should declare it explicitly and take the risk. |
BTW, adding default value can prevent the usage of unsafe null value or Optional as default value. Though I can use Holder.direct() and RegistryFileCodec/ByteBufCodecs.holder to achieve similar behavior like the default value, it just feel hacky and the default value has no key to represent |
Eh, well, people can use it at their own risk. It isn't really any different than just calling |
🚀 This PR has been released as NeoForge version |
Modify the RegistryDataLoader$RegistryData and RegistryBuilder to allow datapack registries to be configured by RegistryBuilder.