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.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)
@ -58,13 +85,13 @@ public class GenLayerBiome extends GenLayer
{
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)
{

View File

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

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)
{
if(choices.length == 1)
{
return choices[0];
}
return choices[super.getIndex(dim)];
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
{
"name": "Mesa",
"derivative": "Mesa",
"height": 0.125,
"region": "HotDry",
"surface": [
"HARD_CLAY",
"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",
"height": 0.35,
"region": "Cold",
"derivative": "EXTREME_HILLS",
"scatter":[
"LONG_GRASS:2=0.04"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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