Add DeferredRegistryData to help with generating data driven registry entries.

Revive GameTest system and make all but one Forge Test mod pass.
This commit is contained in:
LexManos committed 2025-03-27 20:52:35 -07:00
1 parent b4b6e48a7a
commit 0f3b8ee830
102 files changed
+1229 -469

No files matched your search

@@ -175,6 +175,15 @@ public final class RegistryObject<T> implements Supplier<T> {
this.updateReference(registryName);
}
/** Internal constructor used for {@link DeferredRegisterData} */
RegistryObject(final ResourceLocation name, final ResourceKey<? extends Registry<? super T>> registry, final String modid) {
this.name = name;
@SuppressWarnings("unchecked")
var typed = (ResourceKey<Registry<T>>)registry;
this.key = ResourceKey.create(typed, name);
this.optionalRegistry = true;
}
/**
* Retrieves the wrapped object in the registry.
* This value will automatically be updated when the backing registry is updated.
@@ -265,6 +274,11 @@ public final class RegistryObject<T> implements Supplier<T> {
this.value = null;
}
void updateReference(T value, Supplier<Holder<T>> holder) {
this.value = value;
this.holder = holder;
}
private static boolean registryExists(ResourceLocation registryName) {
return RegistryManager.ACTIVE.getRegistry(registryName) != null
|| BuiltInRegistries.REGISTRY.containsKey(registryName);