mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
getOrCreateRegistry
This commit is contained in:
@@ -15,6 +15,8 @@ import java.util.Set;
|
||||
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder {
|
||||
BiomeProviderBuilder getBiomeProviderBuilder();
|
||||
|
||||
<T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz);
|
||||
|
||||
WorldConfig toWorldConfig(TerraWorld world);
|
||||
|
||||
void registerConfigType(ConfigType<?, ?> type, String id, int priority);
|
||||
|
||||
@@ -194,7 +194,6 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
}
|
||||
};
|
||||
|
||||
putPair(map, NoiseProvider.class, new NoiseRegistry());
|
||||
putPair(map, LootTable.class, new OpenRegistryImpl<>());
|
||||
putPair(map, Structure.class, new OpenRegistryImpl<>());
|
||||
|
||||
@@ -302,6 +301,15 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
return biomeProviderBuilder;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz) {
|
||||
return (CheckedRegistry<T>) registryMap.computeIfAbsent(clazz, c -> {
|
||||
OpenRegistry<T> registry = new OpenRegistryImpl<>();
|
||||
return ImmutablePair.of(registry, new CheckedRegistryImpl<>(registry));
|
||||
}).getRight();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WorldConfigImpl toWorldConfig(TerraWorld world) {
|
||||
|
||||
Reference in New Issue
Block a user