Biome specific generators

This commit is contained in:
Daniel Mills 2020-01-17 09:19:41 -05:00
parent 165517608d
commit 451eca0aa9
12 changed files with 427 additions and 210 deletions

View File

@ -57,7 +57,7 @@ public class CommandIris implements CommandExecutor
{ {
IrisGenerator g = (IrisGenerator) w.getGenerator(); IrisGenerator g = (IrisGenerator) w.getGenerator();
IrisBiome b = null; 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", "_"))) 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 x = (int) ((int) (29999983 / 1.2) * Math.random());
int z = (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; f = true;
@ -90,11 +90,11 @@ public class CommandIris implements CommandExecutor
p.teleport(w.getHighestBlockAt(x, z).getLocation()); p.teleport(w.getHighestBlockAt(x, z).getLocation());
break; break;
} }
else else
{ {
t++; t++;
if(t > 30) if(t > 30)
{ {
msg(sender, "Checked 30 " + b.getName() + " bearing chunks. All of them were underwater. Try Again!"); msg(sender, "Checked 30 " + b.getName() + " bearing chunks. All of them were underwater. Try Again!");

View File

@ -18,23 +18,22 @@ public class Settings
public int cascadeLimit = 14; public int cascadeLimit = 14;
public boolean interpolation = true; public boolean interpolation = true;
public boolean surfaceNoise = true; public boolean surfaceNoise = true;
public boolean baseNoise = true;
} }
public static class GeneratorSettings public static class GeneratorSettings
{ {
public int hermiteSampleRadius = 6; public int hermiteSampleRadius = 4;
public double horizontalZoom = 2; public double horizontalZoom = 2;
public double heightFracture = 155; public double heightFracture = 155;
public double landScale = 0.5; public double landScale = 0.5;
public double landChance = 0.5; public double landChance = 0.6;
public double biomeEdgeScramble = 1550D; // 1550D public double biomeEdgeScramble = 0; // 1550D
public double roughness = 1.55; public double roughness = 1.55;
public double heightMultiplier = 0.806; public double heightMultiplier = 0.806;
public double heightExponentBase = 1; public double heightExponentBase = 1;
public double heightExponentMultiplier = 1.41; public double heightExponentMultiplier = 1.41;
public double heightScale = 0.56; public double heightScale = 0.56;
public double baseHeight = 0.165; public double baseHeight = 0.065;
public int seaLevel = 63; public int seaLevel = 63;
public double caveDensity = 4; public double caveDensity = 4;
public double caveScale = 1.45; public double caveScale = 1.45;

View File

@ -59,7 +59,7 @@ public class CommandIris implements CommandExecutor
{ {
IrisGenerator g = (IrisGenerator) w.getGenerator(); IrisGenerator g = (IrisGenerator) w.getGenerator();
IrisBiome b = null; 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", "_"))) if(args[1].toLowerCase().equals(i.getName().toLowerCase().replaceAll("\\Q \\E", "_")))
{ {

View File

@ -8,12 +8,10 @@ import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.BlockPopulator;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController; import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator; import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
import ninja.bytecode.iris.generator.genobject.GenObjectGroup; import ninja.bytecode.iris.generator.layer.BiomeNoiseGenerator;
import ninja.bytecode.iris.generator.layer.GenLayerBase;
import ninja.bytecode.iris.generator.layer.GenLayerBiome; import ninja.bytecode.iris.generator.layer.GenLayerBiome;
import ninja.bytecode.iris.generator.layer.GenLayerCarving; import ninja.bytecode.iris.generator.layer.GenLayerCarving;
import ninja.bytecode.iris.generator.layer.GenLayerCaverns; 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.GenLayerCliffs;
import ninja.bytecode.iris.generator.layer.GenLayerLayeredNoise; import ninja.bytecode.iris.generator.layer.GenLayerLayeredNoise;
import ninja.bytecode.iris.generator.layer.GenLayerSnow; import ninja.bytecode.iris.generator.layer.GenLayerSnow;
import ninja.bytecode.iris.pack.BiomeType;
import ninja.bytecode.iris.pack.CompiledDimension; import ninja.bytecode.iris.pack.CompiledDimension;
import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.pack.IrisRegion; 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.MB;
import ninja.bytecode.iris.util.ParallelChunkGenerator; import ninja.bytecode.iris.util.ParallelChunkGenerator;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.logging.L; import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.CNG; import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.M; import ninja.bytecode.shuriken.math.M;
@ -59,24 +57,21 @@ public class IrisGenerator extends ParallelChunkGenerator
private double[][][] scatterCache; private double[][][] scatterCache;
private CNG scatter; private CNG scatter;
public GMap<String, IrisBiome> biomeCache = new GMap<>();
private MB WATER = new MB(Material.STATIONARY_WATER);
private MB ICE = new MB(Material.ICE); private MB ICE = new MB(Material.ICE);
private MB PACKED_ICE = new MB(Material.PACKED_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 MB BEDROCK = new MB(Material.BEDROCK);
private GList<IrisBiome> internal;
private GenLayerLayeredNoise glLNoise; private GenLayerLayeredNoise glLNoise;
private GenLayerBiome glBiome; private GenLayerBiome glBiome;
private GenLayerCaves glCaves; private GenLayerCaves glCaves;
private GenLayerCarving glCarving; private GenLayerCarving glCarving;
private GenLayerCaverns glCaverns; private GenLayerCaverns glCaverns;
private GenLayerSnow glSnow; private GenLayerSnow glSnow;
private GenLayerBase glBase; private BiomeNoiseGenerator glBase;
private GenLayerCliffs glCliffs; private GenLayerCliffs glCliffs;
private RNG rTerrain; private RNG rTerrain;
private CompiledDimension dim; private CompiledDimension dim;
private World world; private World world;
private GMap<String, GenObjectGroup> schematicCache = new GMap<>();
public IrisGenerator() public IrisGenerator()
{ {
@ -87,26 +82,6 @@ public class IrisGenerator extends ParallelChunkGenerator
{ {
this.dim = dim; this.dim = dim;
L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes..."); 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) 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; return scatter(x, y, z) > chance;
} }
public GList<IrisBiome> getLoadedBiomes()
{
return internal;
}
@Override @Override
public void onInit(World world, Random random) public void onInit(World world, Random random)
{ {
this.world = world; this.world = world;
rTerrain = new RNG(world.getSeed()); rTerrain = new RNG(world.getSeed());
glBase = new GenLayerBase(this, world, random, rTerrain.nextParallelRNG(1));
glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2)); glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2));
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes()); glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
glCaves = new GenLayerCaves(this, world, random, rTerrain.nextParallelRNG(-1)); glCaves = new GenLayerCaves(this, world, random, rTerrain.nextParallelRNG(-1));
@ -162,9 +131,9 @@ public class IrisGenerator extends ParallelChunkGenerator
int m = 0; 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) public IrisBiome biome(String name)
{ {
return biomeCache.get(name); return getDimension().getBiomeByName(name);
} }
public double getOffsetX(double x) public double getOffsetX(double x)
@ -273,7 +242,7 @@ public class IrisGenerator extends ParallelChunkGenerator
IrisBiome nbiome = height < 63 ? getOcean(biome, height) : biome; IrisBiome nbiome = height < 63 ? getOcean(biome, height) : biome;
biome = nbiome; biome = nbiome;
biome = height > 61 && height < 65 ? frozen ? biome : getBeach(biome) : biome; 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++) for(int i = 0; i < max; i++)
{ {
@ -382,17 +351,7 @@ public class IrisGenerator extends ParallelChunkGenerator
{ {
IrisBiome biome = glBiome.getBiome(x, z); IrisBiome biome = glBiome.getBiome(x, z);
double h = Iris.settings.gen.baseHeight + biome.getHeight(); double h = Iris.settings.gen.baseHeight + biome.getHeight();
h += biome.getGenerator().getHeight(x, z);
if(Iris.settings.performance.baseNoise)
{
h += (glBase.getHeight(x, z) * 0.5) - (0.08);
}
else
{
h += 0.00001;
}
plan.setHeight(x, z, h); plan.setHeight(x, z, h);
return h; return h;
} }
@ -405,16 +364,6 @@ public class IrisGenerator extends ParallelChunkGenerator
return world; return world;
} }
public GMap<String, GenObjectGroup> getSchematicCache()
{
return schematicCache;
}
public void setSchematicCache(GMap<String, GenObjectGroup> schematicCache)
{
this.schematicCache = schematicCache;
}
public RNG getRTerrain() public RNG getRTerrain()
{ {
return rTerrain; return rTerrain;

View File

@ -35,7 +35,7 @@ public class GenObjectDecorator extends BlockPopulator
this.g = generator; this.g = generator;
populationCache = new GMap<>(); populationCache = new GMap<>();
for(IrisBiome i : generator.getLoadedBiomes()) for(IrisBiome i : generator.getDimension().getBiomes())
{ {
GMap<GenObjectGroup, Double> gc = new GMap<>(); GMap<GenObjectGroup, Double> gc = new GMap<>();

View File

@ -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;
}
}

View File

@ -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))));
}
}

View File

@ -28,9 +28,16 @@ public class GenLayerBiome extends GenLayer
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng, GList<IrisBiome> biomes) public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng, GList<IrisBiome> biomes)
{ {
super(iris, world, random, rng); 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); //@builder
fracture = new CNG(rng.nextParallelRNG(28), 1D, 24).scale(0.0021).fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 12).scale(0.01), 12250); island = new CNG(rng.nextParallelRNG(10334), 1D, 1)
factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 4).scale(0.02), 56); .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<>(); regions = new GMap<>();
for(IrisBiome i : biomes) for(IrisBiome i : biomes)
@ -61,18 +68,6 @@ public class GenLayerBiome extends GenLayer
v += 13 - i.getName().length(); v += 13 - i.getName().length();
i.setGen(new EnumPolygonGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000255 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory)); i.setGen(new EnumPolygonGenerator<IrisBiome>(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) 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); cbi = getRegionGenerator(x, z).getChoice(x, z);
} }
else if(land < 0.4) else if(land < 0.1)
{ {
cbi = iris.biome("Deep Ocean"); cbi = iris.biome("Deep Ocean");
} }

View File

@ -0,0 +1,8 @@
package ninja.bytecode.iris.pack;
public enum BiomeType
{
LAND,
FLUID,
FRONT;
}

View File

@ -12,23 +12,29 @@ import java.util.zip.GZIPOutputStream;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import net.md_5.bungee.api.ChatColor;
import ninja.bytecode.iris.generator.genobject.GenObjectGroup; import ninja.bytecode.iris.generator.genobject.GenObjectGroup;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap; import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.io.CustomOutputStream; import ninja.bytecode.shuriken.io.CustomOutputStream;
import ninja.bytecode.shuriken.json.JSONObject; import ninja.bytecode.shuriken.json.JSONObject;
import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.RNG;
import ninja.bytecode.shuriken.reaction.O; import ninja.bytecode.shuriken.reaction.O;
public class CompiledDimension public class CompiledDimension
{ {
public static IrisBiome theVoid = new IrisBiome("Void", Biome.VOID).height(0).seal(RNG.r);
private IrisDimension dimension; private IrisDimension dimension;
private GList<IrisBiome> biomes; private GList<IrisBiome> biomes;
private GMap<String, IrisBiome> biomeCache;
private GMap<String, GenObjectGroup> objects; private GMap<String, GenObjectGroup> objects;
public CompiledDimension(IrisDimension dimension) public CompiledDimension(IrisDimension dimension)
{ {
this.dimension = dimension; this.dimension = dimension;
biomes = new GList<>(); biomes = new GList<>();
biomeCache = new GMap<>();
objects = new GMap<>(); objects = new GMap<>();
} }
@ -101,6 +107,7 @@ public class CompiledDimension
public void registerBiome(IrisBiome j) public void registerBiome(IrisBiome j)
{ {
biomes.add(j); biomes.add(j);
biomeCache.put(j.getName(), j);
} }
public void registerObject(GenObjectGroup g) public void registerObject(GenObjectGroup g)
@ -149,4 +156,17 @@ public class CompiledDimension
{ {
biomes.sort(); 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;
}
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.block.Biome;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController; import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.generator.layer.BiomeNoiseGenerator;
import ninja.bytecode.iris.util.MB; import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.PolygonGenerator; import ninja.bytecode.iris.util.PolygonGenerator;
import ninja.bytecode.shuriken.collections.GList; 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 MAX_HEIGHT = 0.77768;
public static final double IDEAL_HEIGHT = 0.0527; public static final double IDEAL_HEIGHT = 0.0527;
public static final double MIN_HEIGHT = -0.0218; 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<Biome, IrisBiome> map = build(); private static final GMap<Biome, IrisBiome> map = build();
private String name; private String name;
private String parent;
private Biome realBiome; private Biome realBiome;
private double height; private double height;
private double amp;
private GList<MB> rock; private GList<MB> rock;
private int rockDepth; private int rockDepth;
private GList<MB> surface; private GList<MB> surface;
@ -67,7 +49,13 @@ public class IrisBiome
private double snow; private double snow;
private double cliffChance; private double cliffChance;
private double cliffScale; private double cliffScale;
private double genScale;
private double genAmplifier;
private double genSwirl;
private double genSwirlScale;
private boolean cliffs; private boolean cliffs;
private BiomeNoiseGenerator bng;
private BiomeType type;
private String region; private String region;
private GMap<String, Double> schematicGroups; private GMap<String, Double> schematicGroups;
private PolygonGenerator.EnumPolygonGenerator<MB> poly; private PolygonGenerator.EnumPolygonGenerator<MB> poly;
@ -89,16 +77,6 @@ public class IrisBiome
return MIN_HEIGHT; return MIN_HEIGHT;
} }
public static IrisBiome getOcean()
{
return OCEAN;
}
public static IrisBiome getDeepOcean()
{
return DEEP_OCEAN;
}
public static GMap<Biome, IrisBiome> getMap() public static GMap<Biome, IrisBiome> getMap()
{ {
return map; return map;
@ -135,13 +113,18 @@ public class IrisBiome
this.region = "default"; this.region = "default";
this.core = false; this.core = false;
this.name = name; this.name = name;
type = BiomeType.LAND;
cliffs = false; cliffs = false;
genScale = 1;
genAmplifier = 0.35;
genSwirl = 1;
genSwirlScale = 1;
cliffScale = 1; cliffScale = 1;
cliffChance = 0.37; cliffChance = 0.37;
parent = "";
dirtDepth = 2; dirtDepth = 2;
this.realBiome = realBiome; this.realBiome = realBiome;
this.height = IDEAL_HEIGHT; this.height = IDEAL_HEIGHT;
this.amp = 0.31;
rockDepth = 11; rockDepth = 11;
surfaceScale = 1; surfaceScale = 1;
subSurfaceScale = 1; subSurfaceScale = 1;
@ -177,7 +160,7 @@ public class IrisBiome
fromJSON(o, true); fromJSON(o, true);
} }
public void seal(RNG rng) public IrisBiome seal(RNG rng)
{ {
if(simplexScatter) 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); 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) public void fromJSON(JSONObject o, boolean chain)
{ {
name = o.getString("name"); name = o.getString("name");
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_")); realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
type = BiomeType.valueOf(o.getString("type").toUpperCase().replaceAll(" ", "_"));
J.attempt(() -> region = o.getString("region")); J.attempt(() -> region = o.getString("region"));
J.attempt(() -> parent = o.getString("parent"));
J.attempt(() -> height = o.getDouble("height")); 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(() -> snow = o.getDouble("snow"));
J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth")); J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth"));
J.attempt(() -> dirtDepth = o.getInt("dirtDepth")); J.attempt(() -> dirtDepth = o.getInt("dirtDepth"));
@ -284,9 +288,15 @@ public class IrisBiome
{ {
JSONObject j = new JSONObject(); JSONObject j = new JSONObject();
j.put("name", name); j.put("name", name);
J.attempt(() -> j.put("parent", parent));
J.attempt(() -> j.put("region", region)); J.attempt(() -> j.put("region", region));
J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " "))); 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("snow", snow));
J.attempt(() -> j.put("cliffs", cliffs)); J.attempt(() -> j.put("cliffs", cliffs));
J.attempt(() -> j.put("cliffScale", cliffScale)); J.attempt(() -> j.put("cliffScale", cliffScale));
@ -469,12 +479,6 @@ public class IrisBiome
return this; return this;
} }
public IrisBiome amp(double amp)
{
this.amp = amp;
return this;
}
public String getName() public String getName()
{ {
return name; return name;
@ -490,11 +494,6 @@ public class IrisBiome
return height; return height;
} }
public double getAmp()
{
return amp;
}
public GList<MB> getSurface() public GList<MB> getSurface()
{ {
return surface; return surface;
@ -598,11 +597,6 @@ public class IrisBiome
} }
public static GList<IrisBiome> getBiomes() public static GList<IrisBiome> getBiomes()
{
return map.v().remove(IrisBiome.OCEAN, IrisBiome.DEEP_OCEAN);
}
public static GList<IrisBiome> getAllBiomes()
{ {
return map.v(); return map.v();
} }
@ -614,7 +608,7 @@ public class IrisBiome
return map.get(biome); return map.get(biome);
} }
return IrisBiome.OCEAN; return null;
} }
public GMap<String, Double> getSchematicGroups() public GMap<String, Double> getSchematicGroups()
@ -680,14 +674,268 @@ public class IrisBiome
return cliffChance; 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<MB> getPolySub()
{
return polySub;
}
public PolygonGenerator.EnumPolygonGenerator<MB> 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<MB> rock)
{
this.rock = rock;
}
public void setRockDepth(int rockDepth)
{
this.rockDepth = rockDepth;
}
public void setSurface(GList<MB> surface)
{
this.surface = surface;
}
public void setDirt(GList<MB> dirt)
{
this.dirt = dirt;
}
public void setScatterChance(GMap<MB, Double> 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<String, Double> schematicGroups)
{
this.schematicGroups = schematicGroups;
}
public void setPoly(PolygonGenerator.EnumPolygonGenerator<MB> poly)
{
this.poly = poly;
}
public void setPolySub(PolygonGenerator.EnumPolygonGenerator<MB> polySub)
{
this.polySub = polySub;
}
public void setPolyRock(PolygonGenerator.EnumPolygonGenerator<MB> 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 @Override
public int hashCode() public int hashCode()
{ {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + ((bng == null) ? 0 : bng.hashCode());
long temp; long temp;
temp = Double.doubleToLongBits(amp);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(cliffChance); temp = Double.doubleToLongBits(cliffChance);
result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(cliffScale); temp = Double.doubleToLongBits(cliffScale);
@ -696,9 +944,18 @@ public class IrisBiome
result = prime * result + (core ? 1231 : 1237); result = prime * result + (core ? 1231 : 1237);
result = prime * result + ((dirt == null) ? 0 : dirt.hashCode()); result = prime * result + ((dirt == null) ? 0 : dirt.hashCode());
result = prime * result + dirtDepth; 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); temp = Double.doubleToLongBits(height);
result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((name == null) ? 0 : name.hashCode()); 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 + ((poly == null) ? 0 : poly.hashCode());
result = prime * result + ((polyRock == null) ? 0 : polyRock.hashCode()); result = prime * result + ((polyRock == null) ? 0 : polyRock.hashCode());
result = prime * result + ((polySub == null) ? 0 : polySub.hashCode()); result = prime * result + ((polySub == null) ? 0 : polySub.hashCode());
@ -723,6 +980,7 @@ public class IrisBiome
result = prime * result + ((surface == null) ? 0 : surface.hashCode()); result = prime * result + ((surface == null) ? 0 : surface.hashCode());
temp = Double.doubleToLongBits(surfaceScale); temp = Double.doubleToLongBits(surfaceScale);
result = prime * result + (int) (temp ^ (temp >>> 32)); result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result; return result;
} }
@ -736,7 +994,12 @@ public class IrisBiome
if(getClass() != obj.getClass()) if(getClass() != obj.getClass())
return false; return false;
IrisBiome other = (IrisBiome) obj; 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; return false;
if(Double.doubleToLongBits(cliffChance) != Double.doubleToLongBits(other.cliffChance)) if(Double.doubleToLongBits(cliffChance) != Double.doubleToLongBits(other.cliffChance))
return false; return false;
@ -755,6 +1018,14 @@ public class IrisBiome
return false; return false;
if(dirtDepth != other.dirtDepth) if(dirtDepth != other.dirtDepth)
return false; 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)) if(Double.doubleToLongBits(height) != Double.doubleToLongBits(other.height))
return false; return false;
if(name == null) if(name == null)
@ -764,6 +1035,13 @@ public class IrisBiome
} }
else if(!name.equals(other.name)) else if(!name.equals(other.name))
return false; return false;
if(parent == null)
{
if(other.parent != null)
return false;
}
else if(!parent.equals(other.parent))
return false;
if(poly == null) if(poly == null)
{ {
if(other.poly != null) if(other.poly != null)
@ -844,6 +1122,8 @@ public class IrisBiome
return false; return false;
if(Double.doubleToLongBits(surfaceScale) != Double.doubleToLongBits(other.surfaceScale)) if(Double.doubleToLongBits(surfaceScale) != Double.doubleToLongBits(other.surfaceScale))
return false; return false;
if(type != other.type)
return false;
return true; return true;
} }
} }

View File

@ -1,7 +1,6 @@
package ninja.bytecode.iris.pack; package ninja.bytecode.iris.pack;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
@ -9,8 +8,6 @@ import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController; import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.execution.J; 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.JSONArray;
import ninja.bytecode.shuriken.json.JSONException; import ninja.bytecode.shuriken.json.JSONException;
import ninja.bytecode.shuriken.json.JSONObject; import ninja.bytecode.shuriken.json.JSONObject;