Biome Regions (group biomes such as hot, cold) so less random gen

This commit is contained in:
Daniel Mills 2020-01-11 04:30:38 -05:00
parent acaf95c017
commit 58632b8da3
35 changed files with 203 additions and 10 deletions

View File

@ -9,17 +9,19 @@ import org.bukkit.World;
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.util.GenLayer; import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MaxingGenerator; import ninja.bytecode.iris.util.MaxingGenerator;
import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator; import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator;
import ninja.bytecode.shuriken.collections.GList; import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.math.CNG; import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.M; 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
{ {
private EnumMaxingGenerator<IrisBiome> biomeGenerator; private EnumMaxingGenerator<IrisRegion> regionGenerator;
private MaxingGenerator roads; private MaxingGenerator roads;
private Function<CNG, CNG> factory; private Function<CNG, CNG> factory;
private CNG pathCheck; private CNG pathCheck;
@ -37,8 +39,33 @@ public class GenLayerBiome extends GenLayer
riverCheck = new CNG(rng.nextParallelRNG(30), 1D, 2).scale(0.00096); riverCheck = new CNG(rng.nextParallelRNG(30), 1D, 2).scale(0.00096);
pathCheck = new CNG(rng.nextParallelRNG(31), 1D, 1).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); 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 //@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) public IrisBiome getBiome(double xx, double zz)
@ -48,23 +75,23 @@ public class GenLayerBiome extends GenLayer
IrisBiome cbi = iris.biome("Ocean"); IrisBiome cbi = iris.biome("Ocean");
double land = island.noise(x, z); double land = island.noise(x, z);
double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D); double landChance = 1D - M.clip(Iris.settings.gen.landChance, 0D, 1D);
if(land > landChance && land < landChance + 0.0175) if(land > landChance && land < landChance + 0.0175)
{ {
cbi = iris.biome("Beach"); cbi = iris.biome("Beach");
} }
else if(land > landChance + 0.0175) else if(land > landChance + 0.0175)
{ {
if(riverCheck.noise(x, z) > 0.75) 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"); return iris.biome("River");
} }
} }
cbi = biomeGenerator.getChoice(x, z); cbi = getRegionGenerator(x, z).getChoice(x, z);
if(pathCheck.noise(x, z) > 0.33) if(pathCheck.noise(x, z) > 0.33)
{ {
@ -81,12 +108,12 @@ public class GenLayerBiome extends GenLayer
} }
} }
} }
else if(land < 0.3) else if(land < 0.3)
{ {
cbi = iris.biome("Deep Ocean"); cbi = iris.biome("Deep Ocean");
} }
return cbi; return cbi;
} }

View File

@ -63,6 +63,7 @@ public class IrisBiome
private boolean scatterSurface; private boolean scatterSurface;
private boolean core; private boolean core;
private boolean simplexScatter; private boolean simplexScatter;
private String region;
private GMap<String, Double> schematicGroups; private GMap<String, Double> schematicGroups;
private PolygonGenerator.EnumPolygonGenerator<MB> poly; private PolygonGenerator.EnumPolygonGenerator<MB> poly;
@ -144,6 +145,7 @@ public class IrisBiome
public IrisBiome(String name, Biome realBiome) public IrisBiome(String name, Biome realBiome)
{ {
this.region = "Default";
this.core = false; this.core = false;
this.name = name; this.name = name;
this.realBiome = realBiome; this.realBiome = realBiome;
@ -158,6 +160,7 @@ public class IrisBiome
{ {
name = o.getString("name"); name = o.getString("name");
realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_")); realBiome = Biome.valueOf(o.getString("derivative").toUpperCase().replaceAll(" ", "_"));
J.attempt(() -> region = o.getString("region"));
J.attempt(() -> height = o.getDouble("height")); J.attempt(() -> height = o.getDouble("height"));
J.attempt(() -> surface = mbListFromJSON(o.getJSONArray("surface"))); J.attempt(() -> surface = mbListFromJSON(o.getJSONArray("surface")));
J.attempt(() -> dirt = mbListFromJSON(o.getJSONArray("dirt"))); J.attempt(() -> dirt = mbListFromJSON(o.getJSONArray("dirt")));
@ -179,6 +182,7 @@ public class IrisBiome
{ {
JSONObject j = new JSONObject(); JSONObject j = new JSONObject();
j.put("name", name); j.put("name", name);
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("height", height));
J.attempt(() -> j.put("surface", mbListToJSON(surface))); J.attempt(() -> j.put("surface", mbListToJSON(surface)));
@ -474,4 +478,9 @@ public class IrisBiome
return false; return false;
} }
public String getRegion()
{
return region;
}
} }

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

View File

@ -111,6 +111,11 @@ public class MaxingGenerator
public T getChoice(double... dim) public T getChoice(double... dim)
{ {
if(choices.length == 1)
{
return choices[0];
}
return choices[super.getIndex(dim)]; return choices[super.getIndex(dim)];
} }
} }

View File

@ -13,7 +13,7 @@
"GRAVEL" "GRAVEL"
], ],
"objects": [ "objects": [
"tree/palm/medium=0.35", "tree/palm/medium=0.45",
"tree/palm/small=1.95" "tree/palm/small=4.95"
] ]
} }

View File

@ -1,6 +1,7 @@
{ {
"name": "Desert", "name": "Desert",
"derivative": "DESERT", "derivative": "DESERT",
"region": "HotDry",
"surface": [ "surface": [
"SAND" "SAND"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Desert Hills", "name": "Desert Hills",
"derivative": "DESERT_HILLS", "derivative": "DESERT_HILLS",
"region": "HotDry",
"surface": [ "surface": [
"SAND" "SAND"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Desert Red", "name": "Desert Red",
"derivative": "MUTATED_DESERT", "derivative": "MUTATED_DESERT",
"region": "HotDry",
"surface": [ "surface": [
"SAND:1" "SAND:1"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Forest", "name": "Forest",
"derivative": "FOREST", "derivative": "FOREST",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -1,6 +1,7 @@
{ {
"name": "Birch Forest", "name": "Birch Forest",
"derivative": "BIRCH_FOREST", "derivative": "BIRCH_FOREST",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -1,6 +1,7 @@
{ {
"name": "Birch Forest Hills", "name": "Birch Forest Hills",
"derivative": "BIRCH_FOREST_HILLS", "derivative": "BIRCH_FOREST_HILLS",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -1,6 +1,7 @@
{ {
"name": "Dark Forest", "name": "Dark Forest",
"derivative": "ROOFED_FOREST", "derivative": "ROOFED_FOREST",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -1,6 +1,7 @@
{ {
"name": "Haunted Forest", "name": "Haunted Forest",
"derivative": "MUTATED_SWAMPLAND", "derivative": "MUTATED_SWAMPLAND",
"region": "Temperate",
"surface": [ "surface": [
"GRASS", "GRASS",
"GRASS", "GRASS",

View File

@ -1,6 +1,7 @@
{ {
"name": "Forest Hills", "name": "Forest Hills",
"derivative": "FOREST_HILLS", "derivative": "FOREST_HILLS",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.23", "LONG_GRASS:1=0.23",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -1,6 +1,7 @@
{ {
"name": "Forest Mountains", "name": "Forest Mountains",
"derivative": "MUTATED_EXTREME_HILLS_WITH_TREES", "derivative": "MUTATED_EXTREME_HILLS_WITH_TREES",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.13", "LONG_GRASS:1=0.13",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -2,6 +2,7 @@
"name": "Ice Mountains", "name": "Ice Mountains",
"derivative": "ICE_MOUNTAINS", "derivative": "ICE_MOUNTAINS",
"height": 0.412, "height": 0.412,
"region": "Cold",
"objects": [ "objects": [
"tree/spruce/medium=0.07", "tree/spruce/medium=0.07",
"tree/spruce/small=0.25", "tree/spruce/small=0.25",

View File

@ -1,4 +1,5 @@
{ {
"name": "Ice Plains", "name": "Ice Plains",
"region": "Cold",
"derivative": "ICE_FLATS" "derivative": "ICE_FLATS"
} }

View File

@ -1,6 +1,7 @@
{ {
"name": "Jungle", "name": "Jungle",
"derivative": "JUNGLE", "derivative": "JUNGLE",
"region": "Humid",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.58", "LONG_GRASS:1=0.58",
"LONG_GRASS:2=0.13" "LONG_GRASS:2=0.13"

View File

@ -1,6 +1,7 @@
{ {
"name": "Jungle Hills", "name": "Jungle Hills",
"derivative": "JUNGLE_HILLS", "derivative": "JUNGLE_HILLS",
"region": "Humid",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.33", "LONG_GRASS:1=0.33",
"LONG_GRASS:2=0.02" "LONG_GRASS:2=0.02"

View File

@ -1,6 +1,8 @@
{ {
"name": "Mesa", "name": "Mesa",
"derivative": "Mesa", "derivative": "Mesa",
"height": 0.125,
"region": "HotDry",
"surface": [ "surface": [
"HARD_CLAY", "HARD_CLAY",
"STAINED_CLAY:1", "STAINED_CLAY:1",

View File

@ -0,0 +1,20 @@
{
"name": "Mesa Blue",
"derivative": "Mesa",
"height": 0.125,
"region": "HotDry",
"surface": [
"STAINED_CLAY:9",
"STAINED_CLAY:3",
"STAINED_CLAY:11",
"STAINED_CLAY:10",
"STAINED_CLAY:2",
"STAINED_CLAY:6"
],
"dirt": [
"CLAY",
"SAND:1",
"SAND"
],
"surfaceType": "simplex"
}

View File

@ -0,0 +1,18 @@
{
"name": "Mesa Mountains",
"derivative": "Mesa",
"height": 0.325,
"region": "HotDry",
"surface": [
"HARD_CLAY",
"STAINED_CLAY:1",
"STAINED_CLAY:8",
"STAINED_CLAY:12"
],
"dirt": [
"CLAY",
"SAND:1",
"SAND"
],
"surfaceType": "simplex"
}

View File

@ -1,6 +1,7 @@
{ {
"name": "Mountains", "name": "Mountains",
"height": 0.35, "height": 0.35,
"region": "Cold",
"derivative": "EXTREME_HILLS", "derivative": "EXTREME_HILLS",
"scatter":[ "scatter":[
"LONG_GRASS:2=0.04" "LONG_GRASS:2=0.04"

View File

@ -1,6 +1,7 @@
{ {
"name": "Mushroom Island", "name": "Mushroom Island",
"derivative": "MUSHROOM_ISLAND", "derivative": "MUSHROOM_ISLAND",
"region": "Cold",
"surface": [ "surface": [
"MYCEL" "MYCEL"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Plains", "name": "Plains",
"derivative": "PLAINS", "derivative": "PLAINS",
"region": "Temperate",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.37", "LONG_GRASS:1=0.37",
"LONG_GRASS:2=0.09" "LONG_GRASS:2=0.09"

View File

@ -1,6 +1,7 @@
{ {
"name": "Redwood Forest", "name": "Redwood Forest",
"derivative": "REDWOOD_TAIGA", "derivative": "REDWOOD_TAIGA",
"region": "Cold",
"surface": [ "surface": [
"DIRT", "DIRT",
"DIRT:1", "DIRT:1",

View File

@ -1,6 +1,7 @@
{ {
"name": "Redwood Forest", "name": "Redwood Forest",
"derivative": "REDWOOD_TAIGA", "derivative": "REDWOOD_TAIGA",
"region": "Cold",
"surface": [ "surface": [
"DIRT", "DIRT",
"DIRT:1", "DIRT:1",

View File

@ -1,5 +1,6 @@
{ {
"name": "Sakura", "name": "Sakura",
"region": "Temperate",
"derivative": "MUTATED_PLAINS", "derivative": "MUTATED_PLAINS",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.37", "LONG_GRASS:1=0.37",

View File

@ -1,6 +1,7 @@
{ {
"name": "Savanna", "name": "Savanna",
"derivative": "SAVANNA", "derivative": "SAVANNA",
"region": "HotDry",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.18" "LONG_GRASS:1=0.18"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Savanna Hills", "name": "Savanna Hills",
"derivative": "SAVANNA_ROCK", "derivative": "SAVANNA_ROCK",
"region": "HotDry",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.18" "LONG_GRASS:1=0.18"
] ]

View File

@ -1,6 +1,7 @@
{ {
"name": "Swamp", "name": "Swamp",
"derivative": "SWAMPLAND", "derivative": "SWAMPLAND",
"region": "Humid",
"scatter":[ "scatter":[
"LONG_GRASS:1=0.04", "LONG_GRASS:1=0.04",
"LONG_GRASS:2=0.03" "LONG_GRASS:2=0.03"

View File

@ -1,6 +1,7 @@
{ {
"name": "Taiga", "name": "Taiga",
"derivative": "TAIGA", "derivative": "TAIGA",
"region": "Cold",
"scatter":[ "scatter":[
"LONG_GRASS:2=0.07" "LONG_GRASS:2=0.07"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Cold Taiga", "name": "Cold Taiga",
"derivative": "TAIGA_COLD", "derivative": "TAIGA_COLD",
"region": "Cold",
"scatter":[ "scatter":[
"LONG_GRASS:2=0.04" "LONG_GRASS:2=0.04"
], ],

View File

@ -1,6 +1,7 @@
{ {
"name": "Cold Taiga", "name": "Cold Taiga",
"derivative": "TAIGA_COLD", "derivative": "TAIGA_COLD",
"region": "Cold",
"scatter":[ "scatter":[
"LONG_GRASS:2=0.04" "LONG_GRASS:2=0.04"
], ],

View File

@ -6,6 +6,8 @@
"desert_red", "desert_red",
"desert_hills", "desert_hills",
"mesa", "mesa",
"mesa_mountains",
"mesa_blue",
"savanna", "savanna",
"savanna_hills", "savanna_hills",
"jungle", "jungle",