mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-16 18:45:09 +00:00
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:
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);
|
||||
|
||||
Reference in new issue
Block a user