mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-10-25 21:40:08 +00:00
getOrCreateRegistry
This commit is contained in:
1 parent
04725698e8
commit
4acfeab948
2 files changed
+11
-1
No files matched your search
@@ -15,6 +15,8 @@ import java.util.Set;
|
|||||||
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder {
|
public interface ConfigPack extends LoaderRegistrar, LoaderHolder, RegistryHolder {
|
||||||
BiomeProviderBuilder getBiomeProviderBuilder();
|
BiomeProviderBuilder getBiomeProviderBuilder();
|
||||||
|
|
||||||
|
<T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz);
|
||||||
|
|
||||||
WorldConfig toWorldConfig(TerraWorld world);
|
WorldConfig toWorldConfig(TerraWorld world);
|
||||||
|
|
||||||
void registerConfigType(ConfigType<?, ?> type, String id, int priority);
|
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, LootTable.class, new OpenRegistryImpl<>());
|
||||||
putPair(map, Structure.class, new OpenRegistryImpl<>());
|
putPair(map, Structure.class, new OpenRegistryImpl<>());
|
||||||
|
|
||||||
@@ -302,6 +301,15 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
return biomeProviderBuilder;
|
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
|
@Override
|
||||||
public WorldConfigImpl toWorldConfig(TerraWorld world) {
|
public WorldConfigImpl toWorldConfig(TerraWorld world) {
|
||||||
|
|||||||
Reference in new issue
Block a user