mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Cleanup & Fix seed issues
This commit is contained in:
137
src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java
Normal file
137
src/main/java/ninja/bytecode/iris/generator/IrisGenerator.java
Normal file
@@ -0,0 +1,137 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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.GenLayerLayeredNoise;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerRidge;
|
||||
import ninja.bytecode.iris.generator.populator.PopulatorTrees;
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.ChunkPlan;
|
||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.ParallelChunkGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
private MB WATER = new MB(Material.STATIONARY_WATER);
|
||||
private MB BEDROCK = new MB(Material.BEDROCK);
|
||||
private GenLayerBase glBase;
|
||||
private GenLayerLayeredNoise glLNoise;
|
||||
private GenLayerRidge glRidge;
|
||||
private GenLayerBiome glBiome;
|
||||
private RNG rTerrain;
|
||||
private RNG rScatter;
|
||||
private World world;
|
||||
|
||||
@Override
|
||||
public void onInit(World world, Random random)
|
||||
{
|
||||
this.world = world;
|
||||
rTerrain = new RNG(world.getSeed() + 1024);
|
||||
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));
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkPlan onInitChunk(World world, int x, int z, Random random)
|
||||
{
|
||||
return new ChunkPlan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome genColumn(int wxx, int wzx, int x, int z, ChunkPlan plan)
|
||||
{
|
||||
int seaLevel = Iris.settings.gen.seaLevel;
|
||||
int wx = (int) Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
|
||||
int wz = (int) Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
|
||||
IrisBiome biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
|
||||
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 -= glRidge.generateLayer(hv, wxx, wzx);
|
||||
int height = (int) Math.round(M.clip(hv, 0D, 1D) * 253);
|
||||
|
||||
for(int i = 0; i < Math.max(height, seaLevel); i++)
|
||||
{
|
||||
MB mb = new MB(Material.STONE);
|
||||
boolean underwater = i >= height && i < seaLevel;
|
||||
boolean underground = i < height;
|
||||
|
||||
if(underwater)
|
||||
{
|
||||
mb = WATER;
|
||||
}
|
||||
|
||||
if(underground && (height - 1) - i < glBase.scatterInt(x, i, z, 4) + 2)
|
||||
{
|
||||
mb = biome.getDirt(wx, wz);
|
||||
}
|
||||
|
||||
if(i == height - 1)
|
||||
{
|
||||
mb = biome.getSurface(wx, wz, rTerrain);
|
||||
}
|
||||
|
||||
if(Iris.settings.gen.flatBedrock ? i == 0 : i < glBase.scatterInt(x, i, z, 3))
|
||||
{
|
||||
mb = BEDROCK;
|
||||
}
|
||||
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorateColumn(int wx, int wz, int x, int z, ChunkPlan plan)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostChunk(World world, int x, int z, Random random, AtomicChunkData data, ChunkPlan plan)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private double getBiomedHeight(int x, int z, ChunkPlan plan)
|
||||
{
|
||||
return plan.getHeight(x, z, () -> {
|
||||
int wx = (int) Math.round((double) x * Iris.settings.gen.horizontalZoom);
|
||||
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());
|
||||
|
||||
return h;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||
{
|
||||
GList<BlockPopulator> p = new GList<BlockPopulator>();
|
||||
p.add(new PopulatorTrees());
|
||||
return p;
|
||||
}
|
||||
}
|
||||
397
src/main/java/ninja/bytecode/iris/generator/biome/IrisBiome.java
Normal file
397
src/main/java/ninja/bytecode/iris/generator/biome/IrisBiome.java
Normal file
@@ -0,0 +1,397 @@
|
||||
package ninja.bytecode.iris.biome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.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 CBI
|
||||
{
|
||||
//@builder
|
||||
public static final CBI RIVER = new CBI("River", Biome.RIVER)
|
||||
.surface(MB.of(Material.SAND));
|
||||
public static final CBI BEACH = new CBI("Beach", Biome.BEACHES)
|
||||
.surface(MB.of(Material.SAND));
|
||||
public static final CBI ROAD_GRAVEL = new CBI("Gravel Road", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRAVEL), MB.of(Material.COBBLESTONE))
|
||||
.scatter(MB.of(Material.TORCH), 0.05);
|
||||
public static final CBI ROAD_GRASSY = new CBI("Grass Path", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRASS_PATH))
|
||||
.scatter(MB.of(Material.TORCH), 0.05);
|
||||
public static final CBI OCEAN = new CBI("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 CBI DEEP_OCEAN = new CBI("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 CBI DESERT = new CBI("Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
|
||||
.dirt(MB.of(Material.SANDSTONE));
|
||||
public static final CBI DESERT_RED = new CBI("Red Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND, 1))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
|
||||
.dirt(MB.of(Material.RED_SANDSTONE));
|
||||
public static final CBI DESERT_COMBINED = new CBI("Combined Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND, 1))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.008)
|
||||
.dirt(MB.of(Material.SANDSTONE), MB.of(Material.RED_SANDSTONE))
|
||||
.simplexSurface();
|
||||
public static final CBI DESERT_HILLS = new CBI("Desert Hills", Biome.DESERT_HILLS)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.amp(0.75)
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
|
||||
.dirt(MB.of(Material.SANDSTONE));
|
||||
public static final CBI MESA = new CBI("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))
|
||||
.simplexSurface();
|
||||
public static final CBI SAVANNA = new CBI("Savanna", Biome.SAVANNA)
|
||||
.tree(TreeType.ACACIA, 0.102)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18);
|
||||
public static final CBI SAVANNA_HILLS = new CBI("Savanna Hills", Biome.SAVANNA_ROCK)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18)
|
||||
.tree(TreeType.ACACIA, 0.102)
|
||||
.amp(0.75);
|
||||
public static final CBI JUNGLE = new CBI("Jungle", Biome.JUNGLE)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.058)
|
||||
.tree(TreeType.JUNGLE, 0.9)
|
||||
.tree(TreeType.JUNGLE_BUSH, 0.3)
|
||||
.tree(TreeType.SMALL_JUNGLE, 0.1)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.013);
|
||||
public static final CBI JUNGLE_HILLS = new CBI("Jungle Hills", Biome.JUNGLE_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.081)
|
||||
.tree(TreeType.JUNGLE, 0.9)
|
||||
.tree(TreeType.JUNGLE_BUSH, 0.3)
|
||||
.tree(TreeType.SMALL_JUNGLE, 0.1)
|
||||
.amp(1.75)
|
||||
.height(0.166)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.02);
|
||||
public static final CBI SWAMP = new CBI("Swamp", Biome.SWAMPLAND)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
|
||||
.tree(TreeType.SWAMP, 0.25)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
|
||||
public static final CBI PLAINS = new CBI("Plains", Biome.PLAINS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.38)
|
||||
.amp(0.4)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
|
||||
public static final CBI DECAYING_PLAINS = new CBI("Decaying Plains", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRASS_PATH), MB.of(Material.GRASS))
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
|
||||
.simplexSurface();
|
||||
public static final CBI FOREST = new CBI("Forest", Biome.FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.tree(TreeType.TREE, 0.7)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI FOREST_HILLS = new CBI("Forest Hills", Biome.FOREST_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.amp(0.75)
|
||||
.tree(TreeType.TREE, 0.7)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI FOREST_MOUNTAINS = new CBI("Forest Mountains", Biome.MUTATED_EXTREME_HILLS_WITH_TREES)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
|
||||
.amp(2.25)
|
||||
.height(0.265)
|
||||
.tree(TreeType.MEGA_REDWOOD, 0.5)
|
||||
.tree(TreeType.TALL_REDWOOD, 0.7)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI HAUNTED_FOREST = new CBI("Haunted Forest", Biome.MUTATED_SWAMPLAND)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.13)
|
||||
.tree(TreeType.JUNGLE_BUSH, 0.5)
|
||||
.tree(TreeType.BIG_TREE, 0.4)
|
||||
.tree(TreeType.SWAMP, 0.4)
|
||||
.tree(TreeType.JUNGLE, 0.4)
|
||||
.tree(TreeType.SMALL_JUNGLE, 0.4)
|
||||
.tree(TreeType.JUNGLE_BUSH, 0.5)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13)
|
||||
.surface(MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.GRASS), MB.of(Material.DIRT), MB.of(Material.DIRT, 1), MB.of(Material.DIRT, 2))
|
||||
.scatterSurface();
|
||||
public static final CBI BIRCH_FOREST = new CBI("Birch Forest", Biome.BIRCH_FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.tree(TreeType.BIRCH, 0.7)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI BIRCH_FOREST_HILLS = new CBI("Birch Forest Hills", Biome.BIRCH_FOREST_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.tree(TreeType.BIRCH, 0.7)
|
||||
.amp(0.75)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI ROOFED_FOREST = new CBI("Roofed Forest", Biome.ROOFED_FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.tree(TreeType.DARK_OAK, 0.9)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI TAIGA = new CBI("Taiga", Biome.TAIGA)
|
||||
.tree(TreeType.REDWOOD, 0.4)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.07);
|
||||
public static final CBI EXTREME_HILLS = new CBI("Extreme Hills", Biome.EXTREME_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04)
|
||||
.amp(1.565)
|
||||
.height(0.22);
|
||||
public static final CBI EXTREME_HILLS_TREES = new CBI("Extreme Hills +", Biome.EXTREME_HILLS_WITH_TREES)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.09)
|
||||
.tree(TreeType.REDWOOD, 0.1)
|
||||
.amp(1.525)
|
||||
.height(0.22);
|
||||
public static final CBI TAIGA_COLD = new CBI("Taiga Cold", Biome.TAIGA_COLD)
|
||||
.tree(TreeType.REDWOOD, 0.3)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04);
|
||||
public static final CBI TAIGA_COLD_HILLS = new CBI("Taiga Cold Hills", Biome.TAIGA_COLD_HILLS)
|
||||
.tree(TreeType.REDWOOD, 0.15).amp(0.75);
|
||||
public static final CBI ICE_FLATS = new CBI("Ice Flats", Biome.ICE_FLATS);
|
||||
public static final CBI ICE_MOUNTAINS = new CBI("Ice Mountains", Biome.ICE_MOUNTAINS)
|
||||
.amp(1.45);
|
||||
public static final CBI REDWOOD_TAIGA = new CBI("Redwood Taiga", Biome.REDWOOD_TAIGA)
|
||||
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
.tree(TreeType.TALL_REDWOOD, 0.7)
|
||||
.tree(TreeType.MEGA_REDWOOD, 0.6)
|
||||
.tree(TreeType.REDWOOD, 0.3)
|
||||
.simplexSurface();
|
||||
public static final CBI REDWOOD_TAIGA_HILLS = new CBI("Redwood Taiga Hills", Biome.REDWOOD_TAIGA_HILLS)
|
||||
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
.amp(0.75)
|
||||
.simplexSurface();
|
||||
|
||||
//@done
|
||||
private static final GMap<Biome, CBI> map = build();
|
||||
private String name;
|
||||
private Biome realBiome;
|
||||
private double height;
|
||||
private double amp;
|
||||
private GMap<TreeType, Double> treeChance;
|
||||
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 CBI(String name, Biome realBiome)
|
||||
{
|
||||
this.name = name;
|
||||
this.realBiome = realBiome;
|
||||
this.height = 0.125;
|
||||
this.amp = 0.5;
|
||||
scatterChance = new GMap<>();
|
||||
schematicGroups = new GMap<>();
|
||||
treeChance = new GMap<>();
|
||||
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
|
||||
}
|
||||
|
||||
private static GMap<Biome, CBI> build()
|
||||
{
|
||||
GMap<Biome, CBI> g = new GMap<Biome, CBI>();
|
||||
|
||||
for(Field i : CBI.class.getDeclaredFields())
|
||||
{
|
||||
J.attempt(() ->
|
||||
{
|
||||
i.setAccessible(true);
|
||||
|
||||
CBI bb = (CBI) i.get(null);
|
||||
|
||||
if(!g.containsKey(bb.realBiome))
|
||||
{
|
||||
g.put(bb.realBiome, bb);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
public CBI scatter(MB mb, Double chance)
|
||||
{
|
||||
scatterChance.put(mb, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI tree(TreeType t, Double chance)
|
||||
{
|
||||
treeChance.put(t, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI schematic(String t, Double chance)
|
||||
{
|
||||
schematicGroups.put(t, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI simplexSurface()
|
||||
{
|
||||
simplexScatter = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI scatterSurface()
|
||||
{
|
||||
scatterSurface = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI surface(MB... mbs)
|
||||
{
|
||||
surface = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI dirt(MB... mbs)
|
||||
{
|
||||
dirt = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI height(double height)
|
||||
{
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI 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(int x, int 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.nextRNG(), 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.nextRNG(), 1D, 2).scale(0.0155), 224);
|
||||
});
|
||||
}
|
||||
|
||||
return poly.getChoice(wx * 0.2D, wz * 0.2D);
|
||||
}
|
||||
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public MB getDirt(int wx, int wz)
|
||||
{
|
||||
return getDirt().getRandom();
|
||||
}
|
||||
|
||||
public GMap<MB, Double> getScatterChance()
|
||||
{
|
||||
return scatterChance;
|
||||
}
|
||||
|
||||
public MB getScatterChanceSingle()
|
||||
{
|
||||
for(MB i : getScatterChance().keySet())
|
||||
{
|
||||
if(M.r(getScatterChance().get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return MB.of(Material.AIR);
|
||||
}
|
||||
|
||||
public GMap<TreeType, Double> getTreeChance()
|
||||
{
|
||||
return treeChance;
|
||||
}
|
||||
|
||||
public TreeType getTreeChanceSingle()
|
||||
{
|
||||
for(TreeType i : getTreeChance().keySet())
|
||||
{
|
||||
if(M.r(getTreeChance().get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSchematicChanceSingle()
|
||||
{
|
||||
for(String i : schematicGroups.keySet())
|
||||
{
|
||||
if(M.r(schematicGroups.get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CBI find(Biome biome)
|
||||
{
|
||||
if(map.containsKey(biome))
|
||||
{
|
||||
return map.get(biome);
|
||||
}
|
||||
|
||||
return CBI.PLAINS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerBase extends GenLayer
|
||||
{
|
||||
private double[][][] scatterCache;
|
||||
private CNG gen;
|
||||
private CNG fracture;
|
||||
private CNG hfracture;
|
||||
private CNG height;
|
||||
private CNG superheight;
|
||||
|
||||
public GenLayerBase(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
scatterCache = new double[16][][];
|
||||
CNG scatter = new CNG(rng.nextParallelRNG(5), 1, 1)
|
||||
.scale(10);
|
||||
hfracture = new CNG(rng.nextParallelRNG(6), 1, 2)
|
||||
.scale(0.0124);
|
||||
gen = new CNG(rng.nextParallelRNG(7), 0.19D, 8)
|
||||
.scale(0.012)
|
||||
.amp(0.5)
|
||||
.freq(1.1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(8), 1, 6)
|
||||
.scale(0.018)
|
||||
.injectWith(CNG.MULTIPLY)
|
||||
.child(new CNG(rng.nextParallelRNG(9), 0.745, 2)
|
||||
.scale(0.1)), 44);
|
||||
height = new CNG(rng.nextParallelRNG(10), 1, 8)
|
||||
.scale(0.0017601 * Iris.settings.gen.heightScale)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(11), 1, 6)
|
||||
.scale(0.0174)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(12), 1, 1)
|
||||
.scale(0.0034), 31)
|
||||
.scale(0.066), 58);
|
||||
superheight = new CNG(rng.nextParallelRNG(13), 1, 6)
|
||||
.scale(0.0025 * Iris.settings.gen.superHeightScale)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(14), 1, 1)
|
||||
.scale(0.021), 250);
|
||||
fracture = new CNG(rng.nextParallelRNG(15), 0.6D, 4)
|
||||
.scale(0.118);
|
||||
//@done
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
scatterCache[i] = new double[16][];
|
||||
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
scatterCache[i][j] = new double[16];
|
||||
|
||||
for(int k = 0; k < 16; k++)
|
||||
{
|
||||
scatterCache[i][j][k] = scatter.noise(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getHeight(double x, double z)
|
||||
{
|
||||
return M.clip(Math.pow(height.noise(x + (hfracture.noise(x, z) * Iris.settings.gen.heightFracture), z + (hfracture.noise(z, x) * Iris.settings.gen.heightFracture)), Iris.settings.gen.heightExponentBase + (superheight.noise(x, z) * Iris.settings.gen.heightExponentMultiplier)) * Iris.settings.gen.heightMultiplier, 0D, 1D);
|
||||
}
|
||||
|
||||
public int scatterInt(int x, int y, int z, int bound)
|
||||
{
|
||||
return (int) (scatter(x, y, z) * (double) (bound - 1));
|
||||
}
|
||||
|
||||
public double scatter(int x, int y, int z)
|
||||
{
|
||||
return scatterCache[Math.abs(x) % 16][Math.abs(y) % 16][Math.abs(z) % 16];
|
||||
}
|
||||
|
||||
public boolean scatterChance(int x, int y, int z, double chance)
|
||||
{
|
||||
return scatter(x, y, z) > chance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double gnoise, double dx, double dz)
|
||||
{
|
||||
double noise = gnoise + getHeight(dx, dz);
|
||||
double fnoise = fracture.noise(dx, dz);
|
||||
dx += (fnoise * 44);
|
||||
dz -= (fnoise * 44);
|
||||
return ((noise * 0.185) + (gen.noise(dx, dz) * (0.15 + (noise * 0.65))));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator.EnumMaxingGenerator;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
private EnumMaxingGenerator<IrisBiome> biomeGenerator;
|
||||
private MaxingGenerator roads;
|
||||
private Function<CNG, CNG> factory;
|
||||
private CNG pathCheck;
|
||||
private CNG riverCheck;
|
||||
private CNG fracture;
|
||||
|
||||
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
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,
|
||||
new IrisBiome[] {
|
||||
IrisBiome.HAUNTED_FOREST,
|
||||
IrisBiome.FOREST_MOUNTAINS,
|
||||
IrisBiome.DESERT,
|
||||
IrisBiome.DESERT_HILLS,
|
||||
IrisBiome.MESA,
|
||||
IrisBiome.DESERT_COMBINED,
|
||||
IrisBiome.SAVANNA,
|
||||
IrisBiome.SAVANNA_HILLS,
|
||||
IrisBiome.DESERT_RED,
|
||||
IrisBiome.JUNGLE,
|
||||
IrisBiome.JUNGLE_HILLS,
|
||||
IrisBiome.SWAMP,
|
||||
IrisBiome.OCEAN,
|
||||
IrisBiome.PLAINS,
|
||||
IrisBiome.DECAYING_PLAINS,
|
||||
IrisBiome.FOREST,
|
||||
IrisBiome.FOREST_HILLS,
|
||||
IrisBiome.BIRCH_FOREST,
|
||||
IrisBiome.BIRCH_FOREST_HILLS,
|
||||
IrisBiome.ROOFED_FOREST,
|
||||
IrisBiome.TAIGA,
|
||||
IrisBiome.EXTREME_HILLS,
|
||||
IrisBiome.EXTREME_HILLS_TREES,
|
||||
IrisBiome.TAIGA_COLD,
|
||||
IrisBiome.TAIGA_COLD_HILLS,
|
||||
IrisBiome.ICE_FLATS,
|
||||
IrisBiome.ICE_MOUNTAINS,
|
||||
IrisBiome.REDWOOD_TAIGA,
|
||||
IrisBiome.REDWOOD_TAIGA_HILLS,
|
||||
}, factory);
|
||||
//@done
|
||||
}
|
||||
|
||||
public IrisBiome getBiome(double xx, double zz)
|
||||
{
|
||||
double x = xx + (fracture.noise(zz, xx) * 1550D);
|
||||
double z = zz - (fracture.noise(xx, zz) * 1550D);
|
||||
|
||||
if(riverCheck.noise(x, z) > 0.75)
|
||||
{
|
||||
if(biomeGenerator.hasBorder(3, 3 + Math.pow(riverCheck.noise(x, z), 1.25) * 16, x, z))
|
||||
{
|
||||
return IrisBiome.RIVER;
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome 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;
|
||||
}
|
||||
}
|
||||
|
||||
return cbi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerFracture extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
private CNG cond;
|
||||
private double shootHeight = 0.563;
|
||||
|
||||
public GenLayerFracture(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
gen = new CNG(rng.nextParallelRNG(40), 1D, 12)
|
||||
.scale(0.023)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(41), 1D, 1)
|
||||
.scale(0.05), 333);
|
||||
cond = new CNG(rng.nextParallelRNG(42), 1D, 12)
|
||||
.scale(0.038)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(43), 1D, 1)
|
||||
.scale(0.025), 299);
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
double shootHeight = this.shootHeight + (cond.noise(dx, dz) * 0.035);
|
||||
|
||||
if(noise >= shootHeight)
|
||||
{
|
||||
double multiplier = M.rangeScale(0, 0.055, this.shootHeight, 1D, cond.noise(-dx, -dz));
|
||||
double on = gen.noise(dx, dz) * multiplier;
|
||||
|
||||
return noise + on;
|
||||
}
|
||||
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerLayeredNoise extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
private CNG fract;
|
||||
|
||||
public GenLayerLayeredNoise(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
fract = new CNG(rng.nextParallelRNG(16), 1D, 9).scale(0.0181);
|
||||
gen = new CNG(rng.nextParallelRNG(17), 0.19D, 16)
|
||||
.scale(0.012)
|
||||
.amp(0.5)
|
||||
.freq(1.1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 6)
|
||||
.scale(0.018)
|
||||
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
||||
.scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
|
||||
.scale(0.15), 24), 44);
|
||||
}
|
||||
|
||||
public double getHeight(double x, double z)
|
||||
{
|
||||
return 0.65* gen.noise(x, z);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerRidge extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
private CNG fract;
|
||||
private CNG g;
|
||||
private CNG q;
|
||||
|
||||
public GenLayerRidge(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
q = new CNG(rng.nextParallelRNG(21), 1D, 2).scale(0.0211);
|
||||
g = new CNG(rng.nextParallelRNG(22), 1D, 2).scale(0.0011);
|
||||
fract = new CNG(rng.nextParallelRNG(23), 1D, 5).scale(0.0011);
|
||||
gen = new CNG(rng.nextParallelRNG(24), 0.19D, 16)
|
||||
.scale(0.012)
|
||||
.injectWith(CNG.MAX)
|
||||
.amp(0.5)
|
||||
.freq(1.1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(25), 1, 6)
|
||||
.scale(0.018)
|
||||
.child(new CNG(rng.nextParallelRNG(26), 0.745, 2)
|
||||
.scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(27), 1, 3)
|
||||
.scale(0.15), 24), 44);
|
||||
}
|
||||
|
||||
public double getHeight(double x, double z)
|
||||
{
|
||||
return gen.noise(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double gnoise, double dx, double dz)
|
||||
{
|
||||
double d = gen.noise(gnoise, dx + (fract.noise(gnoise, dx, dz) * 1555), dz - (fract.noise(dz, dx, gnoise) * 1555));
|
||||
|
||||
if(d > g.noise(dx, dz) / 8D)
|
||||
{
|
||||
return q.noise(dx, dz, d) * (d / (7D * (g.noise(dz, dx, gnoise) + 0.1))) * (Math.PI / 2.78);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package ninja.bytecode.iris.generator.populator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
|
||||
import ninja.bytecode.shuriken.math.RollingSequence;
|
||||
|
||||
public class PopulatorTrees extends BlockPopulator
|
||||
{
|
||||
public static RollingSequence timings = new RollingSequence(512);
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source)
|
||||
{
|
||||
if(!Iris.settings.gen.doTrees)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch f = PrecisionStopwatch.start();
|
||||
int debuff = 0;
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
if(debuff > 0)
|
||||
{
|
||||
debuff--;
|
||||
continue;
|
||||
}
|
||||
|
||||
int x = random.nextInt(15) + (source.getX() * 16);
|
||||
int z = random.nextInt(15) + (source.getZ() * 16);
|
||||
int y = world.getHighestBlockYAt(x, z);
|
||||
Location l = new Location(world, x, y, z);
|
||||
|
||||
if(!l.getBlock().getType().isSolid())
|
||||
{
|
||||
l.getBlock().setType(Material.AIR, false);
|
||||
}
|
||||
|
||||
IrisBiome biome = IrisBiome.find(world.getBiome(x, z));
|
||||
TreeType tt = biome.getTreeChanceSingle();
|
||||
|
||||
if(tt != null)
|
||||
{
|
||||
world.generateTree(l, tt);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
debuff += 4;
|
||||
}
|
||||
}
|
||||
|
||||
f.end();
|
||||
timings.put(f.getMilliseconds());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user