mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
begin tectonic update process
This commit is contained in:
@@ -5,11 +5,12 @@ import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.util.seeded.BiomeProviderBuilder;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class BiomeProviderBuilderLoader implements TypeLoader<BiomeProviderBuilder> {
|
||||
@Override
|
||||
public BiomeProviderBuilder load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
return loader.loadClass(BiomePipelineTemplate.class, c); // TODO: actually implement this lol
|
||||
public BiomeProviderBuilder load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
return loader.loadType(BiomePipelineTemplate.class, c); // TODO: actually implement this lol
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,19 +6,20 @@ import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.util.seeded.SourceSeeded;
|
||||
import com.dfsek.terra.api.world.biome.generation.pipeline.BiomeSource;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class SourceBuilderLoader implements TypeLoader<SourceSeeded> {
|
||||
@Override
|
||||
public SourceSeeded load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
public SourceSeeded load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
Map<String, Object> source = (Map<String, Object>) c;
|
||||
|
||||
BiomeSource.Type type = loader.loadClass(BiomeSource.Type.class, source.get("type"));
|
||||
BiomeSource.Type type = loader.loadType(BiomeSource.Type.class, source.get("type"));
|
||||
|
||||
if(type == BiomeSource.Type.NOISE) {
|
||||
return loader.loadClass(NoiseSourceTemplate.class, source);
|
||||
return loader.loadType(NoiseSourceTemplate.class, source);
|
||||
}
|
||||
throw new LoadException("No such loader type: " + type);
|
||||
}
|
||||
|
||||
@@ -13,13 +13,14 @@ import com.dfsek.terra.addons.biome.pipeline.config.stage.mutator.SmoothMutatorT
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.ExpanderStage;
|
||||
import com.dfsek.terra.addons.biome.pipeline.stages.MutatorStage;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class StageBuilderLoader implements TypeLoader<StageSeeded> {
|
||||
@Override
|
||||
public StageSeeded load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
public StageSeeded load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
Map<String, Object> raw = (Map<String, Object>) c;
|
||||
|
||||
if(raw.size() != 1) throw new LoadException("Illegal stage map size: " + raw.size());
|
||||
@@ -33,22 +34,22 @@ public class StageBuilderLoader implements TypeLoader<StageSeeded> {
|
||||
Map<String, Object> mutator = (Map<String, Object>) entry.getValue();
|
||||
|
||||
if(entry.getKey().equals("expand")) {
|
||||
ExpanderStage.Type stageType = loader.loadClass(ExpanderStage.Type.class, mutator.get("type"));
|
||||
ExpanderStage.Type stageType = loader.loadType(ExpanderStage.Type.class, mutator.get("type"));
|
||||
if(stageType.equals(ExpanderStage.Type.FRACTAL)) {
|
||||
return loader.loadClass(ExpanderStageTemplate.class, mutator);
|
||||
return loader.loadType(ExpanderStageTemplate.class, mutator);
|
||||
} else throw new LoadException("No such expander \"" + stageType + "\"");
|
||||
} else if(entry.getKey().equals("mutate")) {
|
||||
switch(loader.loadClass(MutatorStage.Type.class, mutator.get("type"))) {
|
||||
switch(loader.loadType(MutatorStage.Type.class, mutator.get("type"))) {
|
||||
case SMOOTH:
|
||||
return loader.loadClass(SmoothMutatorTemplate.class, mutator);
|
||||
return loader.loadType(SmoothMutatorTemplate.class, mutator);
|
||||
case REPLACE:
|
||||
return loader.loadClass(ReplaceMutatorTemplate.class, mutator);
|
||||
return loader.loadType(ReplaceMutatorTemplate.class, mutator);
|
||||
case REPLACE_LIST:
|
||||
return loader.loadClass(ReplaceListMutatorTemplate.class, mutator);
|
||||
return loader.loadType(ReplaceListMutatorTemplate.class, mutator);
|
||||
case BORDER:
|
||||
return loader.loadClass(BorderMutatorTemplate.class, mutator);
|
||||
return loader.loadType(BorderMutatorTemplate.class, mutator);
|
||||
case BORDER_LIST:
|
||||
return loader.loadClass(BorderListMutatorTemplate.class, mutator);
|
||||
return loader.loadType(BorderListMutatorTemplate.class, mutator);
|
||||
default:
|
||||
throw new LoadException("No such mutator type \"" + mutator.get("type"));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class BiomeConfigType implements ConfigType<BiomeTemplate, BiomeBuilder>
|
||||
if(c.equals("SELF")) return null;
|
||||
BiomeBuilder obj = registry.get((String) c);
|
||||
if(obj == null)
|
||||
throw new LoadException("No such " + t.getTypeName() + " matching \"" + c + "\" was found in this registry.");
|
||||
throw new LoadException("No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry.");
|
||||
return obj;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.dfsek.terra.addons.biome;
|
||||
|
||||
import com.dfsek.paralithic.eval.parser.Parser;
|
||||
import com.dfsek.paralithic.eval.parser.Scope;
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.config.ValidatedConfigTemplate;
|
||||
import com.dfsek.tectonic.exception.ValidationException;
|
||||
@@ -32,139 +32,116 @@ public class BiomeTemplate implements AbstractableTemplate, ValidatedConfigTempl
|
||||
private final ConfigPack pack;
|
||||
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("extends")
|
||||
@Final
|
||||
@Default
|
||||
private List<String> extended = Collections.emptyList();
|
||||
|
||||
@Value("variables")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<String, Double> variables = new HashMap<>();
|
||||
|
||||
@Value("beta.carving.equation")
|
||||
@Abstractable
|
||||
@Default
|
||||
private NoiseSeeded carvingEquation = NoiseSeeded.zero(3);
|
||||
|
||||
@Value("palette")
|
||||
@Abstractable
|
||||
private PaletteHolder palette;
|
||||
|
||||
@Value("slant")
|
||||
@Abstractable
|
||||
@Default
|
||||
private SlantHolder slant = null;
|
||||
|
||||
@Value("vanilla")
|
||||
@Abstractable
|
||||
private ProbabilityCollection<Biome> vanilla;
|
||||
|
||||
@Value("biome-noise")
|
||||
@Default
|
||||
@Abstractable
|
||||
private NoiseSeeded biomeNoise = NoiseSeeded.zero(2);
|
||||
|
||||
@Value("blend.distance")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int blendDistance = 3;
|
||||
|
||||
@Value("blend.weight")
|
||||
@Abstractable
|
||||
@Default
|
||||
private double blendWeight = 1;
|
||||
|
||||
@Value("blend.step")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int blendStep = 4;
|
||||
|
||||
@Value("structures")
|
||||
@Abstractable
|
||||
@Default
|
||||
private List<ConfiguredStructure> structures = new ArrayList<>();
|
||||
|
||||
@Value("noise")
|
||||
@Abstractable
|
||||
private NoiseSeeded noiseEquation;
|
||||
|
||||
/*@Value("ores")
|
||||
@Abstractable
|
||||
@Default
|
||||
private OreHolder oreHolder = new OreHolder();*/
|
||||
|
||||
@Value("ocean.level")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int seaLevel = 62;
|
||||
|
||||
@Value("ocean.palette")
|
||||
@Abstractable
|
||||
private Palette oceanPalette;
|
||||
|
||||
@Value("elevation.equation")
|
||||
@Default
|
||||
@Abstractable
|
||||
private NoiseSeeded elevationEquation = NoiseSeeded.zero(2);
|
||||
|
||||
@Value("elevation.weight")
|
||||
@Default
|
||||
@Abstractable
|
||||
private double elevationWeight = 1;
|
||||
|
||||
/*@Value("flora")
|
||||
@Abstractable
|
||||
@Default
|
||||
private List<FloraLayer> flora = new ArrayList<>();
|
||||
|
||||
@Value("trees")
|
||||
@Abstractable
|
||||
@Default
|
||||
private List<TreeLayer> trees = new ArrayList<>();*/
|
||||
|
||||
@Value("slabs.enable")
|
||||
@Abstractable
|
||||
@Default
|
||||
private boolean doSlabs = false;
|
||||
|
||||
@Value("slabs.threshold")
|
||||
@Abstractable
|
||||
@Default
|
||||
private double slabThreshold = 0.0075D;
|
||||
|
||||
@Value("slabs.palettes")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<BlockType, Palette> slabPalettes;
|
||||
|
||||
@Value("slabs.stair-palettes")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<BlockType, Palette> stairPalettes;
|
||||
|
||||
@Value("interpolate-elevation")
|
||||
@Abstractable
|
||||
@Default
|
||||
private boolean interpolateElevation = true;
|
||||
|
||||
@Value("color")
|
||||
@Final
|
||||
@Default
|
||||
private int color = 0;
|
||||
|
||||
@Value("tags")
|
||||
@Default
|
||||
@Abstractable
|
||||
private Set<String> tags = new HashSet<>();
|
||||
|
||||
/*@Value("carving")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<UserDefinedCarver, Integer> carvers = new HashMap<>();*/
|
||||
|
||||
@Value("colors")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<String, Integer> colors = new HashMap<>(); // Plain ol' map, so platforms can decide what to do with colors (if anything).
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -12,12 +13,12 @@ import java.util.Map;
|
||||
public class PaletteHolderLoader implements TypeLoader<PaletteHolder> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public PaletteHolder load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
public PaletteHolder load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
List<Map<String, Integer>> palette = (List<Map<String, Integer>>) o;
|
||||
PaletteHolderBuilder builder = new PaletteHolderBuilder();
|
||||
for(Map<String, Integer> layer : palette) {
|
||||
for(Map.Entry<String, Integer> entry : layer.entrySet()) {
|
||||
builder.add(entry.getValue(), (Palette) configLoader.loadType(Palette.class, entry.getKey()));
|
||||
builder.add(entry.getValue(), configLoader.loadType(Palette.class, entry.getKey()));
|
||||
}
|
||||
}
|
||||
return builder.build();
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.dfsek.terra.addons.carver;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
@@ -15,100 +16,79 @@ import java.util.Map;
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class CarverTemplate implements AbstractableTemplate {
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("step")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int step = 2;
|
||||
|
||||
@Value("recalculate-magnitude")
|
||||
@Default
|
||||
@Abstractable
|
||||
private double recaclulateMagnitude = 4;
|
||||
|
||||
@Value("recalculate-direction")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Range recalc = new ConstantRange(8, 10);
|
||||
|
||||
@Value("length")
|
||||
@Abstractable
|
||||
private Range length;
|
||||
|
||||
@Value("start.x")
|
||||
@Abstractable
|
||||
private double startX;
|
||||
|
||||
@Value("start.y")
|
||||
@Abstractable
|
||||
private double startY;
|
||||
|
||||
@Value("start.z")
|
||||
@Abstractable
|
||||
private double startZ;
|
||||
|
||||
@Value("start.radius.x")
|
||||
@Abstractable
|
||||
private String radMX;
|
||||
|
||||
@Value("start.radius.y")
|
||||
@Abstractable
|
||||
private String radMY;
|
||||
|
||||
@Value("start.radius.z")
|
||||
@Abstractable
|
||||
private String radMZ;
|
||||
|
||||
@Value("start.height")
|
||||
@Abstractable
|
||||
private Range height;
|
||||
|
||||
@Value("cut.bottom")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int cutBottom = 0;
|
||||
|
||||
@Value("cut.top")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int cutTop = 0;
|
||||
|
||||
@Value("mutate.x")
|
||||
@Abstractable
|
||||
private double mutateX;
|
||||
|
||||
@Value("mutate.y")
|
||||
@Abstractable
|
||||
private double mutateY;
|
||||
|
||||
@Value("mutate.z")
|
||||
@Abstractable
|
||||
private double mutateZ;
|
||||
|
||||
@Value("palette.top")
|
||||
@Abstractable
|
||||
private CarverPalette top;
|
||||
|
||||
@Value("palette.bottom")
|
||||
@Abstractable
|
||||
private CarverPalette bottom;
|
||||
|
||||
@Value("palette.outer")
|
||||
@Abstractable
|
||||
private CarverPalette outer;
|
||||
|
||||
@Value("palette.inner")
|
||||
@Abstractable
|
||||
private CarverPalette inner;
|
||||
|
||||
@Value("shift")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<BlockType, MaterialSet> shift = new HashMap<>();
|
||||
|
||||
@Value("update")
|
||||
@Abstractable
|
||||
@Default
|
||||
private MaterialSet update = new MaterialSet();
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.flora;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.flora.flora.TerraFlora;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
@@ -10,55 +10,46 @@ import com.dfsek.terra.api.util.collection.MaterialSet;
|
||||
@SuppressWarnings({"FieldMayBeFinal", "unused"})
|
||||
public class FloraTemplate implements AbstractableTemplate {
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("spawnable")
|
||||
@Abstractable
|
||||
private MaterialSet spawnable;
|
||||
|
||||
@Value("spawn-blacklist")
|
||||
@Abstractable
|
||||
@Default
|
||||
private boolean spawnBlacklist = false;
|
||||
|
||||
|
||||
@Value("replaceable")
|
||||
@Abstractable
|
||||
@Default
|
||||
private MaterialSet replaceable = MaterialSet.empty();
|
||||
|
||||
@Value("irrigable")
|
||||
@Abstractable
|
||||
@Default
|
||||
private MaterialSet irrigable = null;
|
||||
|
||||
@Value("rotatable")
|
||||
@Abstractable
|
||||
@Default
|
||||
private MaterialSet rotatable = MaterialSet.empty();
|
||||
|
||||
@Value("physics")
|
||||
@Abstractable
|
||||
@Default
|
||||
private boolean doPhysics = false;
|
||||
|
||||
@Value("ceiling")
|
||||
@Abstractable
|
||||
@Default
|
||||
private boolean ceiling = false;
|
||||
|
||||
@Value("search")
|
||||
@Default
|
||||
@Abstractable
|
||||
private TerraFlora.Search search = TerraFlora.Search.UP;
|
||||
|
||||
@Value("max-placements")
|
||||
@Default
|
||||
@Abstractable
|
||||
private int maxPlacements = -1;
|
||||
|
||||
@Value("irrigable-offset")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int irrigableOffset;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.noise.config;
|
||||
|
||||
import com.dfsek.tectonic.config.Configuration;
|
||||
import com.dfsek.tectonic.config.MapConfiguration;
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
@@ -10,7 +10,7 @@ import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseProvider;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -23,14 +23,14 @@ public class NoiseSamplerBuilderLoader implements TypeLoader<NoiseSeeded> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NoiseSeeded load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
public NoiseSeeded load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
Map<String, Object> map = (Map<String, Object>) c;
|
||||
try {
|
||||
if(!noiseRegistry.contains((String) map.get("type"))) {
|
||||
throw new LoadException("No such noise function: " + map.get("type"));
|
||||
}
|
||||
ObjectTemplate<NoiseSeeded> normalizerTemplate = noiseRegistry.get(((String) map.get("type")).toUpperCase(Locale.ROOT)).get();
|
||||
loader.load(normalizerTemplate, new Configuration(map));
|
||||
loader.load(normalizerTemplate, new MapConfiguration(map));
|
||||
return normalizerTemplate.get();
|
||||
} catch(ConfigException e) {
|
||||
throw new LoadException("Unable to load noise function: ", e);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.ore;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.block.BlockType;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
@@ -15,37 +15,31 @@ import java.util.Map;
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class OreTemplate implements AbstractableTemplate {
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("material")
|
||||
@Abstractable
|
||||
private BlockState material;
|
||||
|
||||
@Value("material-overrides")
|
||||
@Default
|
||||
@Abstractable
|
||||
private Map<BlockType, BlockState> materials = new HashMap<>();
|
||||
|
||||
@Value("replace")
|
||||
@Abstractable
|
||||
private MaterialSet replaceable;
|
||||
|
||||
@Value("physics")
|
||||
@Abstractable
|
||||
@Default
|
||||
private boolean physics = false;
|
||||
|
||||
@Value("size")
|
||||
@Abstractable
|
||||
private Range size;
|
||||
|
||||
@Value("deform")
|
||||
@Abstractable
|
||||
@Default
|
||||
private double deform = 0.75D;
|
||||
|
||||
@Value("deform-frequency")
|
||||
@Abstractable
|
||||
@Default
|
||||
private double deformFrequency = 0.1D;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PaletteConfigType implements ConfigType<PaletteTemplate, Palette> {
|
||||
return new PaletteImpl.Singleton(main.getWorldHandle().createBlockData(((String) c).substring(6))); // Return single palette for BLOCK: shortcut.
|
||||
Palette obj = registry.get((String) c);
|
||||
if(obj == null)
|
||||
throw new LoadException("No such " + t.getTypeName() + " matching \"" + c + "\" was found in this registry.");
|
||||
throw new LoadException("No such " + t.getType().getTypeName() + " matching \"" + c + "\" was found in this registry.");
|
||||
return obj;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.palette;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.addons.palette.palette.PaletteLayerHolder;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
@@ -12,15 +12,14 @@ import java.util.List;
|
||||
@SuppressWarnings({"FieldMayBeFinal", "unused"})
|
||||
public class PaletteTemplate implements AbstractableTemplate {
|
||||
@Value("noise")
|
||||
@Abstractable
|
||||
@Default
|
||||
private NoiseSeeded noise = NoiseSeeded.zero(2);
|
||||
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("layers")
|
||||
@Abstractable
|
||||
private List<PaletteLayerHolder> palette;
|
||||
|
||||
public String getID() {
|
||||
|
||||
@@ -8,16 +8,17 @@ import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.seeded.NoiseSeeded;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class PaletteLayerLoader implements TypeLoader<PaletteLayerHolder> {
|
||||
private static final Type BLOCK_DATA_PROBABILITY_COLLECTION_TYPE;
|
||||
private static final AnnotatedType BLOCK_DATA_PROBABILITY_COLLECTION_TYPE;
|
||||
|
||||
static {
|
||||
try {
|
||||
BLOCK_DATA_PROBABILITY_COLLECTION_TYPE = PaletteLayerLoader.class.getDeclaredField("blockStateProbabilityCollection").getGenericType();
|
||||
BLOCK_DATA_PROBABILITY_COLLECTION_TYPE = PaletteLayerLoader.class.getDeclaredField("blockStateProbabilityCollection").getAnnotatedType();
|
||||
} catch(NoSuchFieldException e) {
|
||||
throw new Error("this should never happen. i dont know what you did to make this happen but something is very wrong.", e);
|
||||
}
|
||||
@@ -27,13 +28,13 @@ public class PaletteLayerLoader implements TypeLoader<PaletteLayerHolder> {
|
||||
private ProbabilityCollection<BlockState> blockStateProbabilityCollection;
|
||||
|
||||
@Override
|
||||
public PaletteLayerHolder load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
public PaletteLayerHolder load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
Map<String, Object> map = (Map<String, Object>) o;
|
||||
ProbabilityCollection<BlockState> collection = (ProbabilityCollection<BlockState>) configLoader.loadType(BLOCK_DATA_PROBABILITY_COLLECTION_TYPE, map.get("materials"));
|
||||
|
||||
NoiseSampler sampler = null;
|
||||
if(map.containsKey("noise")) {
|
||||
sampler = configLoader.loadClass(NoiseSeeded.class, map.get("noise")).apply(2403L);
|
||||
sampler = configLoader.loadType(NoiseSeeded.class, map.get("noise")).apply(2403L);
|
||||
}
|
||||
|
||||
if(collection == null) throw new LoadException("Collection is null: " + map.get("materials"));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.addons.structure;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.tectonic.config.ConfigTemplate;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
@@ -12,18 +12,16 @@ import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class StructureTemplate implements AbstractableTemplate, ConfigTemplate {
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("scripts")
|
||||
@Abstractable
|
||||
private ProbabilityCollection<Structure> structure;
|
||||
|
||||
@Value("spawn.start")
|
||||
@Abstractable
|
||||
private Range y;
|
||||
|
||||
@Value("spawn")
|
||||
@Abstractable
|
||||
private StructureSpawn spawn;
|
||||
|
||||
public String getID() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.addons.tree;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Final;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.config.AbstractableTemplate;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
@@ -11,19 +11,17 @@ import com.dfsek.terra.api.util.collection.ProbabilityCollection;
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class TreeTemplate implements AbstractableTemplate {
|
||||
@Value("scripts")
|
||||
@Abstractable
|
||||
private ProbabilityCollection<Structure> structure;
|
||||
|
||||
@Value("id")
|
||||
@Final
|
||||
private String id;
|
||||
|
||||
@Value("y-offset")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int yOffset = 0;
|
||||
|
||||
@Value("spawnable")
|
||||
@Abstractable
|
||||
private MaterialSet spawnable;
|
||||
|
||||
public ProbabilityCollection<Structure> getStructures() {
|
||||
|
||||
@@ -15,7 +15,7 @@ group = "com.dfsek.terra.common"
|
||||
dependencies {
|
||||
|
||||
"shadedApi"("com.dfsek:Paralithic:0.3.2")
|
||||
"implementation"("com.dfsek.tectonic:common:2.0.0")
|
||||
"shadedApi"("com.dfsek.tectonic:common:2.0.0")
|
||||
|
||||
"shadedApi"("net.jafama:jafama:2.3.2")
|
||||
"shadedApi"("org.yaml:snakeyaml:1.27")
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.api.tectonic;
|
||||
|
||||
import com.dfsek.tectonic.abstraction.TemplateProvider;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.tectonic.loading.object.ObjectTemplate;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface LoaderHolder {
|
||||
<T> LoaderHolder applyLoader(Type type, TypeLoader<T> loader);
|
||||
@@ -13,9 +13,9 @@ public interface LoaderHolder {
|
||||
return applyLoader((Type) type, loader);
|
||||
}
|
||||
|
||||
<T> LoaderHolder applyLoader(Type type, TemplateProvider<ObjectTemplate<T>> loader);
|
||||
<T> LoaderHolder applyLoader(Type type, Supplier<ObjectTemplate<T>> loader);
|
||||
|
||||
default <T> LoaderHolder applyLoader(Class<? extends T> type, TemplateProvider<ObjectTemplate<T>> loader) {
|
||||
default <T> LoaderHolder applyLoader(Class<? extends T> type, Supplier<ObjectTemplate<T>> loader) {
|
||||
return applyLoader((Type) type, loader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -204,7 +205,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> ConfigPackImpl applyLoader(Type type, TemplateProvider<ObjectTemplate<T>> loader) {
|
||||
public <T> ConfigPackImpl applyLoader(Type type, Supplier<ObjectTemplate<T>> loader) {
|
||||
abstractConfigLoader.registerLoader(type, loader);
|
||||
selfLoader.registerLoader(type, loader);
|
||||
return this;
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
@@ -66,7 +67,7 @@ public class CheckedRegistryImpl<T> implements CheckedRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
public T load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
return registry.load(t, c, loader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
@@ -53,7 +54,7 @@ public class LockedRegistryImpl<T> implements Registry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T load(Type t, Object c, ConfigLoader loader) throws LoadException {
|
||||
public T load(AnnotatedType t, Object c, ConfigLoader loader) throws LoadException {
|
||||
return registry.load(t, c, loader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.exception.DuplicateEntryException;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -33,10 +34,10 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
T obj = get((String) o);
|
||||
if(obj == null)
|
||||
throw new LoadException("No such " + type.getTypeName() + " matching \"" + o + "\" was found in this registry.");
|
||||
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o + "\" was found in this registry.");
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.meta.RegistryFactory;
|
||||
import com.dfsek.terra.api.util.generic.Lazy;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -22,7 +23,7 @@ public class RegistryFactoryImpl implements RegistryFactory {
|
||||
private final Lazy<TypeLoader<T>> loaderCache = Lazy.of(() -> loader.apply(this));
|
||||
|
||||
@Override
|
||||
public T load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
return loaderCache.value().load(type, o, configLoader);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user