Biome Systems

This commit is contained in:
Daniel Mills
2020-01-07 07:47:42 -05:00
parent 152b1bd24e
commit 7e9cea94f3
166 changed files with 1128 additions and 681 deletions

View File

@@ -5,15 +5,12 @@ import java.io.IOException;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.generator.layer.GenLayerBase;
import ninja.bytecode.iris.generator.layer.GenLayerBiome;
import ninja.bytecode.iris.generator.layer.GenLayerCaves;
@@ -28,6 +25,8 @@ import ninja.bytecode.iris.generator.layer.GenLayerRidge;
import ninja.bytecode.iris.generator.populator.BiomeBiasSchematicPopulator;
import ninja.bytecode.iris.schematic.Schematic;
import ninja.bytecode.iris.schematic.SchematicGroup;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.spec.IrisDimension;
import ninja.bytecode.iris.util.AtomicChunkData;
import ninja.bytecode.iris.util.ChunkPlan;
import ninja.bytecode.iris.util.IrisInterpolation;
@@ -75,9 +74,21 @@ public class IrisGenerator extends ParallelChunkGenerator
private GenLayerOreEmerald glOreEmerald;
private GenLayerOreDiamond glOreDiamond;
private RNG rTerrain;
private IrisDimension dim;
private World world;
private GMap<String, SchematicGroup> schematicCache = new GMap<>();
public IrisGenerator()
{
this(Iris.dimensions.get("overworld"));
}
public IrisGenerator(IrisDimension dim)
{
this.dim = dim;
L.i("Preparing Dimension: " + dim.getName() + " With " + dim.getBiomes().size() + " Biomes...");
}
@Override
public void onInit(World world, Random random)
{
@@ -86,7 +97,7 @@ public class IrisGenerator extends ParallelChunkGenerator
glBase = new GenLayerBase(this, world, random, rTerrain.nextParallelRNG(1));
glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2));
glRidge = new GenLayerRidge(this, world, random, rTerrain.nextParallelRNG(3));
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4));
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
glCaves = new GenLayerCaves(this, world, random, rTerrain.nextParallelRNG(-1));
glOreIron = new GenLayerOreIron(this, world, random, rTerrain.nextParallelRNG(-500), 10);
glOreLapis = new GenLayerOreLapis(this, world, random, rTerrain.nextParallelRNG(-501), 15);
@@ -102,20 +113,55 @@ public class IrisGenerator extends ParallelChunkGenerator
return new ChunkPlan();
}
public IrisBiome getBiome(int wxx, int wzx)
{
double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
return glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
}
@Override
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
{
int seaLevel = Iris.settings.gen.seaLevel;
double wx = Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
double wz = Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
IrisBiome biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
IrisBiome biome = getBiome(wxx, wzx);
double hv = IrisInterpolation.getBicubicNoise(wxx, wzx, (xf, zf) -> getBiomedHeight((int) Math.round(xf), (int) Math.round(zf), plan));
hv += glLNoise.generateLayer(hv, wxx, wzx);
hv += glLNoise.generateLayer(hv * Iris.settings.gen.roughness * 215, wxx * Iris.settings.gen.roughness * 0.82, wzx * Iris.settings.gen.roughness * 0.82) * (1.6918 * (hv * 2.35));
hv -= glRidge.generateLayer(hv, wxx, wzx);
int height = (int) Math.round(M.clip(hv, 0D, 1D) * 253);
int max = Math.max(height, seaLevel);
IrisBiome override = null;
if(height > 61 && height < 65)
{
override = IrisBiome.BEACH;
}
else if(height < 63)
{
if(height < 36)
{
override = IrisBiome.DEEP_OCEAN;
}
else if(height < 50)
{
override = IrisBiome.OCEAN;
}
else
{
override = IrisBiome.LAKE;
}
}
if(override != null)
{
biome = override;
}
for(int i = 0; i < max; i++)
{
MB mb = ROCK.get(glBase.scatterInt(wzx, i, wxx, ROCK.size()));
@@ -134,34 +180,6 @@ public class IrisGenerator extends ParallelChunkGenerator
if(i == height - 1)
{
if(height > 61 && height < glBase.scatterInt(x, i, z, 4) + 65)
{
override = IrisBiome.BEACH;
}
else if(height < 63)
{
if(i < 36)
{
override = IrisBiome.DEEP_OCEAN;
}
else if(i < 50)
{
override = IrisBiome.OCEAN;
}
else
{
override = IrisBiome.LAKE;
}
}
if(override != null)
{
biome = override;
}
mb = biome.getSurface(wx, wz, rTerrain);
MB mbx = biome.getScatterChanceSingle();
@@ -192,11 +210,6 @@ public class IrisGenerator extends ParallelChunkGenerator
glOreEmerald.genOre(wxx, wzx, x, z, height, this, biome);
glOreDiamond.genOre(wxx, wzx, x, z, height, this, biome);
if(override != null)
{
return override.getRealBiome();
}
return biome.getRealBiome();
}
@@ -221,7 +234,7 @@ public class IrisGenerator extends ParallelChunkGenerator
{
int b = 0;
int sch = 0;
for(IrisBiome i : IrisBiome.getAllBiomes())
for(IrisBiome i : IrisBiome.getAllBiomes().copy().add(dim.getBiomes()))
{
b++;
L.i("Processing Populators for Biome " + i.getName());
@@ -233,7 +246,7 @@ public class IrisGenerator extends ParallelChunkGenerator
p.add(new BiomeBiasSchematicPopulator(i.getSchematicGroups().get(j), i, gs.getSchematics().toArray(new Schematic[gs.size()])));
}
}
L.i("Initialized " + b + " Biomes with " + p.size() + " Populators using " + sch + " Schematics");
}
@@ -306,7 +319,7 @@ public class IrisGenerator extends ParallelChunkGenerator
J.attempt(() -> g.setPriority(Integer.valueOf(i.split("\\Q=\\E")[1]).intValue()));
}
}
schematicCache.put(folder, g);
return g;
}
@@ -319,7 +332,7 @@ public class IrisGenerator extends ParallelChunkGenerator
int wz = (int) Math.round((double) z * Iris.settings.gen.horizontalZoom);
IrisBiome biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
double h = Iris.settings.gen.baseHeight + biome.getHeight();
h += (glBase.getHeight(wx, wz) * biome.getAmp()) - (0.33 * biome.getAmp());
h += (glBase.getHeight(wx, wz) * 0.5) - (0.33 * 0.5);
return h;
});

View File

@@ -1,566 +0,0 @@
package ninja.bytecode.iris.generator.biome;
import java.lang.reflect.Field;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.iris.util.PolygonGenerator;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.M;
import ninja.bytecode.shuriken.math.RNG;
public class IrisBiome
{
//@builder
public static final IrisBiome RIVER = new IrisBiome("River", Biome.RIVER)
.surface(MB.of(Material.SAND));
public static final IrisBiome BEACH = new IrisBiome("Beach", Biome.BEACHES)
.surface(MB.of(Material.SAND))
.schematic("boulder/sandy", 0.009)
.height(0.12)
.schematic("tree/palm", 0.83);
public static final IrisBiome ROAD_GRAVEL = new IrisBiome("Gravel Road", Biome.PLAINS)
.surface(MB.of(Material.GRAVEL), MB.of(Material.COBBLESTONE))
.schematic("boulder/smooth", 0.001)
.scatter(MB.of(Material.TORCH), 0.05);
public static final IrisBiome ROAD_GRASSY = new IrisBiome("Grass Path", Biome.PLAINS)
.surface(MB.of(Material.GRASS_PATH))
.scatter(MB.of(Material.TORCH), 0.05);
public static final IrisBiome OCEAN = new IrisBiome("Ocean", Biome.OCEAN)
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
.simplexSurface()
.height(-0.03);
public static final IrisBiome LAKE = new IrisBiome("Lake", Biome.OCEAN)
.surface(MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.SAND), MB.of(Material.GRAVEL), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
.simplexSurface()
.height(-0.03);
public static final IrisBiome DEEP_OCEAN = new IrisBiome("Deep Ocean", Biome.DEEP_OCEAN)
.surface(MB.of(Material.SAND), MB.of(Material.CLAY), MB.of(Material.GRAVEL))
.simplexSurface()
.height(-0.07);
public static final IrisBiome DESERT = new IrisBiome("Desert", Biome.DESERT)
.surface(MB.of(Material.SAND))
.schematic("boulder/sandy", 0.023)
.schematic("tree/deadwood", 0.03)
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
.dirt(MB.of(Material.SANDSTONE));
public static final IrisBiome DESERT_RED = new IrisBiome("Red Desert", Biome.DESERT)
.surface(MB.of(Material.SAND, 1))
.schematic("tree/deadwood", 0.045)
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
.dirt(MB.of(Material.RED_SANDSTONE));
public static final IrisBiome DESERT_COMBINED = new IrisBiome("Combined Desert", Biome.DESERT)
.surface(MB.of(Material.SAND), MB.of(Material.SAND, 1))
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
.schematic("tree/deadwood", 0.0443)
.dirt(MB.of(Material.SANDSTONE), MB.of(Material.RED_SANDSTONE))
.simplexSurface();
public static final IrisBiome DESERT_HILLS = new IrisBiome("Desert Hills", Biome.DESERT_HILLS)
.surface(MB.of(Material.SAND))
.amp(0.75)
.height(0.137)
.schematic("tree/deadwood", 0.03)
.schematic("boulder/sandy", 0.015)
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
.dirt(MB.of(Material.SANDSTONE));
public static final IrisBiome MESA = new IrisBiome("Mesa", Biome.MESA)
.surface(MB.of(Material.HARD_CLAY), MB.of(Material.STAINED_CLAY, 1), MB.of(Material.STAINED_CLAY, 8), MB.of(Material.STAINED_CLAY, 12))
.dirt(MB.of(Material.CLAY), MB.of(Material.SAND), MB.of(Material.SAND, 1))
.schematic("boulder/sandy", 0.02)
.simplexSurface();
public static final IrisBiome SAVANNA = new IrisBiome("Savanna", Biome.SAVANNA)
.schematic("tree/deadwood", 0.03)
.schematic("boulder/sandy", 0.02)
.schematic("boulder", 0.02)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18);
public static final IrisBiome SAVANNA_HILLS = new IrisBiome("Savanna Hills", Biome.SAVANNA_ROCK)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18)
.schematic("tree/deadwood", 0.01)
.schematic("boulder", 0.02)
.schematic("boulder/sandy", 0.02)
.height(0.13)
.amp(0.75);
public static final IrisBiome JUNGLE = new IrisBiome("Jungle", Biome.JUNGLE)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.058)
.schematic("boulder/smooth", 0.02)
.schematic("tree/oak/massive", 0.045)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.013);
public static final IrisBiome JUNGLE_HILLS = new IrisBiome("Jungle Hills", Biome.JUNGLE_HILLS)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.081)
.schematic("boulder/smooth", 0.02)
.schematic("tree/oak/massive", 0.045)
.amp(1.75)
.height(0.13)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.02);
public static final IrisBiome SWAMP = new IrisBiome("Swamp", Biome.SWAMPLAND)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
.schematic("tree/willow", 2.5)
.schematic("tree/god/willow", 0.01)
.schematic("boulder", 0.02)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
public static final IrisBiome PLAINS = new IrisBiome("Plains", Biome.PLAINS)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.38)
.schematic("tree/oak/bush", 0.25)
.schematic("boulder", 0.02)
.amp(0.4)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
public static final IrisBiome DECAYING_PLAINS = new IrisBiome("Decaying Plains", Biome.PLAINS)
.surface(MB.of(Material.GRASS_PATH), MB.of(Material.GRASS))
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
.schematic("tree/deadwood", 0.03)
.schematic("boulder/sandy", 0.01)
.simplexSurface();
public static final IrisBiome FOREST = new IrisBiome("Forest", Biome.FOREST)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
.schematic("tree/oak", 2.31)
.schematic("boulder", 0.02)
.schematic("boulder/smooth", 0.01)
.schematic("tree/oak/cracked", 0.03)
.schematic("tree/oak/large", 1.41)
.schematic("tree/oak/massive", 0.045)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
public static final IrisBiome FOREST_HILLS = new IrisBiome("Forest Hills", Biome.FOREST_HILLS)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
.schematic("tree/oak", 2.31)
.schematic("boulder", 0.02)
.schematic("boulder/smooth", 0.01)
.schematic("tree/oak/cracked", 0.03)
.schematic("tree/oak/massive", 0.045)
.schematic("tree/oak/large", 0.31)
.amp(0.75)
.height(0.13)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
public static final IrisBiome FOREST_MOUNTAINS = new IrisBiome("Forest Mountains", Biome.MUTATED_EXTREME_HILLS_WITH_TREES)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
.amp(2.25)
.schematic("tree/pine", 2.31)
.schematic("boulder", 0.04)
.schematic("boulder/smooth", 0.01)
.schematic("tree/redwood", 1.11)
.schematic("tree/redwood/tall", 2.51)
.height(0.365)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
public static final IrisBiome HAUNTED_FOREST = new IrisBiome("Haunted Forest", Biome.MUTATED_SWAMPLAND)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13)
.schematic("tree/willow", 1.21)
.schematic("tree/god/willow", 0.04)
.schematic("tree/oak", 0.71)
.schematic("boulder", 0.01)
.schematic("boulder/smooth", 0.02)
.schematic("tree/oak/cracked", 0.03)
.schematic("tree/oak/massive", 0.4)
.schematic("tree/oak/bush", 1.83)
.schematic("structure/magical", 0.002)
.addEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, 100, 0))
.addEffect(new PotionEffect(PotionEffectType.SLOW, 100, 0))
.addEffect(new PotionEffect(PotionEffectType.HUNGER, 100, 0))
.surface(MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.SOUL_SAND), MB.of(Material.DIRT), MB.of(Material.DIRT, 1), MB.of(Material.DIRT, 2))
.scatterSurface();
public static final IrisBiome BIRCH_FOREST = new IrisBiome("Birch Forest", Biome.BIRCH_FOREST)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
.schematic("tree/birch", 2.51)
.schematic("boulder", 0.02)
.schematic("boulder/smooth", 0.01)
.schematic("tree/birch/small", 3.25)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
public static final IrisBiome BIRCH_FOREST_HILLS = new IrisBiome("Birch Forest Hills", Biome.BIRCH_FOREST_HILLS)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
.schematic("tree/birch", 2.51)
.schematic("boulder/smooth", 0.01)
.schematic("boulder", 0.02)
.schematic("tree/birch/small", 3.25)
.amp(0.75)
.height(0.13)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
public static final IrisBiome ROOFED_FOREST = new IrisBiome("Roofed Forest", Biome.ROOFED_FOREST)
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
.schematic("boulder", 0.02)
.schematic("tree/oak/massive", 0.02)
.schematic("tree/oak/roofed", 0.78)
.schematic("boulder/smooth", 0.01)
.schematic("structure/magical", 0.009)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
public static final IrisBiome TAIGA = new IrisBiome("Taiga", Biome.TAIGA)
.schematic("tree/pine/cracked", 0.03)
.schematic("tree/pine", 2.51)
.schematic("boulder", 0.02)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.07);
public static final IrisBiome EXTREME_HILLS = new IrisBiome("Extreme Hills", Biome.EXTREME_HILLS)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04)
.amp(1.565)
.schematic("boulder/smooth", 0.01)
.height(0.342);
public static final IrisBiome EXTREME_HILLS_TREES = new IrisBiome("Extreme Hills +", Biome.EXTREME_HILLS_WITH_TREES)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.09)
.schematic("boulder", 0.02)
.schematic("tree/pine", 1.02)
.schematic("boulder/smooth", 0.01)
.schematic("tree/redwood/tall", 3.02)
.amp(1.525)
.height(0.352);
public static final IrisBiome TAIGA_COLD = new IrisBiome("Taiga Cold", Biome.TAIGA_COLD)
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04)
.schematic("tree/pine", 2.51)
.schematic("boulder/snowy", 0.02)
.schematic("tree/pine/cracked", 0.03);
public static final IrisBiome TAIGA_COLD_HILLS = new IrisBiome("Taiga Cold Hills", Biome.TAIGA_COLD_HILLS)
.schematic("tree/pine", 2.51)
.schematic("boulder/snowy", 0.02)
.schematic("tree/pine/cracked", 0.03);
public static final IrisBiome ICE_FLATS = new IrisBiome("Ice Flats", Biome.ICE_FLATS)
.schematic("boulder/snowy", 0.03);
public static final IrisBiome ICE_MOUNTAINS = new IrisBiome("Ice Mountains", Biome.ICE_MOUNTAINS)
.schematic("boulder/snowy", 0.03)
.amp(1.45);
public static final IrisBiome REDWOOD_TAIGA = new IrisBiome("Redwood Taiga", Biome.REDWOOD_TAIGA)
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
.schematic("tree/redwood/large", 0.87)
.schematic("tree/redwood/massive", 0.2)
.schematic("tree/pine/cracked", 0.03)
.schematic("boulder", 0.02)
.schematic("tree/redwood", 3.5)
.simplexSurface();
public static final IrisBiome REDWOOD_TAIGA_HILLS = new IrisBiome("Redwood Taiga Hills", Biome.REDWOOD_TAIGA_HILLS)
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
.schematic("tree/redwood/large", 0.87)
.schematic("tree/pine/cracked", 0.03)
.schematic("boulder", 0.02)
.schematic("tree/redwood", 3.5)
.amp(0.75)
.height(0.167)
.simplexSurface();
//@done
private static final GMap<Biome, IrisBiome> map = build();
private String name;
private Biome realBiome;
private double height;
private double amp;
private GList<PotionEffect> effects;
private GList<MB> surface;
private GList<MB> dirt;
private GMap<MB, Double> scatterChance;
private boolean scatterSurface;
private boolean simplexScatter;
private GMap<String, Double> schematicGroups;
private PolygonGenerator.EnumPolygonGenerator<MB> poly;
public IrisBiome(String name, Biome realBiome)
{
this.name = name;
effects = new GList<>();
this.realBiome = realBiome;
this.height = 0.125;
this.amp = 0.5;
scatterChance = new GMap<>();
schematicGroups = new GMap<>();
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
}
private static GMap<Biome, IrisBiome> build()
{
GMap<Biome, IrisBiome> g = new GMap<Biome, IrisBiome>();
for(Field i : IrisBiome.class.getDeclaredFields())
{
J.attempt(() ->
{
i.setAccessible(true);
IrisBiome bb = (IrisBiome) i.get(null);
if(!g.containsKey(bb.realBiome))
{
g.put(bb.realBiome, bb);
}
});
}
return g;
}
public IrisBiome scatter(MB mb, Double chance)
{
scatterChance.put(mb, chance);
return this;
}
public IrisBiome schematic(String t, double chance)
{
schematicGroups.put(t, chance);
return this;
}
public IrisBiome simplexSurface()
{
simplexScatter = true;
return this;
}
public IrisBiome scatterSurface()
{
scatterSurface = true;
return this;
}
public IrisBiome surface(MB... mbs)
{
surface = new GList<>(mbs);
return this;
}
public IrisBiome dirt(MB... mbs)
{
dirt = new GList<>(mbs);
return this;
}
public IrisBiome height(double height)
{
this.height = height;
return this;
}
public IrisBiome amp(double amp)
{
this.amp = amp;
return this;
}
public String getName()
{
return name;
}
public Biome getRealBiome()
{
return realBiome;
}
public double getHeight()
{
return height;
}
public double getAmp()
{
return amp;
}
public GList<MB> getSurface()
{
return surface;
}
public GList<MB> getDirt()
{
return dirt;
}
public MB getSurface(double x, double z, RNG rng)
{
double wx = x + 1000D;
double wz = z + 1000D;
if(simplexScatter)
{
if(poly == null)
{
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 0.25, 2, getSurface().toArray(new MB[getSurface().size()]), (g) ->
{
return g.fractureWith(new CNG(rng.nextParallelRNG(56), 1D, 2).scale(0.0155), 242);
});
}
return poly.getChoice(wx * 0.2D, wz * 0.2D);
}
if(scatterSurface)
{
if(poly == null)
{
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 15.05, 2, getSurface().toArray(new MB[getSurface().size()]), (g) ->
{
return g.fractureWith(new CNG(rng.nextParallelRNG(55), 1D, 2).scale(0.0155), 224);
});
}
return poly.getChoice(wx * 0.2D, wz * 0.2D);
}
return getSurface().getRandom();
}
public MB getDirtRNG()
{
return getDirt().getRandom();
}
public GMap<MB, Double> getScatterChance()
{
return scatterChance;
}
public IrisBiome addEffect(PotionEffect effect)
{
effects.add(effect);
return this;
}
public MB getScatterChanceSingle()
{
for(MB i : getScatterChance().keySet())
{
if(M.r(getScatterChance().get(i)))
{
return i;
}
}
return MB.of(Material.AIR);
}
public static GList<IrisBiome> getBiomes()
{
return map.v().remove(IrisBiome.ROAD_GRASSY, IrisBiome.ROAD_GRAVEL, IrisBiome.BEACH, IrisBiome.LAKE, IrisBiome.RIVER);
}
public static GList<IrisBiome> getAllBiomes()
{
return map.v();
}
public static IrisBiome findByBiome(Biome biome)
{
if(map.containsKey(biome))
{
return map.get(biome);
}
return IrisBiome.PLAINS;
}
public GMap<String, Double> getSchematicGroups()
{
return schematicGroups;
}
public void applyEffects(Player j)
{
if(j.getLocation().getY() < 63)
{
return;
}
for(PotionEffect i : effects)
{
j.getPlayer().removePotionEffect(i.getType());
j.addPotionEffect(i);
}
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(amp);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((dirt == null) ? 0 : dirt.hashCode());
result = prime * result + ((effects == null) ? 0 : effects.hashCode());
temp = Double.doubleToLongBits(height);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((poly == null) ? 0 : poly.hashCode());
result = prime * result + ((realBiome == null) ? 0 : realBiome.hashCode());
result = prime * result + ((scatterChance == null) ? 0 : scatterChance.hashCode());
result = prime * result + (scatterSurface ? 1231 : 1237);
result = prime * result + ((schematicGroups == null) ? 0 : schematicGroups.hashCode());
result = prime * result + (simplexScatter ? 1231 : 1237);
result = prime * result + ((surface == null) ? 0 : surface.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;
IrisBiome other = (IrisBiome) obj;
if(Double.doubleToLongBits(amp) != Double.doubleToLongBits(other.amp))
return false;
if(dirt == null)
{
if(other.dirt != null)
return false;
}
else if(!dirt.equals(other.dirt))
return false;
if(effects == null)
{
if(other.effects != null)
return false;
}
else if(!effects.equals(other.effects))
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(poly == null)
{
if(other.poly != null)
return false;
}
else if(!poly.equals(other.poly))
return false;
if(realBiome != other.realBiome)
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(schematicGroups == null)
{
if(other.schematicGroups != null)
return false;
}
else if(!schematicGroups.equals(other.schematicGroups))
return false;
if(simplexScatter != other.simplexScatter)
return false;
if(surface == null)
{
if(other.surface != null)
return false;
}
else if(!surface.equals(other.surface))
return false;
return true;
}
}

View File

@@ -8,11 +8,13 @@ import org.bukkit.World;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
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.math.CNG;
import ninja.bytecode.shuriken.math.M;
import ninja.bytecode.shuriken.math.RNG;
public class GenLayerBiome extends GenLayer
@@ -23,17 +25,19 @@ public class GenLayerBiome extends GenLayer
private CNG pathCheck;
private CNG riverCheck;
private CNG fracture;
private CNG island;
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng)
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng, GList<IrisBiome> biomes)
{
//@builder
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);
fracture = new CNG(rng.nextParallelRNG(28), 1D, 24).scale(0.0021).fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 12).scale(0.01), 12250);
factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 4).scale(0.02), 56);
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, IrisBiome.getBiomes().toArray(new IrisBiome[IrisBiome.getBiomes().size()]), factory);
biomeGenerator = new EnumMaxingGenerator<IrisBiome>(rng.nextParallelRNG(33), 0.00755 * Iris.settings.gen.biomeScale, 1, biomes.toArray(new IrisBiome[biomes.size()]), factory);
//@done
}
@@ -41,32 +45,48 @@ public class GenLayerBiome extends GenLayer
{
double x = xx + (fracture.noise(zz, xx) * 1550D);
double z = zz - (fracture.noise(xx, zz) * 1550D);
if(riverCheck.noise(x, z) > 0.75)
IrisBiome cbi = IrisBiome.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)
{
if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
cbi = IrisBiome.BEACH;
}
else if(land > landChance + 0.0175)
{
if(riverCheck.noise(x, z) > 0.75)
{
return IrisBiome.RIVER;
if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
{
return IrisBiome.RIVER;
}
}
cbi = biomeGenerator.getChoice(x, z);
if(pathCheck.noise(x, z) > 0.33)
{
IrisBiome road = IrisBiome.ROAD_GRAVEL;
if(cbi.getSurface().get(0).material.equals(Material.GRASS))
{
road = IrisBiome.ROAD_GRASSY;
}
if(Math.abs(road.getHeight() - cbi.getHeight()) < 0.0001 && roads.hasBorder(4, 3, xx, zz))
{
return road;
}
}
}
IrisBiome cbi = biomeGenerator.getChoice(x, z);
if(pathCheck.noise(x, z) > 0.33)
else if(land < 0.3)
{
IrisBiome road = IrisBiome.ROAD_GRAVEL;
if(cbi.getSurface().get(0).material.equals(Material.GRASS))
{
road = IrisBiome.ROAD_GRASSY;
}
if(Math.abs(road.getHeight() - cbi.getHeight()) < 0.0001 && roads.hasBorder(4, 3, xx, zz))
{
return road;
}
cbi = IrisBiome.DEEP_OCEAN;
}
return cbi;
}

View File

@@ -39,6 +39,6 @@ public class GenLayerLayeredNoise extends GenLayer
@Override
public double generateLayer(double gnoise, double dx, double dz)
{
return 0.65* gen.noise(gnoise, dx + (fract.noise(gnoise, dx, dz) * 333), dz - (fract.noise(dz, dx, gnoise) * 333));
return 0.65 * gen.noise(gnoise, dx + (fract.noise(gnoise, dx, dz) * 333), dz - (fract.noise(dz, dx, gnoise) * 333));
}
}

View File

@@ -6,7 +6,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.shuriken.math.CNG;

View File

@@ -6,7 +6,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.shuriken.math.CNG;

View File

@@ -6,7 +6,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.shuriken.math.CNG;

View File

@@ -6,7 +6,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.shuriken.math.CNG;

View File

@@ -6,7 +6,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.shuriken.math.CNG;

View File

@@ -6,7 +6,7 @@ import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.MB;
import ninja.bytecode.shuriken.math.CNG;

View File

@@ -5,8 +5,8 @@ import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
import ninja.bytecode.iris.generator.biome.IrisBiome;
import ninja.bytecode.iris.schematic.Schematic;
import ninja.bytecode.iris.spec.IrisBiome;
import ninja.bytecode.iris.util.MB;
public class BiomeBiasSchematicPopulator extends SurfaceBiasSchematicPopulator