mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-26 02:29:14 +00:00
Biome Regions (group biomes such as hot, cold) so less random gen
This commit is contained in:
@@ -9,17 +9,19 @@ import org.bukkit.World;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.pack.IrisRegion;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
private EnumMaxingGenerator<IrisBiome> biomeGenerator;
|
||||
private EnumMaxingGenerator<IrisRegion> regionGenerator;
|
||||
private MaxingGenerator roads;
|
||||
private Function<CNG, CNG> factory;
|
||||
private CNG pathCheck;
|
||||
@@ -37,8 +39,33 @@ public class GenLayerBiome extends GenLayer
|
||||
riverCheck = new CNG(rng.nextParallelRNG(30), 1D, 2).scale(0.00096);
|
||||
pathCheck = new CNG(rng.nextParallelRNG(31), 1D, 1).scale(0.00096);
|
||||
roads = new MaxingGenerator(rng.nextParallelRNG(32), 5, 0.00055, 8, factory);
|
||||
biomeGenerator = new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33), 0.00755 * Iris.settings.gen.biomeScale, 1, biomes.toArray(new IrisBiome[biomes.size()]), factory);
|
||||
//@done
|
||||
|
||||
GMap<String, IrisRegion> regions = new GMap<>();
|
||||
|
||||
for(IrisBiome i : biomes)
|
||||
{
|
||||
if(!regions.containsKey(i.getRegion()))
|
||||
{
|
||||
regions.put(i.getRegion(), new IrisRegion(i.getRegion()));
|
||||
}
|
||||
|
||||
regions.get(i.getRegion()).getBiomes().add(i);
|
||||
}
|
||||
|
||||
int v = 85034;
|
||||
regionGenerator = new EnumMaxingGenerator<IrisRegion>(rng.nextParallelRNG(v), 0.00522 * Iris.settings.gen.biomeScale * 0.189, 1, regions.v().toArray(new IrisRegion[regions.v().size()]), factory);
|
||||
|
||||
for(IrisRegion i : regions.v())
|
||||
{
|
||||
v += 13 - i.getName().length();
|
||||
i.setGen(new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000755 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory));
|
||||
}
|
||||
}
|
||||
|
||||
public EnumMaxingGenerator<IrisBiome> getRegionGenerator(double xx, double zz)
|
||||
{
|
||||
return regionGenerator.getChoice(xx, zz).getGen();
|
||||
}
|
||||
|
||||
public IrisBiome getBiome(double xx, double zz)
|
||||
@@ -48,23 +75,23 @@ public class GenLayerBiome extends GenLayer
|
||||
IrisBiome cbi = iris.biome("Ocean");
|
||||
double land = island.noise(x, z);
|
||||
double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D);
|
||||
|
||||
|
||||
if(land > landChance && land < landChance + 0.0175)
|
||||
{
|
||||
cbi = iris.biome("Beach");
|
||||
}
|
||||
|
||||
|
||||
else if(land > landChance + 0.0175)
|
||||
{
|
||||
if(riverCheck.noise(x, z) > 0.75)
|
||||
{
|
||||
if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
|
||||
if(getRegionGenerator(x, z).hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
|
||||
{
|
||||
return iris.biome("River");
|
||||
}
|
||||
}
|
||||
|
||||
cbi = biomeGenerator.getChoice(x, z);
|
||||
cbi = getRegionGenerator(x, z).getChoice(x, z);
|
||||
|
||||
if(pathCheck.noise(x, z) > 0.33)
|
||||
{
|
||||
@@ -81,12 +108,12 @@ public class GenLayerBiome extends GenLayer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else if(land < 0.3)
|
||||
{
|
||||
cbi = iris.biome("Deep Ocean");
|
||||
}
|
||||
|
||||
|
||||
return cbi;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ public class IrisBiome
|
||||
private boolean scatterSurface;
|
||||
private boolean core;
|
||||
private boolean simplexScatter;
|
||||
private String region;
|
||||
private GMap<String, Double> schematicGroups;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> poly;
|
||||
|
||||
@@ -144,6 +145,7 @@ public class IrisBiome
|
||||
|
||||
public IrisBiome(String name, Biome realBiome)
|
||||
{
|
||||
this.region = "Default";
|
||||
this.core = false;
|
||||
this.name = name;
|
||||
this.realBiome = realBiome;
|
||||
@@ -158,6 +160,7 @@ public class IrisBiome
|
||||
{
|
||||
name = o.getString("name");
|
||||
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
|
||||
J.attempt(() -> region = o.getString("region"));
|
||||
J.attempt(() -> height = o.getDouble("height"));
|
||||
J.attempt(() -> surface = mbListFromJSON(o.getJSONArray("surface")));
|
||||
J.attempt(() -> dirt = mbListFromJSON(o.getJSONArray("dirt")));
|
||||
@@ -179,6 +182,7 @@ public class IrisBiome
|
||||
{
|
||||
JSONObject j = new JSONObject();
|
||||
j.put("name", name);
|
||||
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("surface", mbListToJSON(surface)));
|
||||
@@ -474,4 +478,9 @@ public class IrisBiome
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getRegion()
|
||||
{
|
||||
return region;
|
||||
}
|
||||
}
|
||||
|
||||
84
src/main/java/ninja/bytecode/iris/pack/IrisRegion.java
Normal file
84
src/main/java/ninja/bytecode/iris/pack/IrisRegion.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package ninja.bytecode.iris.pack;
|
||||
|
||||
import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
|
||||
public class IrisRegion
|
||||
{
|
||||
private String name;
|
||||
private GList<IrisBiome> biomes;
|
||||
private EnumMaxingGenerator<IrisBiome> gen;
|
||||
|
||||
public IrisRegion(String name)
|
||||
{
|
||||
this.name = name;
|
||||
this.biomes = new GList<>();
|
||||
}
|
||||
|
||||
public EnumMaxingGenerator<IrisBiome> getGen()
|
||||
{
|
||||
return gen;
|
||||
}
|
||||
|
||||
public void setGen(EnumMaxingGenerator<IrisBiome> gen)
|
||||
{
|
||||
this.gen = gen;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public GList<IrisBiome> getBiomes()
|
||||
{
|
||||
return biomes;
|
||||
}
|
||||
|
||||
public void setBiomes(GList<IrisBiome> biomes)
|
||||
{
|
||||
this.biomes = biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((biomes == null) ? 0 : biomes.hashCode());
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
IrisRegion other = (IrisRegion) obj;
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -111,6 +111,11 @@ public class MaxingGenerator
|
||||
|
||||
public T getChoice(double... dim)
|
||||
{
|
||||
if(choices.length == 1)
|
||||
{
|
||||
return choices[0];
|
||||
}
|
||||
|
||||
return choices[super.getIndex(dim)];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user