From 451eca0aa9824a703120b7357470657a2d3f0651 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Fri, 17 Jan 2020 09:19:41 -0500 Subject: [PATCH] Biome specific generators --- .../java/ninja/bytecode/iris/CommandIris.java | 8 +- .../java/ninja/bytecode/iris/Settings.java | 9 +- .../bytecode/iris/command/CommandIris.java | 2 +- .../iris/generator/IrisGenerator.java | 69 +--- .../genobject/GenObjectDecorator.java | 2 +- .../generator/layer/BiomeNoiseGenerator.java | 36 ++ .../iris/generator/layer/GenLayerBase.java | 67 --- .../iris/generator/layer/GenLayerBiome.java | 27 +- .../ninja/bytecode/iris/pack/BiomeType.java | 8 + .../bytecode/iris/pack/CompiledDimension.java | 20 + .../ninja/bytecode/iris/pack/IrisBiome.java | 386 +++++++++++++++--- .../bytecode/iris/pack/IrisDimension.java | 3 - 12 files changed, 427 insertions(+), 210 deletions(-) create mode 100644 src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java delete mode 100644 src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBase.java create mode 100644 src/main/java/ninja/bytecode/iris/pack/BiomeType.java diff --git a/src/main/java/ninja/bytecode/iris/CommandIris.java b/src/main/java/ninja/bytecode/iris/CommandIris.java index 6dc29d276..07128e120 100644 --- a/src/main/java/ninja/bytecode/iris/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/CommandIris.java @@ -57,7 +57,7 @@ public class CommandIris implements CommandExecutor { IrisGenerator g = (IrisGenerator) w.getGenerator(); IrisBiome b = null; - for(IrisBiome i : g.getLoadedBiomes()) + for(IrisBiome i : g.getDimension().getBiomes()) { if(args[1].toLowerCase().equals(i.getName().toLowerCase().replaceAll("\\Q \\E", "_"))) { @@ -81,7 +81,7 @@ public class CommandIris implements CommandExecutor int x = (int) ((int) (29999983 / 1.2) * Math.random()); int z = (int) ((int) (29999983 / 1.2) * Math.random()); - if(g.getBiome(x, z).equals(b)) + if(g.getBiome((int) g.getOffsetX(x), (int) g.getOffsetZ(z)).equals(b)) { f = true; @@ -90,11 +90,11 @@ public class CommandIris implements CommandExecutor p.teleport(w.getHighestBlockAt(x, z).getLocation()); break; } - + else { t++; - + if(t > 30) { msg(sender, "Checked 30 " + b.getName() + " bearing chunks. All of them were underwater. Try Again!"); diff --git a/src/main/java/ninja/bytecode/iris/Settings.java b/src/main/java/ninja/bytecode/iris/Settings.java index c9e59deba..ebf6d8e71 100644 --- a/src/main/java/ninja/bytecode/iris/Settings.java +++ b/src/main/java/ninja/bytecode/iris/Settings.java @@ -18,23 +18,22 @@ public class Settings public int cascadeLimit = 14; public boolean interpolation = true; public boolean surfaceNoise = true; - public boolean baseNoise = true; } public static class GeneratorSettings { - public int hermiteSampleRadius = 6; + public int hermiteSampleRadius = 4; public double horizontalZoom = 2; public double heightFracture = 155; public double landScale = 0.5; - public double landChance = 0.5; - public double biomeEdgeScramble = 1550D; // 1550D + public double landChance = 0.6; + public double biomeEdgeScramble = 0; // 1550D public double roughness = 1.55; public double heightMultiplier = 0.806; public double heightExponentBase = 1; public double heightExponentMultiplier = 1.41; public double heightScale = 0.56; - public double baseHeight = 0.165; + public double baseHeight = 0.065; public int seaLevel = 63; public double caveDensity = 4; public double caveScale = 1.45; diff --git a/src/main/java/ninja/bytecode/iris/command/CommandIris.java b/src/main/java/ninja/bytecode/iris/command/CommandIris.java index ba0e61c63..008844b49 100644 --- a/src/main/java/ninja/bytecode/iris/command/CommandIris.java +++ b/src/main/java/ninja/bytecode/iris/command/CommandIris.java @@ -59,7 +59,7 @@ public class CommandIris implements CommandExecutor { IrisGenerator g = (IrisGenerator) w.getGenerator(); IrisBiome b = null; - for(IrisBiome i : g.getLoadedBiomes()) + for(IrisBiome i : g.getDimension().getBiomes()) { if(args[1].toLowerCase().equals(i.getName().toLowerCase().replaceAll("\\Q \\E", "_"))) { diff --git a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java index ad23f1614..663b18df4 100644 --- a/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java @@ -8,12 +8,10 @@ import org.bukkit.World; import org.bukkit.block.Biome; import org.bukkit.generator.BlockPopulator; -import net.md_5.bungee.api.ChatColor; import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.controller.PackController; import ninja.bytecode.iris.generator.genobject.GenObjectDecorator; -import ninja.bytecode.iris.generator.genobject.GenObjectGroup; -import ninja.bytecode.iris.generator.layer.GenLayerBase; +import ninja.bytecode.iris.generator.layer.BiomeNoiseGenerator; import ninja.bytecode.iris.generator.layer.GenLayerBiome; import ninja.bytecode.iris.generator.layer.GenLayerCarving; import ninja.bytecode.iris.generator.layer.GenLayerCaverns; @@ -21,6 +19,7 @@ import ninja.bytecode.iris.generator.layer.GenLayerCaves; import ninja.bytecode.iris.generator.layer.GenLayerCliffs; import ninja.bytecode.iris.generator.layer.GenLayerLayeredNoise; import ninja.bytecode.iris.generator.layer.GenLayerSnow; +import ninja.bytecode.iris.pack.BiomeType; import ninja.bytecode.iris.pack.CompiledDimension; import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.pack.IrisRegion; @@ -30,7 +29,6 @@ import ninja.bytecode.iris.util.IrisInterpolation; import ninja.bytecode.iris.util.MB; import ninja.bytecode.iris.util.ParallelChunkGenerator; import ninja.bytecode.shuriken.collections.GList; -import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.math.CNG; import ninja.bytecode.shuriken.math.M; @@ -59,24 +57,21 @@ public class IrisGenerator extends ParallelChunkGenerator private double[][][] scatterCache; private CNG scatter; - public GMap biomeCache = new GMap<>(); - private MB WATER = new MB(Material.STATIONARY_WATER); private MB ICE = new MB(Material.ICE); private MB PACKED_ICE = new MB(Material.PACKED_ICE); + private MB WATER = new MB(Material.STATIONARY_WATER); private MB BEDROCK = new MB(Material.BEDROCK); - private GList internal; private GenLayerLayeredNoise glLNoise; private GenLayerBiome glBiome; private GenLayerCaves glCaves; private GenLayerCarving glCarving; private GenLayerCaverns glCaverns; private GenLayerSnow glSnow; - private GenLayerBase glBase; + private BiomeNoiseGenerator glBase; private GenLayerCliffs glCliffs; private RNG rTerrain; private CompiledDimension dim; private World world; - private GMap schematicCache = new GMap<>(); public IrisGenerator() { @@ -87,26 +82,6 @@ public class IrisGenerator extends ParallelChunkGenerator { this.dim = dim; L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes..."); - internal = IrisBiome.getAllBiomes(); - - for(IrisBiome i : dim.getBiomes()) - { - for(IrisBiome j : internal.copy()) - { - if(j.getName().equals(i.getName())) - { - internal.remove(j); - L.i(ChatColor.LIGHT_PURPLE + "Internal Biome: " + ChatColor.WHITE + j.getName() + ChatColor.LIGHT_PURPLE + " overwritten by dimension " + ChatColor.WHITE + dim.getName()); - } - } - } - - internal.addAll(dim.getBiomes()); - - for(IrisBiome i : internal) - { - biomeCache.put(i.getName(), i); - } } public int scatterInt(int x, int y, int z, int bound) @@ -124,17 +99,11 @@ public class IrisGenerator extends ParallelChunkGenerator return scatter(x, y, z) > chance; } - public GList getLoadedBiomes() - { - return internal; - } - @Override public void onInit(World world, Random random) { this.world = world; rTerrain = new RNG(world.getSeed()); - glBase = new GenLayerBase(this, world, random, rTerrain.nextParallelRNG(1)); glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2)); glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes()); glCaves = new GenLayerCaves(this, world, random, rTerrain.nextParallelRNG(-1)); @@ -162,9 +131,9 @@ public class IrisGenerator extends ParallelChunkGenerator int m = 0; - for(IrisBiome i : biomeCache.values()) + for(IrisBiome i : getDimension().getBiomes()) { - i.seal(getRTerrain().nextParallelRNG(1922 - m++)); + i.seal(getRTerrain().nextParallelRNG(3922 - m++)); } } @@ -181,7 +150,7 @@ public class IrisGenerator extends ParallelChunkGenerator public IrisBiome biome(String name) { - return biomeCache.get(name); + return getDimension().getBiomeByName(name); } public double getOffsetX(double x) @@ -273,7 +242,7 @@ public class IrisGenerator extends ParallelChunkGenerator IrisBiome nbiome = height < 63 ? getOcean(biome, height) : biome; biome = nbiome; biome = height > 61 && height < 65 ? frozen ? biome : getBeach(biome) : biome; - biome = height > 63 && biome.isCore() ? getBeach(biome) : biome; + biome = height > 63 && biome.getType().equals(BiomeType.FLUID) ? getBeach(biome) : biome; for(int i = 0; i < max; i++) { @@ -382,17 +351,7 @@ public class IrisGenerator extends ParallelChunkGenerator { IrisBiome biome = glBiome.getBiome(x, z); double h = Iris.settings.gen.baseHeight + biome.getHeight(); - - if(Iris.settings.performance.baseNoise) - { - h += (glBase.getHeight(x, z) * 0.5) - (0.08); - } - - else - { - h += 0.00001; - } - + h += biome.getGenerator().getHeight(x, z); plan.setHeight(x, z, h); return h; } @@ -405,16 +364,6 @@ public class IrisGenerator extends ParallelChunkGenerator return world; } - public GMap getSchematicCache() - { - return schematicCache; - } - - public void setSchematicCache(GMap schematicCache) - { - this.schematicCache = schematicCache; - } - public RNG getRTerrain() { return rTerrain; diff --git a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java index 6af2e5db1..5e984ccdd 100644 --- a/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java +++ b/src/main/java/ninja/bytecode/iris/generator/genobject/GenObjectDecorator.java @@ -35,7 +35,7 @@ public class GenObjectDecorator extends BlockPopulator this.g = generator; populationCache = new GMap<>(); - for(IrisBiome i : generator.getLoadedBiomes()) + for(IrisBiome i : generator.getDimension().getBiomes()) { GMap gc = new GMap<>(); diff --git a/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java b/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java new file mode 100644 index 000000000..467b8e6c6 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/generator/layer/BiomeNoiseGenerator.java @@ -0,0 +1,36 @@ +package ninja.bytecode.iris.generator.layer; + +import ninja.bytecode.iris.pack.IrisBiome; +import ninja.bytecode.iris.util.GenLayer; +import ninja.bytecode.shuriken.math.CNG; +import ninja.bytecode.shuriken.math.RNG; + +public class BiomeNoiseGenerator +{ + protected IrisBiome biome; + protected CNG gen; + private double block = 1D / 255D; + + public BiomeNoiseGenerator(RNG rng, IrisBiome biome) + { + this.biome = biome; + //@builder + gen = new CNG(rng.nextParallelRNG(31289 - biome.getName().length() * biome.getRealBiome().ordinal()), 1D, 1) + .scale(0.0075 * biome.getGenScale()) + .fractureWith(new CNG(rng.nextParallelRNG(2922 * biome.getName().length() - biome.getRealBiome().ordinal()), 1D, 1) + .scale(0.0075 * biome.getGenSwirlScale()), 20D * biome.getGenSwirl()); + //@done + } + + public double getHeight(double x, double z) + { + if(biome.getGenAmplifier() == 0) + { + return 0; + } + + double r = block * 52; + double m = biome.getGenAmplifier() < 1D ? (r - (biome.getGenAmplifier() * r)) : 0; + return (gen.noise(x, z) * biome.getGenAmplifier() * r) + m; + } +} diff --git a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBase.java b/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBase.java deleted file mode 100644 index 36f8e2c14..000000000 --- a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBase.java +++ /dev/null @@ -1,67 +0,0 @@ -package ninja.bytecode.iris.generator.layer; - -import java.util.Random; - -import org.bukkit.World; - -import ninja.bytecode.iris.Iris; -import ninja.bytecode.iris.generator.IrisGenerator; -import ninja.bytecode.iris.util.GenLayer; -import ninja.bytecode.shuriken.math.CNG; -import ninja.bytecode.shuriken.math.M; -import ninja.bytecode.shuriken.math.RNG; - -public class GenLayerBase extends GenLayer -{ - private CNG gen; - private CNG fracture; - private CNG hfracture; - private CNG height; - private CNG superheight; - - public GenLayerBase(IrisGenerator iris, World world, Random random, RNG rng) - { - //@builder - super(iris, world, random, rng); - hfracture = new CNG(rng.nextParallelRNG(6), 1, 2) - .scale(0.0024); - gen = new CNG(rng.nextParallelRNG(7), 0.24D, 7) - .scale(0.0072) - .amp(0.5) - .freq(1.1) - .fractureWith(new CNG(rng.nextParallelRNG(8), 1, 6) - .scale(0.0007) - .injectWith(CNG.MULTIPLY) - .child(new CNG(rng.nextParallelRNG(9), 0.745, 2) - .scale(0.001)), 44); - height = new CNG(rng.nextParallelRNG(10), 1, 8) - .scale(0.0017601 * Iris.settings.gen.heightScale) - .fractureWith(new CNG(rng.nextParallelRNG(11), 1, 6) - .scale(0.0174) - .fractureWith(new CNG(rng.nextParallelRNG(12), 1, 1) - .scale(0.0034), 31) - .scale(0.066), 58); - superheight = new CNG(rng.nextParallelRNG(13), 1, 6) - .scale(0.0125) - .fractureWith(new CNG(rng.nextParallelRNG(14), 1, 1) - .scale(0.013), 250); - fracture = new CNG(rng.nextParallelRNG(15), 0.6D, 4) - .scale(0.01); - //@done - } - - public double getHeight(double x, double z) - { - return M.clip(Math.pow(height.noise(x + (hfracture.noise(x, z) * Iris.settings.gen.heightFracture), z + (hfracture.noise(z, x) * Iris.settings.gen.heightFracture)), Iris.settings.gen.heightExponentBase + (superheight.noise(x, z) * Iris.settings.gen.heightExponentMultiplier)) * Iris.settings.gen.heightMultiplier, 0D, 1D); - } - - @Override - public double generateLayer(double gnoise, double dx, double dz) - { - double noise = gnoise + getHeight(dx, dz); - double fnoise = fracture.noise(dx, dz); - dx += (fnoise * 44); - dz -= (fnoise * 44); - return ((noise * 0.185) + (gen.noise(dx, dz) * (0.15 + (noise * 0.65)))); - } -} diff --git a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java b/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java index f4422f722..36f9d4c68 100644 --- a/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java +++ b/src/main/java/ninja/bytecode/iris/generator/layer/GenLayerBiome.java @@ -28,9 +28,16 @@ public class GenLayerBiome extends GenLayer public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng, GList biomes) { super(iris, world, random, rng); - island = new CNG(rng.nextParallelRNG(10334), 1D, 3).scale(0.003 * Iris.settings.gen.landScale).fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 12).scale(0.6), 180); - fracture = new CNG(rng.nextParallelRNG(28), 1D, 24).scale(0.0021).fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 12).scale(0.01), 12250); - factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 4).scale(0.02), 56); + //@builder + island = new CNG(rng.nextParallelRNG(10334), 1D, 1) + .scale(0.003 * Iris.settings.gen.landScale) + .fractureWith(new CNG(rng.nextParallelRNG(1211), 1D, 1).scale(0.0001 * Iris.settings.gen.landScale), 600); + fracture = new CNG(rng.nextParallelRNG(28), 1D, 4).scale(0.0021) + .fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2) + .scale(0.01), 12250); + factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 4) + .scale(0.02), 56); + //@done regions = new GMap<>(); for(IrisBiome i : biomes) @@ -61,18 +68,6 @@ public class GenLayerBiome extends GenLayer v += 13 - i.getName().length(); i.setGen(new EnumPolygonGenerator(rng.nextParallelRNG(33 + v), 0.000255 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory)); } - - int m = 0; - - for(IrisRegion i : regions.values()) - { - for(IrisBiome j : i.getBiomes()) - { - j.seal(iris.getRTerrain().nextParallelRNG(3922 - m++)); - } - - i.getBeach().seal(iris.getRTerrain().nextParallelRNG(3922 - m++)); - } } public boolean hasBorder(int checks, double distance, double... dims) @@ -142,7 +137,7 @@ public class GenLayerBiome extends GenLayer cbi = getRegionGenerator(x, z).getChoice(x, z); } - else if(land < 0.4) + else if(land < 0.1) { cbi = iris.biome("Deep Ocean"); } diff --git a/src/main/java/ninja/bytecode/iris/pack/BiomeType.java b/src/main/java/ninja/bytecode/iris/pack/BiomeType.java new file mode 100644 index 000000000..b92610de5 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/pack/BiomeType.java @@ -0,0 +1,8 @@ +package ninja.bytecode.iris.pack; + +public enum BiomeType +{ + LAND, + FLUID, + FRONT; +} diff --git a/src/main/java/ninja/bytecode/iris/pack/CompiledDimension.java b/src/main/java/ninja/bytecode/iris/pack/CompiledDimension.java index 47d66b25a..a3aeea272 100644 --- a/src/main/java/ninja/bytecode/iris/pack/CompiledDimension.java +++ b/src/main/java/ninja/bytecode/iris/pack/CompiledDimension.java @@ -12,23 +12,29 @@ import java.util.zip.GZIPOutputStream; import org.bukkit.World.Environment; import org.bukkit.block.Biome; +import net.md_5.bungee.api.ChatColor; import ninja.bytecode.iris.generator.genobject.GenObjectGroup; import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.io.CustomOutputStream; import ninja.bytecode.shuriken.json.JSONObject; +import ninja.bytecode.shuriken.logging.L; +import ninja.bytecode.shuriken.math.RNG; import ninja.bytecode.shuriken.reaction.O; public class CompiledDimension { + public static IrisBiome theVoid = new IrisBiome("Void", Biome.VOID).height(0).seal(RNG.r); private IrisDimension dimension; private GList biomes; + private GMap biomeCache; private GMap objects; public CompiledDimension(IrisDimension dimension) { this.dimension = dimension; biomes = new GList<>(); + biomeCache = new GMap<>(); objects = new GMap<>(); } @@ -101,6 +107,7 @@ public class CompiledDimension public void registerBiome(IrisBiome j) { biomes.add(j); + biomeCache.put(j.getName(), j); } public void registerObject(GenObjectGroup g) @@ -149,4 +156,17 @@ public class CompiledDimension { biomes.sort(); } + + public IrisBiome getBiomeByName(String name) + { + IrisBiome b = biomeCache.get(name); + + if(b == null) + { + L.f(ChatColor.RED + "Cannot Find Biome: " + ChatColor.GOLD + name); + return theVoid; + } + + return b; + } } diff --git a/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java b/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java index 3af28906a..c87b66e8f 100644 --- a/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/pack/IrisBiome.java @@ -7,6 +7,7 @@ import org.bukkit.block.Biome; import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.controller.PackController; +import ninja.bytecode.iris.generator.layer.BiomeNoiseGenerator; import ninja.bytecode.iris.util.MB; import ninja.bytecode.iris.util.PolygonGenerator; import ninja.bytecode.shuriken.collections.GList; @@ -24,30 +25,11 @@ public class IrisBiome public static final double MAX_HEIGHT = 0.77768; public static final double IDEAL_HEIGHT = 0.0527; public static final double MIN_HEIGHT = -0.0218; - - //@builder - private static final IrisBiome OCEAN = new IrisBiome("Ocean", Biome.OCEAN) - .height(-0.4) - .coreBiome() - .surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL)) - .simplexSurface(); - private static final IrisBiome FROZEN_OCEAN = new IrisBiome("Frozen Ocean", Biome.FROZEN_OCEAN) - .height(-0.4) - .coreBiome() - .surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL)) - .simplexSurface(); - private static final IrisBiome DEEP_OCEAN = new IrisBiome("Deep Ocean", Biome.DEEP_OCEAN) - .height(-0.6) - .coreBiome() - .surface(MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL)) - .simplexSurface(); - - //@done private static final GMap map = build(); private String name; + private String parent; private Biome realBiome; private double height; - private double amp; private GList rock; private int rockDepth; private GList surface; @@ -67,7 +49,13 @@ public class IrisBiome private double snow; private double cliffChance; private double cliffScale; + private double genScale; + private double genAmplifier; + private double genSwirl; + private double genSwirlScale; private boolean cliffs; + private BiomeNoiseGenerator bng; + private BiomeType type; private String region; private GMap schematicGroups; private PolygonGenerator.EnumPolygonGenerator poly; @@ -89,16 +77,6 @@ public class IrisBiome return MIN_HEIGHT; } - public static IrisBiome getOcean() - { - return OCEAN; - } - - public static IrisBiome getDeepOcean() - { - return DEEP_OCEAN; - } - public static GMap getMap() { return map; @@ -135,13 +113,18 @@ public class IrisBiome this.region = "default"; this.core = false; this.name = name; + type = BiomeType.LAND; cliffs = false; + genScale = 1; + genAmplifier = 0.35; + genSwirl = 1; + genSwirlScale = 1; cliffScale = 1; cliffChance = 0.37; + parent = ""; dirtDepth = 2; this.realBiome = realBiome; this.height = IDEAL_HEIGHT; - this.amp = 0.31; rockDepth = 11; surfaceScale = 1; subSurfaceScale = 1; @@ -177,7 +160,7 @@ public class IrisBiome fromJSON(o, true); } - public void seal(RNG rng) + public IrisBiome seal(RNG rng) { if(simplexScatter) { @@ -226,14 +209,35 @@ public class IrisBiome return g.scale(rockScale).fractureWith(new CNG(rng.nextParallelRNG(551), 1D, 2).scale(0.0155), 224); }); } + + bng = new BiomeNoiseGenerator(rng.nextParallelRNG(2077), this); + + return this; + } + + public BiomeNoiseGenerator getGenerator() + { + if(polySub == null) + { + L.w(getName() + " is not sealed!"); + } + + return bng; } public void fromJSON(JSONObject o, boolean chain) { name = o.getString("name"); realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_")); + type = BiomeType.valueOf(o.getString("type").toUpperCase().replaceAll(" ", "_")); J.attempt(() -> region = o.getString("region")); + J.attempt(() -> parent = o.getString("parent")); J.attempt(() -> height = o.getDouble("height")); + J.attempt(() -> height = o.getDouble("genHeight")); + J.attempt(() -> genAmplifier = o.getDouble("genAmplifier")); + J.attempt(() -> genSwirl = o.getDouble("genSwirl")); + J.attempt(() -> genSwirlScale = o.getDouble("genSwirlScale")); + J.attempt(() -> genScale = o.getDouble("genScale")); J.attempt(() -> snow = o.getDouble("snow")); J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth")); J.attempt(() -> dirtDepth = o.getInt("dirtDepth")); @@ -284,9 +288,15 @@ public class IrisBiome { JSONObject j = new JSONObject(); j.put("name", name); + J.attempt(() -> j.put("parent", parent)); J.attempt(() -> j.put("region", region)); J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " "))); - J.attempt(() -> j.put("height", height)); + J.attempt(() -> j.put("type", type.name().toLowerCase().replaceAll("_", " "))); + J.attempt(() -> j.put("genHeight", height)); + J.attempt(() -> j.put("genScale", genScale)); + J.attempt(() -> j.put("genSwirl", genSwirl)); + J.attempt(() -> j.put("genSwirlScale", genSwirlScale)); + J.attempt(() -> j.put("genAmplifier", genAmplifier)); J.attempt(() -> j.put("snow", snow)); J.attempt(() -> j.put("cliffs", cliffs)); J.attempt(() -> j.put("cliffScale", cliffScale)); @@ -469,12 +479,6 @@ public class IrisBiome return this; } - public IrisBiome amp(double amp) - { - this.amp = amp; - return this; - } - public String getName() { return name; @@ -490,11 +494,6 @@ public class IrisBiome return height; } - public double getAmp() - { - return amp; - } - public GList getSurface() { return surface; @@ -598,11 +597,6 @@ public class IrisBiome } public static GList getBiomes() - { - return map.v().remove(IrisBiome.OCEAN, IrisBiome.DEEP_OCEAN); - } - - public static GList getAllBiomes() { return map.v(); } @@ -614,7 +608,7 @@ public class IrisBiome return map.get(biome); } - return IrisBiome.OCEAN; + return null; } public GMap getSchematicGroups() @@ -680,14 +674,268 @@ public class IrisBiome return cliffChance; } + public String getParent() + { + return parent; + } + + public boolean isScatterSurfaceRock() + { + return scatterSurfaceRock; + } + + public boolean isScatterSurfaceSub() + { + return scatterSurfaceSub; + } + + public double getSurfaceScale() + { + return surfaceScale; + } + + public double getSubSurfaceScale() + { + return subSurfaceScale; + } + + public double getRockScale() + { + return rockScale; + } + + public boolean isSimplexScatterRock() + { + return simplexScatterRock; + } + + public boolean isSimplexScatterSub() + { + return simplexScatterSub; + } + + public BiomeType getType() + { + return type; + } + + public PolygonGenerator.EnumPolygonGenerator getPolySub() + { + return polySub; + } + + public PolygonGenerator.EnumPolygonGenerator getPolyRock() + { + return polyRock; + } + + public double getGenScale() + { + return genScale; + } + + public void setGenScale(double genScale) + { + this.genScale = genScale; + } + + public double getGenAmplifier() + { + return genAmplifier; + } + + public void setGenAmplifier(double genAmplifier) + { + this.genAmplifier = genAmplifier; + } + + public double getGenSwirl() + { + return genSwirl; + } + + public void setGenSwirl(double genSwirl) + { + this.genSwirl = genSwirl; + } + + public void setName(String name) + { + this.name = name; + } + + public void setParent(String parent) + { + this.parent = parent; + } + + public void setRealBiome(Biome realBiome) + { + this.realBiome = realBiome; + } + + public void setHeight(double height) + { + this.height = height; + } + + public void setRock(GList rock) + { + this.rock = rock; + } + + public void setRockDepth(int rockDepth) + { + this.rockDepth = rockDepth; + } + + public void setSurface(GList surface) + { + this.surface = surface; + } + + public void setDirt(GList dirt) + { + this.dirt = dirt; + } + + public void setScatterChance(GMap scatterChance) + { + this.scatterChance = scatterChance; + } + + public void setScatterSurface(boolean scatterSurface) + { + this.scatterSurface = scatterSurface; + } + + public void setScatterSurfaceRock(boolean scatterSurfaceRock) + { + this.scatterSurfaceRock = scatterSurfaceRock; + } + + public void setScatterSurfaceSub(boolean scatterSurfaceSub) + { + this.scatterSurfaceSub = scatterSurfaceSub; + } + + public void setCore(boolean core) + { + this.core = core; + } + + public void setDirtDepth(int dirtDepth) + { + this.dirtDepth = dirtDepth; + } + + public void setSurfaceScale(double surfaceScale) + { + this.surfaceScale = surfaceScale; + } + + public void setSubSurfaceScale(double subSurfaceScale) + { + this.subSurfaceScale = subSurfaceScale; + } + + public void setRockScale(double rockScale) + { + this.rockScale = rockScale; + } + + public void setSimplexScatter(boolean simplexScatter) + { + this.simplexScatter = simplexScatter; + } + + public void setSimplexScatterRock(boolean simplexScatterRock) + { + this.simplexScatterRock = simplexScatterRock; + } + + public void setSimplexScatterSub(boolean simplexScatterSub) + { + this.simplexScatterSub = simplexScatterSub; + } + + public void setSnow(double snow) + { + this.snow = snow; + } + + public void setCliffChance(double cliffChance) + { + this.cliffChance = cliffChance; + } + + public void setCliffScale(double cliffScale) + { + this.cliffScale = cliffScale; + } + + public void setCliffs(boolean cliffs) + { + this.cliffs = cliffs; + } + + public void setType(BiomeType type) + { + this.type = type; + } + + public void setRegion(String region) + { + this.region = region; + } + + public void setSchematicGroups(GMap schematicGroups) + { + this.schematicGroups = schematicGroups; + } + + public void setPoly(PolygonGenerator.EnumPolygonGenerator poly) + { + this.poly = poly; + } + + public void setPolySub(PolygonGenerator.EnumPolygonGenerator polySub) + { + this.polySub = polySub; + } + + public void setPolyRock(PolygonGenerator.EnumPolygonGenerator polyRock) + { + this.polyRock = polyRock; + } + + public double getGenSwirlScale() + { + return genSwirlScale; + } + + public void setGenSwirlScale(double genSwirlScale) + { + this.genSwirlScale = genSwirlScale; + } + + public BiomeNoiseGenerator getBng() + { + return bng; + } + + public void setBng(BiomeNoiseGenerator bng) + { + this.bng = bng; + } + @Override public int hashCode() { final int prime = 31; int result = 1; + result = prime * result + ((bng == null) ? 0 : bng.hashCode()); long temp; - temp = Double.doubleToLongBits(amp); - result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(cliffChance); result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(cliffScale); @@ -696,9 +944,18 @@ public class IrisBiome result = prime * result + (core ? 1231 : 1237); result = prime * result + ((dirt == null) ? 0 : dirt.hashCode()); result = prime * result + dirtDepth; + temp = Double.doubleToLongBits(genAmplifier); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(genScale); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(genSwirl); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(genSwirlScale); + result = prime * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(height); result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + ((name == null) ? 0 : name.hashCode()); + result = prime * result + ((parent == null) ? 0 : parent.hashCode()); result = prime * result + ((poly == null) ? 0 : poly.hashCode()); result = prime * result + ((polyRock == null) ? 0 : polyRock.hashCode()); result = prime * result + ((polySub == null) ? 0 : polySub.hashCode()); @@ -723,6 +980,7 @@ public class IrisBiome result = prime * result + ((surface == null) ? 0 : surface.hashCode()); temp = Double.doubleToLongBits(surfaceScale); result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + ((type == null) ? 0 : type.hashCode()); return result; } @@ -736,7 +994,12 @@ public class IrisBiome if(getClass() != obj.getClass()) return false; IrisBiome other = (IrisBiome) obj; - if(Double.doubleToLongBits(amp) != Double.doubleToLongBits(other.amp)) + if(bng == null) + { + if(other.bng != null) + return false; + } + else if(!bng.equals(other.bng)) return false; if(Double.doubleToLongBits(cliffChance) != Double.doubleToLongBits(other.cliffChance)) return false; @@ -755,6 +1018,14 @@ public class IrisBiome return false; if(dirtDepth != other.dirtDepth) return false; + if(Double.doubleToLongBits(genAmplifier) != Double.doubleToLongBits(other.genAmplifier)) + return false; + if(Double.doubleToLongBits(genScale) != Double.doubleToLongBits(other.genScale)) + return false; + if(Double.doubleToLongBits(genSwirl) != Double.doubleToLongBits(other.genSwirl)) + return false; + if(Double.doubleToLongBits(genSwirlScale) != Double.doubleToLongBits(other.genSwirlScale)) + return false; if(Double.doubleToLongBits(height) != Double.doubleToLongBits(other.height)) return false; if(name == null) @@ -764,6 +1035,13 @@ public class IrisBiome } else if(!name.equals(other.name)) return false; + if(parent == null) + { + if(other.parent != null) + return false; + } + else if(!parent.equals(other.parent)) + return false; if(poly == null) { if(other.poly != null) @@ -844,6 +1122,8 @@ public class IrisBiome return false; if(Double.doubleToLongBits(surfaceScale) != Double.doubleToLongBits(other.surfaceScale)) return false; + if(type != other.type) + return false; return true; } } diff --git a/src/main/java/ninja/bytecode/iris/pack/IrisDimension.java b/src/main/java/ninja/bytecode/iris/pack/IrisDimension.java index 85576cef9..bdf5c636a 100644 --- a/src/main/java/ninja/bytecode/iris/pack/IrisDimension.java +++ b/src/main/java/ninja/bytecode/iris/pack/IrisDimension.java @@ -1,7 +1,6 @@ package ninja.bytecode.iris.pack; import java.io.IOException; -import java.util.concurrent.locks.ReentrantLock; import org.bukkit.World.Environment; @@ -9,8 +8,6 @@ import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.controller.PackController; import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.execution.J; -import ninja.bytecode.shuriken.execution.TaskExecutor; -import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup; import ninja.bytecode.shuriken.json.JSONArray; import ninja.bytecode.shuriken.json.JSONException; import ninja.bytecode.shuriken.json.JSONObject;