mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-29 21:30:43 +00:00
pull getOrCreateRegistry methods to RegistryProvider interface
This commit is contained in:
@@ -16,20 +16,20 @@ import java.util.Map;
|
|||||||
import com.dfsek.terra.api.addon.BaseAddon;
|
import com.dfsek.terra.api.addon.BaseAddon;
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
import com.dfsek.terra.api.registry.key.Keyed;
|
import com.dfsek.terra.api.registry.key.Keyed;
|
||||||
import com.dfsek.terra.api.registry.key.Namespaced;
|
|
||||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||||
|
import com.dfsek.terra.api.registry.meta.CheckedRegistryHolder;
|
||||||
import com.dfsek.terra.api.registry.meta.RegistryHolder;
|
import com.dfsek.terra.api.registry.meta.RegistryHolder;
|
||||||
|
import com.dfsek.terra.api.registry.meta.RegistryProvider;
|
||||||
import com.dfsek.terra.api.tectonic.ConfigLoadingDelegate;
|
import com.dfsek.terra.api.tectonic.ConfigLoadingDelegate;
|
||||||
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
import com.dfsek.terra.api.tectonic.LoaderRegistrar;
|
||||||
import com.dfsek.terra.api.tectonic.ShortcutLoader;
|
import com.dfsek.terra.api.tectonic.ShortcutLoader;
|
||||||
import com.dfsek.terra.api.registry.key.StringIdentifiable;
|
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
import com.dfsek.terra.api.world.chunk.generation.stage.GenerationStage;
|
||||||
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
import com.dfsek.terra.api.world.chunk.generation.util.provider.ChunkGeneratorProvider;
|
||||||
|
|
||||||
|
|
||||||
public interface ConfigPack extends LoaderRegistrar, ConfigLoadingDelegate, RegistryHolder, Keyed {
|
public interface ConfigPack extends LoaderRegistrar, ConfigLoadingDelegate, CheckedRegistryHolder, RegistryProvider, Keyed {
|
||||||
|
|
||||||
ConfigPack registerConfigType(ConfigType<?, ?> type, RegistryKey id, int priority);
|
ConfigPack registerConfigType(ConfigType<?, ?> type, RegistryKey id, int priority);
|
||||||
|
|
||||||
@@ -37,12 +37,6 @@ public interface ConfigPack extends LoaderRegistrar, ConfigLoadingDelegate, Regi
|
|||||||
|
|
||||||
BiomeProvider getBiomeProvider();
|
BiomeProvider getBiomeProvider();
|
||||||
|
|
||||||
default <T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz) {
|
|
||||||
return getOrCreateRegistry(TypeKey.of(clazz));
|
|
||||||
}
|
|
||||||
|
|
||||||
<T> CheckedRegistry<T> getOrCreateRegistry(TypeKey<T> type);
|
|
||||||
|
|
||||||
List<GenerationStage> getStages();
|
List<GenerationStage> getStages();
|
||||||
|
|
||||||
Loader getLoader();
|
Loader getLoader();
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.dfsek.terra.api.registry.meta;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
|
||||||
|
public interface CheckedRegistryHolder extends RegistryHolder {
|
||||||
|
default <T> CheckedRegistry<T> getCheckedRegistry(Class<T> clazz) throws IllegalStateException {
|
||||||
|
return getCheckedRegistry((Type) clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
default <T> CheckedRegistry<T> getCheckedRegistry(TypeKey<T> type) throws IllegalStateException {
|
||||||
|
return getCheckedRegistry(type.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
<T> CheckedRegistry<T> getCheckedRegistry(Type type);
|
||||||
|
}
|
||||||
@@ -9,7 +9,6 @@ package com.dfsek.terra.api.registry.meta;
|
|||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
|
||||||
import com.dfsek.terra.api.registry.Registry;
|
import com.dfsek.terra.api.registry.Registry;
|
||||||
import com.dfsek.terra.api.util.reflection.TypeKey;
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
@@ -24,16 +23,4 @@ public interface RegistryHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
<T> Registry<T> getRegistry(Type type);
|
<T> Registry<T> getRegistry(Type type);
|
||||||
|
|
||||||
default <T> CheckedRegistry<T> getCheckedRegistry(Class<T> clazz) throws IllegalStateException {
|
|
||||||
return getCheckedRegistry((Type) clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
default <T> CheckedRegistry<T> getCheckedRegistry(TypeKey<T> type) throws IllegalStateException {
|
|
||||||
return getCheckedRegistry(type.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
default <T> CheckedRegistry<T> getCheckedRegistry(Type type) throws IllegalStateException {
|
|
||||||
throw new UnsupportedOperationException("Cannot get checked registry.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.dfsek.terra.api.registry.meta;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||||
|
import com.dfsek.terra.api.util.reflection.TypeKey;
|
||||||
|
|
||||||
|
|
||||||
|
public interface RegistryProvider {
|
||||||
|
default <T> CheckedRegistry<T> getOrCreateRegistry(Class<T> clazz) {
|
||||||
|
return getOrCreateRegistry(TypeKey.of(clazz));
|
||||||
|
}
|
||||||
|
|
||||||
|
<T> CheckedRegistry<T> getOrCreateRegistry(TypeKey<T> type);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user