From cb537d05148c1e5ccef20146dcda1ebf39ff3fc4 Mon Sep 17 00:00:00 2001 From: dfsek Date: Mon, 16 Nov 2020 23:32:04 -0700 Subject: [PATCH] Rewrite basically the whole generator again. Get rid of failsafe biomes because they are dumb --- build.gradle.kts | 2 +- lib/{Gaea-1.14.2.jar => Gaea-1.14.3.jar} | Bin 590492 -> 590723 bytes .../dfsek/terra/biome/UserDefinedBiome.java | 14 ++- .../dfsek/terra/biome/failsafe/FailType.java | 61 ------------ .../terra/biome/failsafe/FailoverBiome.java | 13 --- .../biome/failsafe/FailoverDecorator.java | 10 -- .../biome/failsafe/FailoverGenerator.java | 24 ----- .../terra/biome/grid/TerraBiomeGrid.java | 2 +- .../dfsek/terra/config/base/ConfigUtil.java | 11 --- .../config/genconfig/biome/BiomeConfig.java | 4 +- .../genconfig/biome/GeneratorOptions.java} | 89 ++---------------- .../terra/generation/ElevationEquation.java | 7 +- .../generation/ElevationInterpolator.java | 17 ++-- .../terra/generation/TerraChunkGenerator.java | 3 +- .../generation/config/WorldGenerator.java | 81 ++++++++++++++-- .../com/dfsek/terra/math/NoiseFunction2.java | 5 +- .../com/dfsek/terra/math/NoiseFunction3.java | 5 +- .../dfsek/terra/structure/spawn/AirSpawn.java | 4 +- .../terra/structure/spawn/LandSpawn.java | 4 +- .../terra/structure/spawn/OceanSpawn.java | 4 +- 20 files changed, 121 insertions(+), 239 deletions(-) rename lib/{Gaea-1.14.2.jar => Gaea-1.14.3.jar} (93%) delete mode 100644 src/main/java/com/dfsek/terra/biome/failsafe/FailType.java delete mode 100644 src/main/java/com/dfsek/terra/biome/failsafe/FailoverBiome.java delete mode 100644 src/main/java/com/dfsek/terra/biome/failsafe/FailoverDecorator.java delete mode 100644 src/main/java/com/dfsek/terra/biome/failsafe/FailoverGenerator.java rename src/main/java/com/dfsek/terra/{generation/UserDefinedGenerator.java => config/genconfig/biome/GeneratorOptions.java} (50%) diff --git a/build.gradle.kts b/build.gradle.kts index ea3cb99a1..4c4334e23 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,7 +35,7 @@ val versionObj = Version("1", "4", "0", true) version = versionObj dependencies { - val gaeaVersion = "1.14.2" + val gaeaVersion = "1.14.3" compileOnly(name = "Gaea-${gaeaVersion}", group = "") testImplementation(name = "Gaea-${gaeaVersion}", group = "") diff --git a/lib/Gaea-1.14.2.jar b/lib/Gaea-1.14.3.jar similarity index 93% rename from lib/Gaea-1.14.2.jar rename to lib/Gaea-1.14.3.jar index 966ebed95d2605ca6de05c5b3e1af279a03aecfa..62866ea34bd3ef50500de629c017194f2f8f2883 100644 GIT binary patch delta 13232 zcmaKS30RHW_y0NXIh}U%JS(Xr87e~(sf?FG88So(8A2pOgeD4&M7u%CkP<~I2ZfA9 zsSptrMb}*6n(4RRy-#(H@BjJtJnp;qXRY;FYme_*@3{wdn1n@`D7ZNB__7=hLYyOK z*X&X7=dq8lUgVM4mptwdR0PoVXPN2ZDGY~G#*fca)yg;JE@D`5e0`D;zPt{}#h>TN zvp{|s&qtP6ta1ADdjnY1^YN9tj26+t8`dL@{Edpi#5n(l@^Nk_%U*psT^>gwAlG|? zCiXlb!{LOe;k;5QEl|lwvEeBAdST7=V-{qi_LJ% z7KHvM=qQvH6$j&3k%K=I7!`LI45PM!dF1QKtG`D<4gQlafBH_b;<9F8`G0@KV|W4$1xp8wdlNs9Qn zw62^+5Vf(CHrzHxN)gYd1N%*O2j-bLBwfII*3LHwUPotnf0&{)YaieDw^4lAZWY4y zbhjHN9U6C1K#&&+UkE8|rr|_gC)u6|+>?8AiIc>EISn4*L_a<#+c^Jp%67^>EUkq` zV|aK0LGW@7X(Oz(1F6TK&k*g$jBGlc>$6>GqbxU$1Q73D@SeDFDzvA8L>J9aWfA3LWM@-x{BscHbNBg{I@wPUKjRSvD`X z|E#Um(v4f%ZbS6;Z~*mgnt27TNiSXh7YCBZGAGorQb$D`3ah6KJtB$}!3#12BEW4i7OMR=w zv()I6h+hHP>qpfzsc=sPdB@CNUZ1EEU|8VsP$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kjq|m?aVs2f+P8-ZAedis};2Do>PPb)8{|X8vUXTQNhXo!L!8X6-B_8EcSgZ zQslO#DXa3f9c30Z` zFT)`QIQKgopt168Vg=m)2OL-?iWG_cft=a%%57p*tn(9M>#0VOH9uj_`IteNd^D)#2qz&8dgjI*ck yjqmWL?^glJ@3RzfCz~P8U}gL8SN-b!U}XpM-Bw6t(38b;`La4fwE*s?r2hepC7ZDT diff --git a/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java b/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java index fe319332f..d8725e03e 100644 --- a/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java +++ b/src/main/java/com/dfsek/terra/biome/UserDefinedBiome.java @@ -1,7 +1,8 @@ package com.dfsek.terra.biome; +import com.dfsek.terra.config.genconfig.biome.GeneratorOptions; import com.dfsek.terra.generation.UserDefinedDecorator; -import com.dfsek.terra.generation.UserDefinedGenerator; +import org.bukkit.World; import org.polydev.gaea.biome.Biome; import org.polydev.gaea.biome.Decorator; import org.polydev.gaea.biome.Generator; @@ -13,14 +14,14 @@ import java.util.List; * Class representing a config-defined biome */ public class UserDefinedBiome implements Biome { - private final UserDefinedGenerator gen; + private final GeneratorOptions gen; private final UserDefinedDecorator decorator; private final org.bukkit.block.Biome vanilla; private final String id; private final boolean erode; - public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, UserDefinedGenerator gen, boolean erode, String id) { + public UserDefinedBiome(org.bukkit.block.Biome vanilla, UserDefinedDecorator dec, GeneratorOptions gen, boolean erode, String id) { this.vanilla = vanilla; this.decorator = dec; this.gen = gen; @@ -45,7 +46,7 @@ public class UserDefinedBiome implements Biome { */ @Override public Generator getGenerator() { - return gen; + return gen.getGenerator(0); } /** @@ -75,4 +76,9 @@ public class UserDefinedBiome implements Biome { public boolean isErodible() { return erode; } + + @Override + public Generator getGenerator(World w) { + return gen.getGenerator(w.getSeed()); + } } diff --git a/src/main/java/com/dfsek/terra/biome/failsafe/FailType.java b/src/main/java/com/dfsek/terra/biome/failsafe/FailType.java deleted file mode 100644 index bc5c7f959..000000000 --- a/src/main/java/com/dfsek/terra/biome/failsafe/FailType.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.dfsek.terra.biome.failsafe; - -import org.bukkit.Bukkit; -import org.polydev.gaea.biome.Biome; -import parsii.tokenizer.ParseException; - -/** - * What happens if terrain generation is attempted with an unrecoverable config error. - */ -@SuppressWarnings("unused") -public enum FailType { - /** - * Return failover biome, then shut down server to minimize damage. - * Generally the safest option. - */ - SHUTDOWN { - @Override - public Biome fail() { - Bukkit.getServer().shutdown(); - try { - return new FailoverBiome(); - } catch(ParseException e) { - e.printStackTrace(); - return null; - } - } - }, - /** - * Returns null, hard crashing the server, but not generating any corrupted terrain.
- * This option is NOT stable, but it has the least risk of blank chunks being generated. - * However, it has the highest risk of corruption! - */ - CRASH { - @Override - public Biome fail() { - return null; - } - }, - /** - * Returns a failover biome, which generates completely blank chunks. - * Recommended for debugging. - */ - FAILOVER { - @Override - public Biome fail() { - try { - return new FailoverBiome(); - } catch(ParseException e) { - e.printStackTrace(); - return null; - } - } - }; - - /** - * Performs the action specified by the enum type to occur on failure of terrain generation. - * - * @return Failover biome, if specified, null if not. - */ - public abstract Biome fail(); -} diff --git a/src/main/java/com/dfsek/terra/biome/failsafe/FailoverBiome.java b/src/main/java/com/dfsek/terra/biome/failsafe/FailoverBiome.java deleted file mode 100644 index e5e0f72b0..000000000 --- a/src/main/java/com/dfsek/terra/biome/failsafe/FailoverBiome.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dfsek.terra.biome.failsafe; - -import com.dfsek.terra.biome.UserDefinedBiome; -import parsii.tokenizer.ParseException; - -/** - * Blank biome to generate in case of a severe config error - */ -public final class FailoverBiome extends UserDefinedBiome { - public FailoverBiome() throws ParseException { - super(org.bukkit.block.Biome.PLAINS, new FailoverDecorator(), new FailoverGenerator(), false, "FAILSAFE"); - } -} diff --git a/src/main/java/com/dfsek/terra/biome/failsafe/FailoverDecorator.java b/src/main/java/com/dfsek/terra/biome/failsafe/FailoverDecorator.java deleted file mode 100644 index 1cc01f82b..000000000 --- a/src/main/java/com/dfsek/terra/biome/failsafe/FailoverDecorator.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.dfsek.terra.biome.failsafe; - -import com.dfsek.terra.generation.UserDefinedDecorator; -import org.polydev.gaea.math.ProbabilityCollection; - -public final class FailoverDecorator extends UserDefinedDecorator { - public FailoverDecorator() { - super(new ProbabilityCollection<>(), new ProbabilityCollection<>(), 0, 0); - } -} diff --git a/src/main/java/com/dfsek/terra/biome/failsafe/FailoverGenerator.java b/src/main/java/com/dfsek/terra/biome/failsafe/FailoverGenerator.java deleted file mode 100644 index 17469ba63..000000000 --- a/src/main/java/com/dfsek/terra/biome/failsafe/FailoverGenerator.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.dfsek.terra.biome.failsafe; - -import com.dfsek.terra.generation.UserDefinedGenerator; -import org.bukkit.Material; -import org.bukkit.block.data.BlockData; -import org.polydev.gaea.world.palette.Palette; -import org.polydev.gaea.world.palette.RandomPalette; -import parsii.tokenizer.ParseException; - -import java.util.HashMap; -import java.util.Random; -import java.util.TreeMap; - -public final class FailoverGenerator extends UserDefinedGenerator { - private static final TreeMap> palette = new TreeMap<>(); - - static { - palette.put(255, new RandomPalette(new Random(2403)).add(Material.STONE.createBlockData(), 1)); - } - - public FailoverGenerator() throws ParseException { - super("0", null, new HashMap<>(), palette, new TreeMap<>(), new HashMap<>(), false); - } -} diff --git a/src/main/java/com/dfsek/terra/biome/grid/TerraBiomeGrid.java b/src/main/java/com/dfsek/terra/biome/grid/TerraBiomeGrid.java index 045d69f03..d57aedb4e 100644 --- a/src/main/java/com/dfsek/terra/biome/grid/TerraBiomeGrid.java +++ b/src/main/java/com/dfsek/terra/biome/grid/TerraBiomeGrid.java @@ -57,7 +57,7 @@ public class TerraBiomeGrid extends BiomeGrid { if(failNum % 256 == 0) LangUtil.log("error.severe-config", Level.SEVERE, String.valueOf(x), String.valueOf(z)); failNum++; - return ConfigUtil.failType.fail(); + return null; } if(erode != null && b.isErodible() && erode.isEroded(xp, zp)) { return erosionGrid.getBiome(xp, zp, phase); diff --git a/src/main/java/com/dfsek/terra/config/base/ConfigUtil.java b/src/main/java/com/dfsek/terra/config/base/ConfigUtil.java index 98d502d6a..d19ae54e5 100644 --- a/src/main/java/com/dfsek/terra/config/base/ConfigUtil.java +++ b/src/main/java/com/dfsek/terra/config/base/ConfigUtil.java @@ -3,7 +3,6 @@ package com.dfsek.terra.config.base; import com.dfsek.terra.Debug; import com.dfsek.terra.Terra; import com.dfsek.terra.TerraWorld; -import com.dfsek.terra.biome.failsafe.FailType; import com.dfsek.terra.config.exception.ConfigException; import com.dfsek.terra.config.lang.LangUtil; import com.dfsek.terra.util.TagUtil; @@ -23,7 +22,6 @@ import java.util.List; import java.util.Objects; import java.util.Set; import java.util.jar.JarFile; -import java.util.logging.Level; import java.util.logging.Logger; public final class ConfigUtil { @@ -31,7 +29,6 @@ public final class ConfigUtil { public static long dataSave; // Period of population data saving, in ticks. public static boolean masterDisableCaves; public static int cacheSize; - public static FailType failType; public static void loadConfig(JavaPlugin main) { main.saveDefaultConfig(); @@ -54,14 +51,6 @@ public final class ConfigUtil { } } - - String fail = config.getString("fail-type", "SHUTDOWN"); - try { - failType = FailType.valueOf(fail); - } catch(IllegalArgumentException e) { - LangUtil.log("config.invalid-failover", Level.SEVERE, fail); - } - Logger logger = main.getLogger(); logger.info("Loading config values"); diff --git a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java index 97de6c1c1..8182cb28a 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/BiomeConfig.java @@ -9,7 +9,6 @@ import com.dfsek.terra.config.exception.ConfigException; import com.dfsek.terra.config.exception.NotFoundException; import com.dfsek.terra.config.genconfig.structure.StructureConfig; import com.dfsek.terra.generation.UserDefinedDecorator; -import com.dfsek.terra.generation.UserDefinedGenerator; import org.bukkit.block.data.BlockData; import org.bukkit.configuration.InvalidConfigurationException; import org.polydev.gaea.math.Range; @@ -171,8 +170,7 @@ public class BiomeConfig extends TerraConfig { try { // Get UserDefinedBiome instance representing this config. - UserDefinedGenerator gen = new UserDefinedGenerator(eq, elevation, config.getDefinedVariables(), palette.getPaletteMap(), slant, config.getNoiseBuilders(), getBoolean("prevent-smooth", false)); - gen.setElevationInterpolation(doElevationInterpolation); + GeneratorOptions gen = new GeneratorOptions(eq, elevation, config.getDefinedVariables(), palette.getPaletteMap(), slant, config.getNoiseBuilders(), getBoolean("prevent-smooth", false), doElevationInterpolation); this.biome = new UserDefinedBiome(vanillaBiome, dec, gen, getBoolean("erodible", false), biomeID); } catch(ParseException e) { e.printStackTrace(); diff --git a/src/main/java/com/dfsek/terra/generation/UserDefinedGenerator.java b/src/main/java/com/dfsek/terra/config/genconfig/biome/GeneratorOptions.java similarity index 50% rename from src/main/java/com/dfsek/terra/generation/UserDefinedGenerator.java rename to src/main/java/com/dfsek/terra/config/genconfig/biome/GeneratorOptions.java index b067a149b..dc62ec946 100644 --- a/src/main/java/com/dfsek/terra/generation/UserDefinedGenerator.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/biome/GeneratorOptions.java @@ -1,15 +1,11 @@ -package com.dfsek.terra.generation; +package com.dfsek.terra.config.genconfig.biome; import com.dfsek.terra.config.genconfig.noise.NoiseConfig; import com.dfsek.terra.generation.config.WorldGenerator; import com.dfsek.terra.math.BlankFunction; import com.dfsek.terra.util.DataUtil; -import org.bukkit.World; import org.bukkit.block.data.BlockData; import org.jetbrains.annotations.Nullable; -import org.polydev.gaea.biome.Generator; -import org.polydev.gaea.math.FastNoiseLite; -import org.polydev.gaea.math.Interpolator; import org.polydev.gaea.world.palette.Palette; import parsii.eval.Parser; import parsii.eval.Scope; @@ -17,10 +13,10 @@ import parsii.tokenizer.ParseException; import java.util.HashMap; import java.util.Map; -import java.util.UUID; +public class GeneratorOptions { -public class UserDefinedGenerator extends Generator { + private final Map generators = new HashMap<>(); private final boolean preventSmooth; @SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"}) @@ -34,11 +30,9 @@ public class UserDefinedGenerator extends Generator { private final Map userVariables; private final Map noiseBuilders; - private final Map gens = new HashMap<>(); - private boolean elevationInterpolation; + private final boolean elevationInterpolation; - - public UserDefinedGenerator(String equation, @Nullable String elevateEquation, Map userVariables, Map> paletteMap, Map> slantPaletteMap, Map noiseBuilders, boolean preventSmooth) + public GeneratorOptions(String equation, @Nullable String elevateEquation, Map userVariables, Map> paletteMap, Map> slantPaletteMap, Map noiseBuilders, boolean preventSmooth, boolean elevationInterpolation) throws ParseException { this.equation = equation; this.elevationEquation = elevateEquation; @@ -77,74 +71,11 @@ public class UserDefinedGenerator extends Generator { } slantPalettes[y] = slantPalette; } - - } - - /** - * Gets the 2D noise at a pair of coordinates using the provided FastNoiseLite instance. - * - * @param gen - The FastNoiseLite instance to use. - * @param x - The x coordinate. - * @param z - The z coordinate. - * @return double - Noise value at the specified coordinates. - */ - @Override - public double getNoise(FastNoiseLite gen, World w, int x, int z) { - return compute(w).getNoise(x, 0, z); - } - - /** - * Gets the 3D noise at a pair of coordinates using the provided FastNoiseLite instance. - * - * @param gen - The FastNoiseLite instance to use. - * @param x - The x coordinate. - * @param y - The y coordinate. - * @param z - The z coordinate. - * @return double - Noise value at the specified coordinates. - */ - @Override - public double getNoise(FastNoiseLite gen, World w, int x, int y, int z) { - return compute(w).getNoise(x, y, z); - } - - private WorldGenerator compute(World world) { - return gens.computeIfAbsent(world.getUID(), w -> new WorldGenerator(world, equation, elevationEquation, userVariables, noiseBuilders)); - } - - /** - * Gets the BlocPalette to generate the biome with. - * - * @return BlocPalette - The biome's palette. - */ - @Override - public Palette getPalette(int y) { - return palettes[y]; - } - - public Palette getSlantPalette(int y) { - return slantPalettes[y]; - } - - - @Override - public boolean useMinimalInterpolation() { - return preventSmooth; - } - - @Override - public Interpolator.Type getInterpolationType() { - return Interpolator.Type.LINEAR; - } - - public ElevationEquation getElevationEquation(World w) { - return compute(w).getElevationEquation(); - } - - public boolean interpolateElevation() { - return elevationInterpolation; - } - - public void setElevationInterpolation(boolean elevationInterpolation) { this.elevationInterpolation = elevationInterpolation; } + + public WorldGenerator getGenerator(long seed) { + return generators.computeIfAbsent(seed, s -> new WorldGenerator(seed, equation, elevationEquation, userVariables, noiseBuilders, palettes, slantPalettes, preventSmooth) + .setElevationInterpolation(elevationInterpolation)); + } } diff --git a/src/main/java/com/dfsek/terra/generation/ElevationEquation.java b/src/main/java/com/dfsek/terra/generation/ElevationEquation.java index af084cc42..4adb15c5a 100644 --- a/src/main/java/com/dfsek/terra/generation/ElevationEquation.java +++ b/src/main/java/com/dfsek/terra/generation/ElevationEquation.java @@ -3,7 +3,6 @@ package com.dfsek.terra.generation; import com.dfsek.terra.config.genconfig.noise.NoiseConfig; import com.dfsek.terra.math.NoiseFunction2; import com.dfsek.terra.math.NoiseFunction3; -import org.bukkit.World; import parsii.eval.Expression; import parsii.eval.Parser; import parsii.eval.Scope; @@ -19,7 +18,7 @@ public class ElevationEquation { private final Variable xVar = s.getVariable("x"); private final Variable zVar = s.getVariable("z"); - public ElevationEquation(World w, String elevateEquation, Map userVariables, Map noiseBuilders) { + public ElevationEquation(long seed, String elevateEquation, Map userVariables, Map noiseBuilders) { for(Map.Entry entry : userVariables.entrySet()) { s.getVariable(entry.getKey()).setValue(entry.getValue()); // Define all user variables. } @@ -28,11 +27,11 @@ public class ElevationEquation { for(Map.Entry e : noiseBuilders.entrySet()) { switch(e.getValue().getDimensions()) { case 2: - NoiseFunction2 function2 = new NoiseFunction2(w, e.getValue().getBuilder()); + NoiseFunction2 function2 = new NoiseFunction2(seed, e.getValue().getBuilder()); p.registerFunction(e.getKey(), function2); break; case 3: - NoiseFunction3 function3 = new NoiseFunction3(w, e.getValue().getBuilder()); + NoiseFunction3 function3 = new NoiseFunction3(seed, e.getValue().getBuilder()); p.registerFunction(e.getKey(), function3); break; } diff --git a/src/main/java/com/dfsek/terra/generation/ElevationInterpolator.java b/src/main/java/com/dfsek/terra/generation/ElevationInterpolator.java index 428ade7fc..7a67e69a9 100644 --- a/src/main/java/com/dfsek/terra/generation/ElevationInterpolator.java +++ b/src/main/java/com/dfsek/terra/generation/ElevationInterpolator.java @@ -1,12 +1,13 @@ package com.dfsek.terra.generation; import com.dfsek.terra.biome.grid.TerraBiomeGrid; +import com.dfsek.terra.generation.config.WorldGenerator; import org.bukkit.World; import org.polydev.gaea.generation.GenerationPhase; import org.polydev.gaea.math.Interpolator; public class ElevationInterpolator { - private final UserDefinedGenerator[][] gens = new UserDefinedGenerator[10][10]; + private final WorldGenerator[][] gens = new WorldGenerator[10][10]; private final double[][] values = new double[18][18]; private final int xOrigin; private final int zOrigin; @@ -19,13 +20,13 @@ public class ElevationInterpolator { for(int x = -2; x < 8; x++) { for(int z = -2; z < 8; z++) { - gens[x + 2][z + 2] = (UserDefinedGenerator) grid.getBiome(xOrigin + x * 4, zOrigin + z * 4, GenerationPhase.BASE).getGenerator(); + gens[x + 2][z + 2] = (WorldGenerator) grid.getBiome(xOrigin + x * 4, zOrigin + z * 4, GenerationPhase.BASE).getGenerator(); } } for(byte x = -1; x <= 16; x++) { for(byte z = -1; z <= 16; z++) { - UserDefinedGenerator generator = getGenerator(x, z); + WorldGenerator generator = getGenerator(x, z); if(compareGens((x / 4), (z / 4)) && generator.interpolateElevation()) { Interpolator interpolator = new Interpolator(biomeAvg(x / 4, z / 4, w), biomeAvg((x / 4) + 1, z / 4, w), @@ -38,16 +39,16 @@ public class ElevationInterpolator { } } - private UserDefinedGenerator getGenerator(int x, int z) { - return (UserDefinedGenerator) grid.getBiome(xOrigin + x, zOrigin + z, GenerationPhase.BASE).getGenerator(); + private WorldGenerator getGenerator(int x, int z) { + return (WorldGenerator) grid.getBiome(xOrigin + x, zOrigin + z, GenerationPhase.BASE).getGenerator(); } - private UserDefinedGenerator getStoredGen(int x, int z) { + private WorldGenerator getStoredGen(int x, int z) { return gens[x + 2][z + 2]; } private boolean compareGens(int x, int z) { - UserDefinedGenerator comp = getStoredGen(x, z); + WorldGenerator comp = getStoredGen(x, z); for(int xi = x - 2; xi <= x + 2; xi++) { for(int zi = z - 2; zi <= z + 2; zi++) { @@ -69,7 +70,7 @@ public class ElevationInterpolator { + elevate(getStoredGen(x + 1, z + 1), x * 4 + xOrigin, z * 4 + zOrigin, w)) / 9D; } - private double elevate(UserDefinedGenerator g, int x, int z, World w) { + private double elevate(WorldGenerator g, int x, int z, World w) { if(g.getElevationEquation(w) != null) return g.getElevationEquation(w).getNoise(x, z); return 0; } diff --git a/src/main/java/com/dfsek/terra/generation/TerraChunkGenerator.java b/src/main/java/com/dfsek/terra/generation/TerraChunkGenerator.java index 8dea8e9fe..049c2866f 100644 --- a/src/main/java/com/dfsek/terra/generation/TerraChunkGenerator.java +++ b/src/main/java/com/dfsek/terra/generation/TerraChunkGenerator.java @@ -9,6 +9,7 @@ import com.dfsek.terra.config.base.ConfigPack; import com.dfsek.terra.config.genconfig.biome.BiomeConfig; import com.dfsek.terra.config.genconfig.biome.BiomeSlabConfig; import com.dfsek.terra.config.lang.LangUtil; +import com.dfsek.terra.generation.config.WorldGenerator; import com.dfsek.terra.population.CavePopulator; import com.dfsek.terra.population.FloraPopulator; import com.dfsek.terra.population.OrePopulator; @@ -83,7 +84,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator { } private static Palette getPalette(int x, int y, int z, BiomeConfig c, ChunkInterpolator interpolator, ElevationInterpolator elevationInterpolator) { - Palette slant = ((UserDefinedGenerator) c.getBiome().getGenerator()).getSlantPalette(y); + Palette slant = ((WorldGenerator) c.getBiome().getGenerator()).getSlantPalette(y); if(slant != null) { boolean north = interpolator.getNoise(x, y - elevationInterpolator.getElevation(x, z + 1), z + 1) > 0; boolean south = interpolator.getNoise(x, y - elevationInterpolator.getElevation(x, z - 1), z - 1) > 0; diff --git a/src/main/java/com/dfsek/terra/generation/config/WorldGenerator.java b/src/main/java/com/dfsek/terra/generation/config/WorldGenerator.java index 51a72a5ea..ea3c9a25f 100644 --- a/src/main/java/com/dfsek/terra/generation/config/WorldGenerator.java +++ b/src/main/java/com/dfsek/terra/generation/config/WorldGenerator.java @@ -6,6 +6,11 @@ import com.dfsek.terra.generation.ElevationEquation; import com.dfsek.terra.math.NoiseFunction2; import com.dfsek.terra.math.NoiseFunction3; import org.bukkit.World; +import org.bukkit.block.data.BlockData; +import org.polydev.gaea.biome.Generator; +import org.polydev.gaea.math.FastNoiseLite; +import org.polydev.gaea.math.Interpolator; +import org.polydev.gaea.world.palette.Palette; import parsii.eval.Expression; import parsii.eval.Parser; import parsii.eval.Scope; @@ -14,29 +19,44 @@ import parsii.tokenizer.ParseException; import java.util.Map; -public class WorldGenerator { +public class WorldGenerator extends Generator { private final ElevationEquation elevationEquation; + @SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"}) + private final Palette[] palettes; + @SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"}) + private final Palette[] slantPalettes; + + private final boolean preventSmooth; + + private boolean elevationInterpolation = true; + private final Expression noiseExp; private final Scope s = new Scope(); private final Variable xVar = s.getVariable("x"); private final Variable yVar = s.getVariable("y"); private final Variable zVar = s.getVariable("z"); - public WorldGenerator(World w, String equation, String elevateEquation, Map userVariables, Map noiseBuilders) { + @SuppressWarnings({"rawtypes", "unchecked"}) + public WorldGenerator(long seed, String equation, String elevateEquation, Map userVariables, Map noiseBuilders, Palette[] palettes, Palette[] slantPalettes, boolean preventSmooth) { for(Map.Entry entry : userVariables.entrySet()) { s.getVariable(entry.getKey()).setValue(entry.getValue()); // Define all user variables. } Parser p = new Parser(); + this.preventSmooth = preventSmooth; + + this.palettes = palettes; + this.slantPalettes = slantPalettes; + for(Map.Entry e : noiseBuilders.entrySet()) { switch(e.getValue().getDimensions()) { case 2: - NoiseFunction2 function2 = new NoiseFunction2(w, e.getValue().getBuilder()); + NoiseFunction2 function2 = new NoiseFunction2(seed, e.getValue().getBuilder()); p.registerFunction(e.getKey(), function2); break; case 3: - NoiseFunction3 function3 = new NoiseFunction3(w, e.getValue().getBuilder()); + NoiseFunction3 function3 = new NoiseFunction3(seed, e.getValue().getBuilder()); p.registerFunction(e.getKey(), function3); break; } @@ -45,21 +65,68 @@ public class WorldGenerator { this.noiseExp = p.parse(equation, s); if(elevateEquation != null) { Debug.info("Using elevation equation"); - this.elevationEquation = new ElevationEquation(w, elevateEquation, userVariables, noiseBuilders); + this.elevationEquation = new ElevationEquation(seed, elevateEquation, userVariables, noiseBuilders); } else this.elevationEquation = null; } catch(ParseException e) { throw new IllegalArgumentException(); } } - public double getNoise(int x, int y, int z) { + public ElevationEquation getElevationEquation() { + return elevationEquation; + } + + @Override + public double getNoise(FastNoiseLite fastNoiseLite, World world, int x, int z) { + xVar.setValue(x); + yVar.setValue(0); + zVar.setValue(z); + return noiseExp.evaluate(); + } + + @Override + public double getNoise(FastNoiseLite fastNoiseLite, World world, int x, int y, int z) { xVar.setValue(x); yVar.setValue(y); zVar.setValue(z); return noiseExp.evaluate(); } - public ElevationEquation getElevationEquation() { + /** + * Gets the BlocPalette to generate the biome with. + * + * @return BlocPalette - The biome's palette. + */ + @Override + public Palette getPalette(int y) { + return palettes[y]; + } + + public Palette getSlantPalette(int y) { + return slantPalettes[y]; + } + + + @Override + public boolean useMinimalInterpolation() { + return preventSmooth; + } + + @Override + public Interpolator.Type getInterpolationType() { + return Interpolator.Type.LINEAR; + } + + public ElevationEquation getElevationEquation(World w) { return elevationEquation; } + + public boolean interpolateElevation() { + return elevationInterpolation; + } + + public WorldGenerator setElevationInterpolation(boolean elevationInterpolation) { + this.elevationInterpolation = elevationInterpolation; + return this; + } } diff --git a/src/main/java/com/dfsek/terra/math/NoiseFunction2.java b/src/main/java/com/dfsek/terra/math/NoiseFunction2.java index 08dc65c7c..2545e7e85 100644 --- a/src/main/java/com/dfsek/terra/math/NoiseFunction2.java +++ b/src/main/java/com/dfsek/terra/math/NoiseFunction2.java @@ -2,7 +2,6 @@ package com.dfsek.terra.math; import com.dfsek.terra.config.base.ConfigUtil; import com.dfsek.terra.generation.config.NoiseBuilder; -import org.bukkit.World; import org.polydev.gaea.math.FastNoiseLite; import parsii.eval.Expression; @@ -12,8 +11,8 @@ public class NoiseFunction2 implements NoiseFunction { private final Cache cache = new Cache(); private final FastNoiseLite gen; - public NoiseFunction2(World world, NoiseBuilder builder) { - this.gen = builder.build((int) world.getSeed()); + public NoiseFunction2(long seed, NoiseBuilder builder) { + this.gen = builder.build((int) seed); } @Override diff --git a/src/main/java/com/dfsek/terra/math/NoiseFunction3.java b/src/main/java/com/dfsek/terra/math/NoiseFunction3.java index e9294c79d..f257afff5 100644 --- a/src/main/java/com/dfsek/terra/math/NoiseFunction3.java +++ b/src/main/java/com/dfsek/terra/math/NoiseFunction3.java @@ -1,7 +1,6 @@ package com.dfsek.terra.math; import com.dfsek.terra.generation.config.NoiseBuilder; -import org.bukkit.World; import org.polydev.gaea.math.FastNoiseLite; import parsii.eval.Expression; @@ -10,8 +9,8 @@ import java.util.List; public class NoiseFunction3 implements NoiseFunction { private final FastNoiseLite gen; - public NoiseFunction3(World world, NoiseBuilder builder) { - this.gen = builder.build((int) world.getSeed()); + public NoiseFunction3(long seed, NoiseBuilder builder) { + this.gen = builder.build((int) seed); } @Override diff --git a/src/main/java/com/dfsek/terra/structure/spawn/AirSpawn.java b/src/main/java/com/dfsek/terra/structure/spawn/AirSpawn.java index a2fc71115..ee5212de0 100644 --- a/src/main/java/com/dfsek/terra/structure/spawn/AirSpawn.java +++ b/src/main/java/com/dfsek/terra/structure/spawn/AirSpawn.java @@ -5,7 +5,7 @@ import com.dfsek.terra.biome.UserDefinedBiome; import com.dfsek.terra.config.base.ConfigPack; import com.dfsek.terra.config.genconfig.biome.BiomeConfig; import com.dfsek.terra.generation.ElevationEquation; -import com.dfsek.terra.generation.UserDefinedGenerator; +import com.dfsek.terra.generation.config.WorldGenerator; import org.bukkit.World; import org.polydev.gaea.generation.GenerationPhase; @@ -21,7 +21,7 @@ public class AirSpawn extends Requirement { UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE); BiomeConfig c = wc.getBiome(b); if(y <= c.getOcean().getSeaLevel()) return false; - ElevationEquation elevationEquation = ((UserDefinedGenerator) b.getGenerator()).getElevationEquation(getWorld()); + ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation(getWorld()); int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z)); return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0; } diff --git a/src/main/java/com/dfsek/terra/structure/spawn/LandSpawn.java b/src/main/java/com/dfsek/terra/structure/spawn/LandSpawn.java index 1158c3f65..df6c3efa5 100644 --- a/src/main/java/com/dfsek/terra/structure/spawn/LandSpawn.java +++ b/src/main/java/com/dfsek/terra/structure/spawn/LandSpawn.java @@ -3,7 +3,7 @@ package com.dfsek.terra.structure.spawn; import com.dfsek.terra.TerraWorld; import com.dfsek.terra.biome.UserDefinedBiome; import com.dfsek.terra.generation.ElevationEquation; -import com.dfsek.terra.generation.UserDefinedGenerator; +import com.dfsek.terra.generation.config.WorldGenerator; import org.bukkit.World; import org.polydev.gaea.generation.GenerationPhase; @@ -16,7 +16,7 @@ public class LandSpawn extends Requirement { public boolean matches(int x, int y, int z) { TerraWorld tw = TerraWorld.getWorld(getWorld()); UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE); - ElevationEquation elevationEquation = ((UserDefinedGenerator) b.getGenerator()).getElevationEquation(getWorld()); + ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation(getWorld()); int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z)); return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) > 0; } diff --git a/src/main/java/com/dfsek/terra/structure/spawn/OceanSpawn.java b/src/main/java/com/dfsek/terra/structure/spawn/OceanSpawn.java index 25d247cc5..c8aad465d 100644 --- a/src/main/java/com/dfsek/terra/structure/spawn/OceanSpawn.java +++ b/src/main/java/com/dfsek/terra/structure/spawn/OceanSpawn.java @@ -4,7 +4,7 @@ import com.dfsek.terra.TerraWorld; import com.dfsek.terra.biome.UserDefinedBiome; import com.dfsek.terra.config.genconfig.biome.BiomeConfig; import com.dfsek.terra.generation.ElevationEquation; -import com.dfsek.terra.generation.UserDefinedGenerator; +import com.dfsek.terra.generation.config.WorldGenerator; import org.bukkit.World; import org.polydev.gaea.generation.GenerationPhase; @@ -19,7 +19,7 @@ public class OceanSpawn extends Requirement { UserDefinedBiome b = (UserDefinedBiome) tw.getGrid().getBiome(x, z, GenerationPhase.POPULATE); BiomeConfig c = tw.getConfig().getBiome(b); if(y > c.getOcean().getSeaLevel()) return false; - ElevationEquation elevationEquation = ((UserDefinedGenerator) b.getGenerator()).getElevationEquation(getWorld()); + ElevationEquation elevationEquation = ((WorldGenerator) b.getGenerator()).getElevationEquation(getWorld()); int yf = y - ((elevationEquation == null) ? 0 : (int) elevationEquation.getNoise(x, z)); return b.getGenerator().getNoise(getNoise(), getWorld(), x, yf, z) <= 0; }