mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-29 13:20:32 +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.Addon;
|
||||||
import com.dfsek.terra.api.addon.annotations.Author;
|
import com.dfsek.terra.api.addon.annotations.Author;
|
||||||
import com.dfsek.terra.api.addon.annotations.Version;
|
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.annotations.Global;
|
||||||
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
|
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
|
||||||
import com.dfsek.terra.api.injection.annotations.Inject;
|
import com.dfsek.terra.api.injection.annotations.Inject;
|
||||||
@@ -40,12 +41,13 @@ import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
|||||||
@Addon("noise")
|
@Addon("noise")
|
||||||
@Author("Terra")
|
@Author("Terra")
|
||||||
@Version("1.0.0")
|
@Version("1.0.0")
|
||||||
public class NoiseAddon extends TerraAddon {
|
public class NoiseAddon extends TerraAddon implements EventListener {
|
||||||
@Inject
|
@Inject
|
||||||
private TerraPlugin plugin;
|
private TerraPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
plugin.getEventManager().registerListener(this, this);
|
||||||
plugin.applyLoader(ImageSamplerTemplate.class, ImageSamplerTemplate::new)
|
plugin.applyLoader(ImageSamplerTemplate.class, ImageSamplerTemplate::new)
|
||||||
.applyLoader(DomainWarpTemplate.class, DomainWarpTemplate::new)
|
.applyLoader(DomainWarpTemplate.class, DomainWarpTemplate::new)
|
||||||
.applyLoader(LinearNormalizerTemplate.class, LinearNormalizerTemplate::new)
|
.applyLoader(LinearNormalizerTemplate.class, LinearNormalizerTemplate::new)
|
||||||
@@ -58,7 +60,6 @@ public class NoiseAddon extends TerraAddon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Global
|
|
||||||
public void packPreLoad(ConfigPackPreLoadEvent event) {
|
public void packPreLoad(ConfigPackPreLoadEvent event) {
|
||||||
|
|
||||||
event.getPack()
|
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.
|
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() {
|
private Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> newRegistryMap() {
|
||||||
Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> map = new HashMap<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>>() {
|
Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> map = new HashMap<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>>() {
|
||||||
@Serial
|
@Serial
|
||||||
@@ -230,6 +236,8 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
|
|
||||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
private void load(long start, TerraPlugin main) throws ConfigException {
|
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())));
|
configTypes.values().forEach(list -> list.forEach(pair -> configTypeRegistry.register(pair.getLeft(), pair.getRight())));
|
||||||
|
|
||||||
for(Map.Entry<String, Double> var : template.getVariables().entrySet()) {
|
for(Map.Entry<String, Double> var : template.getVariables().entrySet()) {
|
||||||
@@ -297,8 +305,6 @@ public class ConfigPackImpl implements ConfigPack {
|
|||||||
.registerLoader(ConfigType.class, configTypeRegistry)
|
.registerLoader(ConfigType.class, configTypeRegistry)
|
||||||
.registerLoader(BufferedImage.class, new BufferedImageLoader(loader));
|
.registerLoader(BufferedImage.class, new BufferedImageLoader(loader));
|
||||||
registryMap.forEach((clazz, reg) -> registry.registerLoader(clazz, reg.getLeft()));
|
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
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user