mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-07 08:16:05 +00:00
noise addon impl
This commit is contained in:
@@ -30,6 +30,7 @@ import com.dfsek.terra.api.addon.TerraAddon;
|
||||
import com.dfsek.terra.api.addon.annotations.Addon;
|
||||
import com.dfsek.terra.api.addon.annotations.Author;
|
||||
import com.dfsek.terra.api.addon.annotations.Version;
|
||||
import com.dfsek.terra.api.event.EventListener;
|
||||
import com.dfsek.terra.api.event.annotations.Global;
|
||||
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||
@@ -40,12 +41,13 @@ import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
@Addon("noise")
|
||||
@Author("Terra")
|
||||
@Version("1.0.0")
|
||||
public class NoiseAddon extends TerraAddon {
|
||||
public class NoiseAddon extends TerraAddon implements EventListener {
|
||||
@Inject
|
||||
private TerraPlugin plugin;
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
plugin.getEventManager().registerListener(this, this);
|
||||
plugin.applyLoader(ImageSamplerTemplate.class, ImageSamplerTemplate::new)
|
||||
.applyLoader(DomainWarpTemplate.class, DomainWarpTemplate::new)
|
||||
.applyLoader(LinearNormalizerTemplate.class, LinearNormalizerTemplate::new)
|
||||
@@ -58,7 +60,6 @@ public class NoiseAddon extends TerraAddon {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Global
|
||||
public void packPreLoad(ConfigPackPreLoadEvent event) {
|
||||
|
||||
event.getPack()
|
||||
|
||||
@@ -184,6 +184,12 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
toWorldConfig(new TerraWorldImpl(new DummyWorld(), this, main)); // Build now to catch any errors immediately.
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void applyLoaders(TypeRegistry registry) {
|
||||
loaders.forEach(registry::registerLoader);
|
||||
objectLoaders.forEach((t, l) -> registry.registerLoader(t, (TemplateProvider<ObjectTemplate<Object>>) ((Object) l)));
|
||||
}
|
||||
|
||||
private Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> newRegistryMap() {
|
||||
Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> map = new HashMap<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>>() {
|
||||
@Serial
|
||||
@@ -230,6 +236,8 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void load(long start, TerraPlugin main) throws ConfigException {
|
||||
applyLoaders(abstractConfigLoader);
|
||||
applyLoaders(selfLoader);
|
||||
configTypes.values().forEach(list -> list.forEach(pair -> configTypeRegistry.register(pair.getLeft(), pair.getRight())));
|
||||
|
||||
for(Map.Entry<String, Double> var : template.getVariables().entrySet()) {
|
||||
@@ -297,8 +305,6 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
.registerLoader(ConfigType.class, configTypeRegistry)
|
||||
.registerLoader(BufferedImage.class, new BufferedImageLoader(loader));
|
||||
registryMap.forEach((clazz, reg) -> registry.registerLoader(clazz, reg.getLeft()));
|
||||
loaders.forEach(registry::registerLoader);
|
||||
objectLoaders.forEach((t, l) -> registry.registerLoader(t, (TemplateProvider<ObjectTemplate<Object>>) ((Object) l)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user