fix addon registry stack overflow

This commit is contained in:
dfsek 2021-07-05 19:47:02 -07:00
parent 27a54101e7
commit fe28fcedd1
2 changed files with 8 additions and 2 deletions

View File

@ -41,7 +41,10 @@ public class BiomeConfigType implements ConfigType<BiomeTemplate, BiomeBuilder>
public Supplier<OpenRegistry<BiomeBuilder>> registrySupplier() {
return () -> pack.getRegistryFactory().create(registry -> (TypeLoader<BiomeBuilder>) (t, c, loader) -> {
if(c.equals("SELF")) return null;
return registry.load(t, c, loader);
BiomeBuilder obj = registry.get((String) c);
if(obj == null)
throw new LoadException("No such " + t.getTypeName() + " matching \"" + c + "\" was found in this registry.");
return obj;
});
}
}

View File

@ -44,7 +44,10 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
return () -> pack.getRegistryFactory().create(registry -> (TypeLoader<Palette>) (t, c, loader) -> {
if(((String) c).startsWith("BLOCK:"))
return new PaletteImpl.Singleton(main.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
return registry.load(t, c, loader);
Palette obj = registry.get((String) c);
if(obj == null)
throw new LoadException("No such " + t.getTypeName() + " matching \"" + c + "\" was found in this registry.");
return obj;
});
}
}