This commit is contained in:
Daniel Mills 2020-01-22 14:31:00 -05:00
parent c1971bffa8
commit 199a26afbc
8 changed files with 169 additions and 378 deletions

View File

@ -22,7 +22,6 @@ import ninja.bytecode.iris.generator.genobject.PlacedObject;
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.util.BiomeLayer; import ninja.bytecode.iris.util.BiomeLayer;
import ninja.bytecode.iris.util.ObjectMode;
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.execution.ChronoLatch; import ninja.bytecode.shuriken.execution.ChronoLatch;
@ -228,30 +227,6 @@ public class CommandIris implements CommandExecutor
} }
} }
if(args[0].equalsIgnoreCase("regen"))
{
if(sender instanceof Player)
{
ChronoLatch cl = new ChronoLatch(3000);
Player p = (Player) sender;
World ww = ((Player) sender).getWorld();
msg(p, "Regenerating View Distance");
WorldReactor r = new WorldReactor(ww);
r.generateRegionNormal(p, true, 200, (pct) ->
{
if(cl.flip())
{
msg(p, "Regenerating " + F.pc(pct));
}
}, () ->
{
msg(p, "Done! Use F3 + A");
});
}
}
if(args[0].equalsIgnoreCase("hotload")) if(args[0].equalsIgnoreCase("hotload"))
{ {
msg(sender, "=== Hotloading Pack ==="); msg(sender, "=== Hotloading Pack ===");
@ -300,6 +275,30 @@ public class CommandIris implements CommandExecutor
c.compile(); c.compile();
L.logConsumers.remove(m); L.logConsumers.remove(m);
J.s(() ->
{
if(sender instanceof Player)
{
ChronoLatch cl = new ChronoLatch(3000);
Player p = (Player) sender;
World ww = ((Player) sender).getWorld();
msg(p, "Regenerating View Distance");
WorldReactor r = new WorldReactor(ww);
r.generateRegionNormal(p, true, 200, (pct) ->
{
if(cl.flip())
{
msg(p, "Regenerating " + F.pc(pct));
}
}, () ->
{
msg(p, "Done! Use F3 + A");
});
}
}, 5);
for(String fi : f.k()) for(String fi : f.k())
{ {
J.s(() -> J.s(() ->

View File

@ -25,8 +25,8 @@ public class Settings
public static class GeneratorSettings public static class GeneratorSettings
{ {
public InterpolationMode interpolationMode = InterpolationMode.BILINEAR; public InterpolationMode interpolationMode = InterpolationMode.BICUBIC;
public int interpolationRadius = 3; public int interpolationRadius = 4;
public double objectDensity = 1D; public double objectDensity = 1D;
public double horizontalZoom = 2; public double horizontalZoom = 2;
public double heightFracture = 155; public double heightFracture = 155;
@ -42,7 +42,7 @@ public class Settings
public double heightScale = 0.56; public double heightScale = 0.56;
public double baseHeight = 0.065; public double baseHeight = 0.065;
public int seaLevel = 63; public int seaLevel = 63;
public double biomeScale = 0.525; public double biomeScale = 1;
public boolean flatBedrock = false; public boolean flatBedrock = false;
} }
} }

View File

@ -67,7 +67,6 @@ public class IrisGenerator extends ParallaxWorldGenerator
private CNG swirl; private CNG swirl;
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 GenObjectDecorator god; private GenObjectDecorator god;
private GenLayerLayeredNoise glLNoise; private GenLayerLayeredNoise glLNoise;
@ -143,24 +142,6 @@ public class IrisGenerator extends ParallaxWorldGenerator
return new ChunkPlan(); return new ChunkPlan();
} }
public IrisBiome getBiome(int wxx, int wzx)
{
PrecisionStopwatch c = getMetrics().start();
IrisBiome biome = glBiome.getBiome(wxx, wzx);
IrisBiome real = glBiome.getBiome(wxx, wzx, true);
boolean frozen = getRegion(biome) != null ? getRegion(biome).isFrozen() : false;
int height = computeHeight(wxx, wzx, new ChunkPlan(), biome);
IrisBiome nbiome = height < 63 ? getOcean(real, height) : biome;
biome = nbiome;
int beach = (int) Math.round(65 + this.beach.noise(wxx, wzx));
biome = height > 61 && height < 65 ? frozen ? biome : getBeach(real) : biome;
biome = height > 63 && biome.getType().equals(BiomeType.FLUID) ? getBeach(real) : biome;
biome = height >= beach && !biome.getType().equals(BiomeType.LAND) ? real : biome;
getMetrics().stop("biome:ms:x256:/terrain:..", c);
return biome;
}
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{ {
random = new Random(world.getSeed()); random = new Random(world.getSeed());
@ -193,32 +174,10 @@ public class IrisGenerator extends ParallaxWorldGenerator
return metrics; return metrics;
} }
public IrisBiome getOcean(IrisBiome biome, int height)
{
IrisRegion region = glBiome.getRegion(biome.getRegion());
if(region != null)
{
if(region.isFrozen())
{
return biome("Frozen Ocean");
}
}
if(height < 36)
{
return biome("Deep Ocean");
}
else
{
return biome("Ocean");
}
}
public IrisBiome getBeach(IrisBiome biome) public IrisBiome getBeach(IrisBiome biome)
{ {
IrisBiome beach = null; IrisBiome beach = null;
IrisRegion region = glBiome.getRegion(biome.getRegion()); IrisRegion region = glBiome.getRegion(biome.getRegionID());
if(region != null) if(region != null)
{ {
@ -283,7 +242,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
public IrisRegion getRegion(IrisBiome biome) public IrisRegion getRegion(IrisBiome biome)
{ {
return glBiome.getRegion(biome.getRegion()); return glBiome.getRegion(biome.getRegionID());
} }
@Override @Override
@ -341,27 +300,32 @@ public class IrisGenerator extends ParallaxWorldGenerator
int wzx = (int) wz; int wzx = (int) wz;
int highest = 0; int highest = 0;
int seaLevel = Iris.settings.gen.seaLevel; int seaLevel = Iris.settings.gen.seaLevel;
IrisBiome biome = getBiome(wxx, wzx); IrisBiome biome = glBiome.getBiome(wxx, wzx);
IrisRegion r = getRegion(biome); IrisBiome realBiome = glBiome.getBiome(wxx, wzx, true);
boolean frozen = r != null && r.isFrozen(); IrisRegion region = getRegion(realBiome);
MB FLUID = biome.getFluid();
int height = computeHeight(wxx, wzx, plan, biome); int height = computeHeight(wxx, wzx, plan, biome);
int max = Math.max(height, seaLevel); int max = Math.max(height, seaLevel);
boolean land = height >= seaLevel;
int beachHeight = land ? (int) Math.round(seaLevel + beach.noise(wx, wz)) : seaLevel;
boolean beach = height <= beachHeight + 2 && land;
biome = land && biome.getType().equals(BiomeType.FLUID) ? region.getBeach() : biome;
biome = !land && biome.getType().equals(BiomeType.LAND) ? region.getLake() : biome;
biome = beach && !land && biome.getType().equals(BiomeType.FLUID) ? region.getShore() : biome;
// biome = !beach && land && biome.getType().equals(BiomeType.FRONT) ? realBiome
// : biome;
for(int i = surfaceOnly ? max > seaLevel ? max - 2 : height - 2 : 0; i < max; i++) for(int i = surfaceOnly ? max > seaLevel ? max - 2 : height - 2 : 0; i < max; i++)
{ {
MB mb = ROCK.get(scatterInt(wzx, i, wxx, ROCK.size())); MB mb = ROCK.get(scatterInt(wzx, i, wxx, ROCK.size()));
boolean underwater = i >= height && i < seaLevel; boolean underwater = i >= height && i < seaLevel;
boolean someunderwater = i >= height && i < seaLevel - (1 + scatterInt(x, i, z, 1));
boolean wayunderwater = i >= height && i < seaLevel - (3 + scatterInt(x, i, z, 2));
boolean underground = i < height; boolean underground = i < height;
int dheight = biome.getDirtDepth(); int dheight = biome.getDirtDepth();
int rheight = biome.getRockDepth(); int rheight = biome.getRockDepth();
boolean dirt = (height - 1) - i < (dheight > 0 ? scatterInt(x, i, z, 4) : 0) + dheight; boolean dirt = (height - 1) - i < (dheight > 0 ? scatterInt(x, i, z, 4) : 0) + dheight;
boolean rocky = i > height - rheight && !dirt; boolean rocky = i > height - rheight && !dirt;
boolean bedrock = i == 0 || !Iris.settings.gen.flatBedrock ? i <= 2 : i < scatterInt(x, i, z, 3); boolean bedrock = i == 0 || !Iris.settings.gen.flatBedrock ? i <= 2 : i < scatterInt(x, i, z, 3);
mb = underwater ? frozen ? PACKED_ICE : WATER : mb; mb = underwater ? FLUID : mb;
mb = someunderwater ? frozen ? ICE : WATER : mb;
mb = wayunderwater ? WATER : mb;
mb = underground && dirt ? biome.getSubSurface(wxx, i, wzx, rTerrain) : mb; mb = underground && dirt ? biome.getSubSurface(wxx, i, wzx, rTerrain) : mb;
mb = underground && rocky ? biome.getRock(wxx, i, wzx, rTerrain) : mb; mb = underground && rocky ? biome.getRock(wxx, i, wzx, rTerrain) : mb;
mb = bedrock ? BEDROCK : mb; mb = bedrock ? BEDROCK : mb;
@ -438,7 +402,7 @@ public class IrisGenerator extends ParallaxWorldGenerator
{ {
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); h += biome.getGenerator().getHeight(x, z) / 2D;
plan.setHeight(x, z, h); plan.setHeight(x, z, h);
return h; return h;
} }

View File

@ -29,7 +29,6 @@ public class BiomeNoiseGenerator
} }
double r = block * 52; double r = block * 52;
double m = biome.getGenAmplifier() < 1D ? (r - (biome.getGenAmplifier() * r)) : 0; return (gen.noise(x, z) * biome.getGenAmplifier() * r);
return (gen.noise(x, z) * biome.getGenAmplifier() * r) + m;
} }
} }

View File

@ -5,16 +5,18 @@ import java.util.function.Function;
import org.bukkit.World; import org.bukkit.World;
import mortar.util.text.C;
import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.IrisGenerator; import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.pack.IrisBiome; import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.pack.IrisRegion; import ninja.bytecode.iris.pack.IrisRegion;
import ninja.bytecode.iris.util.BiomeLayer; import ninja.bytecode.iris.util.BiomeLayer;
import ninja.bytecode.iris.util.GenLayer; import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.PolygonGenerator;
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.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.RNG; import ninja.bytecode.shuriken.math.RNG;
public class GenLayerBiome extends GenLayer public class GenLayerBiome extends GenLayer
@ -23,17 +25,18 @@ public class GenLayerBiome extends GenLayer
private Function<CNG, CNG> factory; private Function<CNG, CNG> factory;
private CNG fracture; private CNG fracture;
private CNG fuzz; private CNG fuzz;
private CNG island; private PolygonGenerator channel;
private PolygonGenerator ocean;
private BiomeLayer master; private BiomeLayer master;
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);
//@builder //@builder
island = new CNG(rng.nextParallelRNG(10334), 1D, 1) channel = new PolygonGenerator(rng.nextParallelRNG(-12), 2, 0.0005, 1, (g)->g.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2)
.scale(0.003 * Iris.settings.gen.landScale) .scale(0.01), 30));
.fractureWith(new CNG(rng.nextParallelRNG(1211), 1D, 1) ocean = new PolygonGenerator(rng.nextParallelRNG(-11), 6, 0.005, 1, (g)->g.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2)
.scale(0.001 * Iris.settings.gen.landScale), 3600); .scale(0.01), 150));
fuzz = new CNG(rng.nextParallelRNG(9112), 1D * 8 * Iris.settings.gen.biomeEdgeFuzzScale, 1).scale(6.5); fuzz = new CNG(rng.nextParallelRNG(9112), 1D * 8 * Iris.settings.gen.biomeEdgeFuzzScale, 1).scale(6.5);
fracture = new CNG(rng.nextParallelRNG(28), 1D, 4).scale(0.0021 * Iris.settings.gen.biomeEdgeScrambleScale) fracture = new CNG(rng.nextParallelRNG(28), 1D, 4).scale(0.0021 * Iris.settings.gen.biomeEdgeScrambleScale)
.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2) .fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2)
@ -48,17 +51,17 @@ public class GenLayerBiome extends GenLayer
for(IrisBiome i : biomes) for(IrisBiome i : biomes)
{ {
if(i.getRegion().equals("default")) if(i.getRegionID().equals("default"))
{ {
continue; continue;
} }
if(!regions.containsKey(i.getRegion())) if(!regions.containsKey(i.getRegionID()))
{ {
regions.put(i.getRegion(), new IrisRegion(i.getRegion())); regions.put(i.getRegionID(), new IrisRegion(i.getRegionID()));
} }
regions.get(i.getRegion()).getBiomes().add(i); regions.get(i.getRegionID()).getBiomes().add(i);
} }
for(IrisRegion i : regions.values()) for(IrisRegion i : regions.values())
@ -81,53 +84,6 @@ public class GenLayerBiome extends GenLayer
} }
} }
public boolean hasBorder(int checks, double distance, double... dims)
{
IrisBiome current = getBiome(dims[0], dims[1]);
double ajump = 360D / (double) checks;
if(dims.length == 2)
{
for(int i = 0; i < checks; i++)
{
double dx = M.sin((float) Math.toRadians(ajump * i));
double dz = M.cos((float) Math.toRadians(ajump * i));
if(!current.equals(getBiome((dx * distance) + dims[0], (dz * distance) + dims[1])))
{
return true;
}
}
}
return false;
}
public boolean hasHeightBorder(int checks, double distance, double... dims)
{
IrisBiome current = getBiome(dims[0], dims[1]);
double ajump = 360D / (double) checks;
if(dims.length == 2)
{
for(int i = 0; i < checks; i++)
{
double dx = M.sin((float) Math.toRadians(ajump * i));
double dz = M.cos((float) Math.toRadians(ajump * i));
if(current.getHeight() != getBiome((dx * distance) + dims[0], (dz * distance) + dims[1]).getHeight())
{
return true;
}
}
}
return false;
}
public boolean isBorder(int wx, int wz, double range)
{
return hasHeightBorder(6, range, wx, wz);
}
public IrisBiome getBiome(double wxx, double wzx) public IrisBiome getBiome(double wxx, double wzx)
{ {
return getBiome(wxx, wzx, false); return getBiome(wxx, wzx, false);
@ -137,36 +93,56 @@ public class GenLayerBiome extends GenLayer
{ {
double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale; double wx = Math.round((double) wxx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;
double wz = Math.round((double) wzx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale; double wz = Math.round((double) wzx * (Iris.settings.gen.horizontalZoom / 1.90476190476)) * Iris.settings.gen.biomeScale;
double x = wx + ((fracture.noise(wx, wz) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange); double xf = wx + ((fracture.noise(wx, wz) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange);
double z = wz - ((fracture.noise(wz, wx) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange); double zf = wz - ((fracture.noise(wz, wx) / 2D) * 200D * Iris.settings.gen.biomeEdgeScrambleRange);
x -= fuzz.noise(wx, wz); double x = xf - fuzz.noise(wx, wz);
z += fuzz.noise(wz, wx); double z = zf + fuzz.noise(wz, wx);
IrisBiome biome = master.computeBiome(x, z);
if(real) if(real)
{ {
return master.computeBiome(x, z); return biome;
} }
IrisBiome cbi = iris.biome("Ocean"); if(ocean.getIndex(x, z) == 0)
double land = island.noise(x, z);
double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D);
if(land > landChance)
{ {
cbi = master.computeBiome(x, z); IrisRegion region = getRegion(biome.getRegionID());
if(region == null)
{
L.f(C.YELLOW + "Cannot find Region " + C.RED + biome.getRegionID());
return biome;
}
if(region.getOcean() == null)
{
L.f(C.YELLOW + "Cannot find Ocean in Region" + C.RED + biome.getRegionID());
return biome;
}
return getRegion(biome.getRegionID()).getOcean();
} }
else if(land < 0.1) if(channel.hasBorder(3, 44, xf, zf))
{ {
cbi = iris.biome("Deep Ocean"); IrisRegion region = getRegion(biome.getRegionID());
if(region == null)
{
L.f(C.YELLOW + "Cannot find Region " + C.RED + biome.getRegionID());
return biome;
}
if(region.getChannel() == null)
{
L.f(C.YELLOW + "Cannot find Channel in Region" + C.RED + biome.getRegionID());
return biome;
}
return getRegion(biome.getRegionID()).getChannel();
} }
else return biome;
{
cbi = iris.biome("Ocean");
}
return cbi;
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package ninja.bytecode.iris.pack; package ninja.bytecode.iris.pack;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Objects;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
@ -25,7 +26,7 @@ import ninja.bytecode.shuriken.math.RNG;
public class IrisBiome 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.138;
public static final double MIN_HEIGHT = -0.0218; public static final double MIN_HEIGHT = -0.0218;
private static final GMap<Biome, IrisBiome> map = build(); private static final GMap<Biome, IrisBiome> map = build();
private String name; private String name;
@ -33,6 +34,7 @@ public class IrisBiome
private Biome realBiome; private Biome realBiome;
private double height; private double height;
private GList<MB> rock; private GList<MB> rock;
private MB fluid;
private int rockDepth; private int rockDepth;
private GList<MB> surface; private GList<MB> surface;
private GList<MB> dirt; private GList<MB> dirt;
@ -118,6 +120,7 @@ public class IrisBiome
this.name = name; this.name = name;
type = BiomeType.LAND; type = BiomeType.LAND;
cliffs = false; cliffs = false;
fluid = MB.of(Material.STATIONARY_WATER);
genScale = 1; genScale = 1;
rarity = 1; rarity = 1;
genAmplifier = 0.35; genAmplifier = 0.35;
@ -236,14 +239,15 @@ public class IrisBiome
type = BiomeType.valueOf(o.getString("type").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(() -> parent = o.getString("parent"));
J.attempt(() -> height = o.getDouble("height")); J.attempt(() -> height(o.getDouble("height")));
J.attempt(() -> height = o.getDouble("genHeight")); J.attempt(() -> height(o.getDouble("genHeight")));
J.attempt(() -> genAmplifier = o.getDouble("genAmplifier")); J.attempt(() -> genAmplifier = o.getDouble("genAmplifier"));
J.attempt(() -> genSwirl = o.getDouble("genSwirl")); J.attempt(() -> genSwirl = o.getDouble("genSwirl"));
J.attempt(() -> genSwirlScale = o.getDouble("genSwirlScale")); J.attempt(() -> genSwirlScale = o.getDouble("genSwirlScale"));
J.attempt(() -> genScale = o.getDouble("genScale")); J.attempt(() -> genScale = o.getDouble("genScale"));
J.attempt(() -> snow = o.getDouble("snow")); J.attempt(() -> snow = o.getDouble("snow"));
J.attempt(() -> rarity = o.getDouble("rarity")); J.attempt(() -> rarity = o.getDouble("rarity"));
J.attempt(() -> fluid = MB.of(o.getString("fluid")));
J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth")); J.attempt(() -> dirtDepth = o.getInt("subSurfaceDepth"));
J.attempt(() -> dirtDepth = o.getInt("dirtDepth")); J.attempt(() -> dirtDepth = o.getInt("dirtDepth"));
J.attempt(() -> rockDepth = o.getInt("rockDepth")); J.attempt(() -> rockDepth = o.getInt("rockDepth"));
@ -298,6 +302,7 @@ public class IrisBiome
J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " "))); J.attempt(() -> j.put("derivative", realBiome.name().toLowerCase().replaceAll("_", " ")));
J.attempt(() -> j.put("type", type.name().toLowerCase().replaceAll("_", " "))); J.attempt(() -> j.put("type", type.name().toLowerCase().replaceAll("_", " ")));
J.attempt(() -> j.put("rarity", rarity)); J.attempt(() -> j.put("rarity", rarity));
J.attempt(() -> j.put("fluid", fluid.toString()));
J.attempt(() -> j.put("genHeight", height)); J.attempt(() -> j.put("genHeight", height));
J.attempt(() -> j.put("genScale", genScale)); J.attempt(() -> j.put("genScale", genScale));
J.attempt(() -> j.put("genSwirl", genSwirl)); J.attempt(() -> j.put("genSwirl", genSwirl));
@ -479,7 +484,7 @@ public class IrisBiome
else else
{ {
this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, M.clip(height, -1D, 0D)); this.height = M.lerp(MIN_HEIGHT, IDEAL_HEIGHT, 1d - Math.abs(M.clip(height, -1D, 0D)));
} }
return this; return this;
@ -635,7 +640,7 @@ public class IrisBiome
return false; return false;
} }
public String getRegion() public String getRegionID()
{ {
return region; return region;
} }
@ -1038,173 +1043,39 @@ public class IrisBiome
} }
} }
public MB getFluid()
{
return fluid;
}
public void setFluid(MB fluid)
{
this.fluid = fluid;
}
public void setRarity(double rarity)
{
this.rarity = rarity;
}
@Override @Override
public int hashCode() public int hashCode()
{ {
final int prime = 31; return Objects.hash(cliffChance, cliffScale, cliffs, core, dirt, dirtDepth, fluid, genAmplifier, genScale, genSwirl, genSwirlScale, height, name, parent, rarity, realBiome, region, rock, rockDepth, rockScale, scatterChance, scatterSurface, scatterSurfaceRock, scatterSurfaceSub, schematicGroups, simplexScatter, simplexScatterRock, simplexScatterSub, snow, subSurfaceScale, surface, surfaceScale, type);
int result = 1;
long temp;
temp = Double.doubleToLongBits(cliffChance);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(cliffScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + (cliffs ? 1231 : 1237);
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());
temp = Double.doubleToLongBits(rarity);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((realBiome == null) ? 0 : realBiome.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + ((rock == null) ? 0 : rock.hashCode());
result = prime * result + rockDepth;
temp = Double.doubleToLongBits(rockScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((scatterChance == null) ? 0 : scatterChance.hashCode());
result = prime * result + (scatterSurface ? 1231 : 1237);
result = prime * result + (scatterSurfaceRock ? 1231 : 1237);
result = prime * result + (scatterSurfaceSub ? 1231 : 1237);
result = prime * result + ((schematicGroups == null) ? 0 : schematicGroups.hashCode());
result = prime * result + (simplexScatter ? 1231 : 1237);
result = prime * result + (simplexScatterRock ? 1231 : 1237);
result = prime * result + (simplexScatterSub ? 1231 : 1237);
temp = Double.doubleToLongBits(snow);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(subSurfaceScale);
result = prime * result + (int) (temp ^ (temp >>> 32));
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;
} }
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if(this == obj) if(this == obj)
{
return true; return true;
if(obj == null) }
return false; if(!(obj instanceof IrisBiome))
if(getClass() != obj.getClass()) {
return false; return false;
}
IrisBiome other = (IrisBiome) obj; IrisBiome other = (IrisBiome) obj;
if(Double.doubleToLongBits(cliffChance) != Double.doubleToLongBits(other.cliffChance)) return Double.doubleToLongBits(cliffChance) == Double.doubleToLongBits(other.cliffChance) && Double.doubleToLongBits(cliffScale) == Double.doubleToLongBits(other.cliffScale) && cliffs == other.cliffs && core == other.core && Objects.equals(dirt, other.dirt) && dirtDepth == other.dirtDepth && Objects.equals(fluid, other.fluid) && Double.doubleToLongBits(genAmplifier) == Double.doubleToLongBits(other.genAmplifier) && Double.doubleToLongBits(genScale) == Double.doubleToLongBits(other.genScale) && Double.doubleToLongBits(genSwirl) == Double.doubleToLongBits(other.genSwirl) && Double.doubleToLongBits(genSwirlScale) == Double.doubleToLongBits(other.genSwirlScale) && Double.doubleToLongBits(height) == Double.doubleToLongBits(other.height) && Objects.equals(name, other.name) && Objects.equals(parent, other.parent) && Double.doubleToLongBits(rarity) == Double.doubleToLongBits(other.rarity) && realBiome == other.realBiome && Objects.equals(region, other.region) && Objects.equals(rock, other.rock) && rockDepth == other.rockDepth && Double.doubleToLongBits(rockScale) == Double.doubleToLongBits(other.rockScale) && Objects.equals(scatterChance, other.scatterChance) && scatterSurface == other.scatterSurface && scatterSurfaceRock == other.scatterSurfaceRock && scatterSurfaceSub == other.scatterSurfaceSub && Objects.equals(schematicGroups, other.schematicGroups) && simplexScatter == other.simplexScatter && simplexScatterRock == other.simplexScatterRock && simplexScatterSub == other.simplexScatterSub && Double.doubleToLongBits(snow) == Double.doubleToLongBits(other.snow) && Double.doubleToLongBits(subSurfaceScale) == Double.doubleToLongBits(other.subSurfaceScale) && Objects.equals(surface, other.surface) && Double.doubleToLongBits(surfaceScale) == Double.doubleToLongBits(other.surfaceScale) && type == other.type;
return false;
if(Double.doubleToLongBits(cliffScale) != Double.doubleToLongBits(other.cliffScale))
return false;
if(cliffs != other.cliffs)
return false;
if(core != other.core)
return false;
if(dirt == null)
{
if(other.dirt != null)
return false;
}
else if(!dirt.equals(other.dirt))
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)
{
if(other.name != null)
return false;
}
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(Double.doubleToLongBits(rarity) != Double.doubleToLongBits(other.rarity))
return false;
if(realBiome != other.realBiome)
return false;
if(region == null)
{
if(other.region != null)
return false;
}
else if(!region.equals(other.region))
return false;
if(rock == null)
{
if(other.rock != null)
return false;
}
else if(!rock.equals(other.rock))
return false;
if(rockDepth != other.rockDepth)
return false;
if(Double.doubleToLongBits(rockScale) != Double.doubleToLongBits(other.rockScale))
return false;
if(scatterChance == null)
{
if(other.scatterChance != null)
return false;
}
else if(!scatterChance.equals(other.scatterChance))
return false;
if(scatterSurface != other.scatterSurface)
return false;
if(scatterSurfaceRock != other.scatterSurfaceRock)
return false;
if(scatterSurfaceSub != other.scatterSurfaceSub)
return false;
if(schematicGroups == null)
{
if(other.schematicGroups != null)
return false;
}
else if(!schematicGroups.equals(other.schematicGroups))
return false;
if(simplexScatter != other.simplexScatter)
return false;
if(simplexScatterRock != other.simplexScatterRock)
return false;
if(simplexScatterSub != other.simplexScatterSub)
return false;
if(Double.doubleToLongBits(snow) != Double.doubleToLongBits(other.snow))
return false;
if(Double.doubleToLongBits(subSurfaceScale) != Double.doubleToLongBits(other.subSurfaceScale))
return false;
if(surface == null)
{
if(other.surface != null)
return false;
}
else if(!surface.equals(other.surface))
return false;
if(Double.doubleToLongBits(surfaceScale) != Double.doubleToLongBits(other.surfaceScale))
return false;
if(type != other.type)
return false;
return true;
} }
} }

View File

@ -1,5 +1,7 @@
package ninja.bytecode.iris.pack; package ninja.bytecode.iris.pack;
import java.util.Objects;
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.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
@ -10,17 +12,21 @@ public class IrisRegion
{ {
private String name; private String name;
private GList<IrisBiome> biomes; private GList<IrisBiome> biomes;
private double rarity; private IrisBiome ocean;
private boolean frozen; private IrisBiome lake;
private IrisBiome lakeBeach;
private IrisBiome channel;
private IrisBiome beach; private IrisBiome beach;
public IrisRegion(String name) public IrisRegion(String name)
{ {
frozen = false;
this.name = name; this.name = name;
this.biomes = new GList<>(); this.biomes = new GList<>();
rarity = 1;
beach = null; beach = null;
ocean = null;
lake = null;
lakeBeach = null;
channel = null;
} }
public void load() public void load()
@ -28,10 +34,12 @@ public class IrisRegion
J.attempt(() -> J.attempt(() ->
{ {
JSONObject o = Iris.getController(PackController.class).loadJSON("pack/regions/" + name + ".json"); JSONObject o = Iris.getController(PackController.class).loadJSON("pack/regions/" + name + ".json");
J.attempt(() -> frozen = o.getBoolean("frozen"));
J.attempt(() -> name = o.getString("name")); J.attempt(() -> name = o.getString("name"));
J.attempt(() -> rarity = o.getDouble("rarity")); J.attempt(() -> ocean = Iris.getController(PackController.class).getBiomeById(o.getString("ocean")));
J.attempt(() -> beach = Iris.getController(PackController.class).getBiomeById(o.getString("beach"))); J.attempt(() -> beach = Iris.getController(PackController.class).getBiomeById(o.getString("beach")));
J.attempt(() -> lake = Iris.getController(PackController.class).getBiomeById(o.getString("lake")));
J.attempt(() -> lakeBeach = Iris.getController(PackController.class).getBiomeById(o.getString("lakeBeach")));
J.attempt(() -> channel = Iris.getController(PackController.class).getBiomeById(o.getString("channel")));
}); });
} }
@ -55,16 +63,6 @@ public class IrisRegion
this.biomes = biomes; this.biomes = biomes;
} }
public double getRarity()
{
return rarity;
}
public void setRarity(double rarity)
{
this.rarity = rarity;
}
public IrisBiome getBeach() public IrisBiome getBeach()
{ {
return beach; return beach;
@ -75,59 +73,44 @@ public class IrisRegion
this.beach = beach; this.beach = beach;
} }
public IrisBiome getOcean()
{
return ocean;
}
public IrisBiome getLake()
{
return lake;
}
public IrisBiome getShore()
{
return lakeBeach;
}
public IrisBiome getChannel()
{
return channel;
}
@Override @Override
public int hashCode() public int hashCode()
{ {
final int prime = 31; return Objects.hash(beach, biomes, channel, lake, lakeBeach, name, ocean);
int result = 1;
result = prime * result + ((beach == null) ? 0 : beach.hashCode());
result = prime * result + ((biomes == null) ? 0 : biomes.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
long temp;
temp = Double.doubleToLongBits(rarity);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
} }
@Override @Override
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if(this == obj) if(this == obj)
{
return true; return true;
if(obj == null) }
return false; if(!(obj instanceof IrisRegion))
if(getClass() != obj.getClass()) {
return false; return false;
}
IrisRegion other = (IrisRegion) obj; IrisRegion other = (IrisRegion) obj;
if(beach == null) return Objects.equals(beach, other.beach) && Objects.equals(biomes, other.biomes) && Objects.equals(channel, other.channel) && Objects.equals(lake, other.lake) && Objects.equals(lakeBeach, other.lakeBeach) && Objects.equals(name, other.name) && Objects.equals(ocean, other.ocean);
{
if(other.beach != null)
return false;
}
else if(!beach.equals(other.beach))
return false;
if(biomes == null)
{
if(other.biomes != null)
return false;
}
else if(!biomes.equals(other.biomes))
return false;
if(name == null)
{
if(other.name != null)
return false;
}
else if(!name.equals(other.name))
return false;
if(Double.doubleToLongBits(rarity) != Double.doubleToLongBits(other.rarity))
return false;
return true;
}
public boolean isFrozen()
{
return frozen;
} }
} }

View File

@ -90,7 +90,6 @@ public class PolygonGenerator
int current = getIndex(dims); int current = getIndex(dims);
double ajump = 360D / (double) checks; double ajump = 360D / (double) checks;
int hit = -1; int hit = -1;
int hit2 = -1;
if(dims.length == 3) if(dims.length == 3)
{ {