Allows configuration of Generator interpolation smoothing

This commit is contained in:
dfsek
2020-10-18 14:26:41 -07:00
parent c3d5b55dcc
commit 55a74636a0
8 changed files with 13 additions and 5 deletions

View File

@@ -17,6 +17,6 @@ public final class FailoverGenerator extends UserDefinedGenerator {
palette.put(255, new RandomPalette<BlockData>(new Random(2403)).add(Material.STONE.createBlockData(), 1));
}
public FailoverGenerator() throws ParseException {
super("0", Collections.emptyList(), palette);
super("0", Collections.emptyList(), palette, false);
}
}

View File

@@ -150,7 +150,7 @@ public class BiomeConfig extends TerraConfig {
try {
// Get UserDefinedBiome instance representing this config.
this.biome = new UserDefinedBiome(vanillaBiome, dec, new UserDefinedGenerator(eq, Collections.emptyList(), palette.getPaletteMap()), getBoolean("erodible", false), biomeID);
this.biome = new UserDefinedBiome(vanillaBiome, dec, new UserDefinedGenerator(eq, Collections.emptyList(), palette.getPaletteMap(), getBoolean("prevent-smooth", false)), getBoolean("erodible", false), biomeID);
} catch(ParseException e) {
e.printStackTrace();
throw new ConfigException("Unable to parse noise equation!", getID());

View File

@@ -29,10 +29,12 @@ public class UserDefinedGenerator extends Generator {
private final NoiseFunction2 n2 = new NoiseFunction2();
private final NoiseFunction3 n3 = new NoiseFunction3();
private final boolean preventSmooth;
private static final Object noiseLock = new Object();
public UserDefinedGenerator(String equation, List<Variable> v, TreeMap<Integer, Palette<BlockData>> pa) throws ParseException {
public UserDefinedGenerator(String equation, List<Variable> v, TreeMap<Integer, Palette<BlockData>> pa, boolean preventSmooth) throws ParseException {
Parser p = new Parser();
p.registerFunction("noise2", n2);
p.registerFunction("noise3", n3);
@@ -47,6 +49,7 @@ public class UserDefinedGenerator extends Generator {
palettes[y] = d;
}
this.noiseExp = p.parse(equation, s);
this.preventSmooth = preventSmooth;
}
/**
* Gets the 2D noise at a pair of coordinates using the provided FastNoiseLite instance.
@@ -98,4 +101,9 @@ public class UserDefinedGenerator extends Generator {
public Palette<BlockData> getPalette(int y) {
return palettes[y];
}
@Override
public boolean useMinimalInterpolation() {
return preventSmooth;
}
}