mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
Cleanup & Fix seed issues
This commit is contained in:
parent
92ce6e5a8d
commit
4ce37da17e
@ -18,6 +18,7 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.RealBiome;
|
||||
import ninja.bytecode.shuriken.bench.Profiler;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
@ -161,7 +162,7 @@ public class Iris extends JavaPlugin implements Listener
|
||||
|
||||
private World createIrisWorld()
|
||||
{
|
||||
World ww = Bukkit.createWorld(new WorldCreator("iris-worlds/" + UUID.randomUUID().toString()).generator(new IrisGenerator()).seed(0));
|
||||
World ww = Bukkit.createWorld(new WorldCreator("iris-worlds/" + UUID.randomUUID().toString()).generator(new IrisGenerator()).seed(5944323));
|
||||
ww.setSpawnFlags(false, false);
|
||||
ww.setAutoSave(false);
|
||||
ww.setKeepSpawnInMemory(false);
|
||||
|
@ -1,241 +0,0 @@
|
||||
package ninja.bytecode.iris;
|
||||
|
||||
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 org.bukkit.util.Vector;
|
||||
|
||||
import ninja.bytecode.iris.atomics.AtomicChunkData;
|
||||
import ninja.bytecode.iris.biome.CBI;
|
||||
import ninja.bytecode.iris.gen.GenLayerBase;
|
||||
import ninja.bytecode.iris.gen.GenLayerBiome;
|
||||
import ninja.bytecode.iris.gen.GenLayerLayeredNoise;
|
||||
import ninja.bytecode.iris.gen.GenLayerRidge;
|
||||
import ninja.bytecode.iris.pop.PopulatorTrees;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
private GMap<Vector, Double> heightCache;
|
||||
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 rng;
|
||||
private World world;
|
||||
|
||||
@Override
|
||||
public void onInit(World world, Random random)
|
||||
{
|
||||
this.world = world;
|
||||
heightCache = new GMap<>();
|
||||
rng = new RNG(world.getSeed());
|
||||
glBase = new GenLayerBase(this, world, random, rng.nextRNG());
|
||||
glLNoise = new GenLayerLayeredNoise(this, world, random, rng.nextRNG());
|
||||
glRidge = new GenLayerRidge(this, world, random, rng.nextRNG());
|
||||
glBiome = new GenLayerBiome(this, world, random, rng.nextRNG());
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getHeight(double h)
|
||||
{
|
||||
double height = M.clip(h, 0D, 1D);
|
||||
|
||||
return (int) (height * 253);
|
||||
}
|
||||
|
||||
public int getHeight(double dx, double dz)
|
||||
{
|
||||
return getHeight(getRawHeight(dx, dz));
|
||||
}
|
||||
|
||||
public double getRawHeight(double dx, double dz)
|
||||
{
|
||||
double noise = 0 + Iris.settings.gen.baseHeight;
|
||||
|
||||
return M.clip(noise, 0D, 1D);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome genColumn(int wxx, int wzx, int x, int z)
|
||||
{
|
||||
return genBaseColumn(wxx, wzx, x, z);
|
||||
}
|
||||
|
||||
private double lerp(double a, double b, double f)
|
||||
{
|
||||
return a + (f * (b - a));
|
||||
}
|
||||
|
||||
private double blerp(double a, double b, double c, double d, double tx, double ty)
|
||||
{
|
||||
return lerp(lerp(a, b, tx), lerp(c, d, tx), ty);
|
||||
}
|
||||
|
||||
private double getBiomedHeight(int x, int z)
|
||||
{
|
||||
Vector v = new Vector(x, z, x * z);
|
||||
if(heightCache.containsKey(v))
|
||||
{
|
||||
return heightCache.get(v);
|
||||
}
|
||||
|
||||
int wx = (int) Math.round((double) x * Iris.settings.gen.horizontalZoom);
|
||||
int wz = (int) Math.round((double) z * Iris.settings.gen.horizontalZoom);
|
||||
CBI 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());
|
||||
heightCache.put(v, h);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
private double getBilinearNoise(int x, int z)
|
||||
{
|
||||
int h = 5;
|
||||
int fx = x >> h;
|
||||
int fz = z >> h;
|
||||
int xa = (fx << h) - 2;
|
||||
int za = (fz << h) - 2;
|
||||
int xb = ((fx + 1) << h) + 2;
|
||||
int zb = ((fz + 1) << h) + 2;
|
||||
double na = getBiomedHeight(xa, za);
|
||||
double nb = getBiomedHeight(xa, zb);
|
||||
double nc = getBiomedHeight(xb, za);
|
||||
double nd = getBiomedHeight(xb, zb);
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerp(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
|
||||
private double getBicubicNoise(int x, int z)
|
||||
{
|
||||
int h = 5;
|
||||
int fx = x >> h;
|
||||
int fz = z >> h;
|
||||
int xa = (fx << h);
|
||||
int za = (fz << h);
|
||||
int xb = ((fx + 1) << h);
|
||||
int zb = ((fz + 1) << h);
|
||||
double na = getBilinearNoise(xa, za);
|
||||
double nb = getBilinearNoise(xa, zb);
|
||||
double nc = getBilinearNoise(xb, za);
|
||||
double nd = getBilinearNoise(xb, zb);
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerp(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
|
||||
|
||||
private Biome genBaseColumn(int wxx, int wzx, int x, int z)
|
||||
{
|
||||
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);
|
||||
CBI biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
|
||||
double hv = getBicubicNoise(wxx, wzx);
|
||||
hv += glLNoise.generateLayer(hv, wxx, wzx);
|
||||
hv -= glRidge.generateLayer(hv, wxx, wzx);
|
||||
int height = getHeight(hv);
|
||||
|
||||
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, rng);
|
||||
|
||||
if(height < 254 && height >= seaLevel)
|
||||
{
|
||||
MB place = biome.getScatterChanceSingle();
|
||||
|
||||
if(!place.material.equals(Material.AIR))
|
||||
{
|
||||
if(mb.material.equals(Material.GRASS) || mb.material.equals(Material.SAND) || mb.material.equals(Material.DIRT))
|
||||
{
|
||||
setBlock(x, i + 1, z, place.material, place.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Iris.settings.gen.flatBedrock ? i == 0 : i < glBase.scatterInt(x, i, z, 3))
|
||||
{
|
||||
mb = BEDROCK;
|
||||
}
|
||||
|
||||
if(i == height - 1 && i < 66 + (glBase.scatter(wx, i, wz) * 2) && i > 59)
|
||||
{
|
||||
mb = MB.of(Material.SAND);
|
||||
setBlock(x, i+1, z, Material.AIR);
|
||||
setBlock(x, i-1, z, mb.material, mb.data);
|
||||
setBlock(x, i-2, z, mb.material, mb.data);
|
||||
setBlock(x, i-3, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||
{
|
||||
GList<BlockPopulator> p = new GList<BlockPopulator>();
|
||||
p.add(new PopulatorTrees());
|
||||
return p;
|
||||
}
|
||||
|
||||
public int pick(int max, double noise)
|
||||
{
|
||||
return (int) (noise * max);
|
||||
}
|
||||
|
||||
public MB pick(MB[] array, double noise)
|
||||
{
|
||||
return array[pick(array.length, noise)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitChunk(World world, int x, int z, Random random)
|
||||
{
|
||||
heightCache.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GList<Runnable> onPostChunk(World world, int x, int z, Random random, AtomicChunkData data)
|
||||
{
|
||||
GList<Runnable> jobs = new GList<>();
|
||||
|
||||
return jobs;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package ninja.bytecode.iris;
|
||||
|
||||
import ninja.bytecode.iris.util.PerformanceMode;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
public PerformanceSettings performance = new PerformanceSettings();
|
||||
@ -25,5 +27,6 @@ public class Settings
|
||||
public int seaLevel = 63;
|
||||
public double biomeScale = 2.46;
|
||||
public boolean flatBedrock = false;
|
||||
public boolean doTrees = false;
|
||||
}
|
||||
}
|
||||
|
@ -1,108 +0,0 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
|
||||
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.IrisGenerator;
|
||||
import ninja.bytecode.iris.biome.CBI;
|
||||
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<CBI> 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.nextRNG(), 1D, 24).scale(0.0021).fractureWith(new CNG(rng.nextRNG(), 1D, 12).scale(0.01), 12250);
|
||||
factory = (g) -> g.fractureWith(new CNG(rng.nextRNG(), 1D, 4).scale(0.02), 56);
|
||||
riverCheck = new CNG(rng.nextRNG(), 1D, 2).scale(0.00096);
|
||||
pathCheck = new CNG(rng.nextRNG(), 1D, 1).scale(0.00096);
|
||||
roads = new MaxingGenerator(rng.nextRNG(), 5, 0.00055, 8, factory);
|
||||
biomeGenerator = new EnumMaxingGenerator<CBI>(rng.nextRNG(), 0.00755 * Iris.settings.gen.biomeScale, 1,
|
||||
new CBI[] {
|
||||
CBI.HAUNTED_FOREST,
|
||||
CBI.FOREST_MOUNTAINS,
|
||||
CBI.DESERT,
|
||||
CBI.DESERT_HILLS,
|
||||
CBI.MESA,
|
||||
CBI.DESERT_COMBINED,
|
||||
CBI.SAVANNA,
|
||||
CBI.SAVANNA_HILLS,
|
||||
CBI.DESERT_RED,
|
||||
CBI.JUNGLE,
|
||||
CBI.JUNGLE_HILLS,
|
||||
CBI.SWAMP,
|
||||
CBI.OCEAN,
|
||||
CBI.PLAINS,
|
||||
CBI.DECAYING_PLAINS,
|
||||
CBI.FOREST,
|
||||
CBI.FOREST_HILLS,
|
||||
CBI.BIRCH_FOREST,
|
||||
CBI.BIRCH_FOREST_HILLS,
|
||||
CBI.ROOFED_FOREST,
|
||||
CBI.TAIGA,
|
||||
CBI.EXTREME_HILLS,
|
||||
CBI.EXTREME_HILLS_TREES,
|
||||
CBI.TAIGA_COLD,
|
||||
CBI.TAIGA_COLD_HILLS,
|
||||
CBI.ICE_FLATS,
|
||||
CBI.ICE_MOUNTAINS,
|
||||
CBI.REDWOOD_TAIGA,
|
||||
CBI.REDWOOD_TAIGA_HILLS,
|
||||
}, factory);
|
||||
//@done
|
||||
}
|
||||
|
||||
public CBI 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 CBI.RIVER;
|
||||
}
|
||||
}
|
||||
|
||||
CBI cbi = biomeGenerator.getChoice(x, z);
|
||||
|
||||
if(pathCheck.noise(x, z) > 0.33)
|
||||
{
|
||||
CBI road = CBI.ROAD_GRAVEL;
|
||||
|
||||
if(cbi.getSurface().get(0).material.equals(Material.GRASS))
|
||||
{
|
||||
road = CBI.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;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerDeepOcean extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
private CNG cond;
|
||||
private double deepHeight = 0.493;
|
||||
|
||||
public GenLayerDeepOcean(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
gen = new CNG(rng.nextRNG(), 1D, 4)
|
||||
.scale(0.023)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
|
||||
.scale(0.05), 25);
|
||||
cond = new CNG(rng.nextRNG(), 1D, 4)
|
||||
.scale(0.018)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
|
||||
.scale(0.025), 33);
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
double deepHeight = this.deepHeight - (cond.noise(dx, dz) * 0.03);
|
||||
|
||||
if(noise <= deepHeight)
|
||||
{
|
||||
double inv = 1D / deepHeight;
|
||||
double fract = ((1D - (((noise + (1D - deepHeight)) * inv) * deepHeight))) * inv;
|
||||
double on = gen.noise(dx, dz) * 1.93 * fract;
|
||||
|
||||
return noise - on;
|
||||
}
|
||||
|
||||
return noise;
|
||||
}
|
||||
}
|
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;
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
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;
|
||||
@ -24,33 +25,31 @@ public class GenLayerBase extends GenLayer
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
scatterCache = new double[16][][];
|
||||
CNG scatter = new CNG(rng.nextRNG(), 1, 1)
|
||||
CNG scatter = new CNG(rng.nextParallelRNG(5), 1, 1)
|
||||
.scale(10);
|
||||
hfracture = new CNG(rng.nextRNG(), 1, 2)
|
||||
hfracture = new CNG(rng.nextParallelRNG(6), 1, 2)
|
||||
.scale(0.0124);
|
||||
gen = new CNG(rng.nextRNG(), 0.19D, 16)
|
||||
gen = new CNG(rng.nextParallelRNG(7), 0.19D, 8)
|
||||
.scale(0.012)
|
||||
.amp(0.5)
|
||||
.freq(1.1)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1, 6)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(8), 1, 6)
|
||||
.scale(0.018)
|
||||
.injectWith(CNG.MULTIPLY)
|
||||
.child(new CNG(rng.nextRNG(), 0.745, 2)
|
||||
.scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1, 3)
|
||||
.scale(0.15), 24), 44);
|
||||
height = new CNG(rng.nextRNG(), 1, 16)
|
||||
.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.nextRNG(), 1, 6)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(11), 1, 6)
|
||||
.scale(0.0174)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(12), 1, 1)
|
||||
.scale(0.0034), 31)
|
||||
.scale(0.066), 58);
|
||||
superheight = new CNG(rng.nextRNG(), 1, 6)
|
||||
superheight = new CNG(rng.nextParallelRNG(13), 1, 6)
|
||||
.scale(0.0025 * Iris.settings.gen.superHeightScale)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(14), 1, 1)
|
||||
.scale(0.021), 250);
|
||||
fracture = new CNG(rng.nextRNG(), 0.6D, 4)
|
||||
fracture = new CNG(rng.nextParallelRNG(15), 0.6D, 4)
|
||||
.scale(0.118);
|
||||
//@done
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
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;
|
||||
@ -19,13 +20,13 @@ public class GenLayerFracture extends GenLayer
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
gen = new CNG(rng.nextRNG(), 1D, 12)
|
||||
gen = new CNG(rng.nextParallelRNG(40), 1D, 12)
|
||||
.scale(0.023)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(41), 1D, 1)
|
||||
.scale(0.05), 333);
|
||||
cond = new CNG(rng.nextRNG(), 1D, 12)
|
||||
cond = new CNG(rng.nextParallelRNG(42), 1D, 12)
|
||||
.scale(0.038)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(43), 1D, 1)
|
||||
.scale(0.025), 299);
|
||||
//@done
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
@ -17,16 +18,16 @@ public class GenLayerLayeredNoise extends GenLayer
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
fract = new CNG(rng.nextRNG(), 1D, 9).scale(0.0181);
|
||||
gen = new CNG(rng.nextRNG(), 0.19D, 16)
|
||||
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.nextRNG(), 1, 6)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(18), 1, 6)
|
||||
.scale(0.018)
|
||||
.child(new CNG(rng.nextRNG(), 0.745, 2)
|
||||
.child(new CNG(rng.nextParallelRNG(19), 0.745, 2)
|
||||
.scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1, 3)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(20), 1, 3)
|
||||
.scale(0.15), 24), 44);
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
@ -19,19 +20,19 @@ public class GenLayerRidge extends GenLayer
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
q = new CNG(rng.nextRNG(), 1D, 2).scale(0.0211);
|
||||
g = new CNG(rng.nextRNG(), 1D, 2).scale(0.0011);
|
||||
fract = new CNG(rng.nextRNG(), 1D, 5).scale(0.0011);
|
||||
gen = new CNG(rng.nextRNG(), 0.19D, 16)
|
||||
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.nextRNG(), 1, 6)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(25), 1, 6)
|
||||
.scale(0.018)
|
||||
.child(new CNG(rng.nextRNG(), 0.745, 2)
|
||||
.child(new CNG(rng.nextParallelRNG(26), 0.745, 2)
|
||||
.scale(0.1))
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1, 3)
|
||||
.fractureWith(new CNG(rng.nextParallelRNG(27), 1, 3)
|
||||
.scale(0.15), 24), 44);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris.pop;
|
||||
package ninja.bytecode.iris.generator.populator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -9,7 +9,8 @@ import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import ninja.bytecode.iris.biome.CBI;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
|
||||
import ninja.bytecode.shuriken.math.RollingSequence;
|
||||
|
||||
@ -20,6 +21,11 @@ public class PopulatorTrees extends BlockPopulator
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source)
|
||||
{
|
||||
if(!Iris.settings.gen.doTrees)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch f = PrecisionStopwatch.start();
|
||||
int debuff = 0;
|
||||
|
||||
@ -41,7 +47,7 @@ public class PopulatorTrees extends BlockPopulator
|
||||
l.getBlock().setType(Material.AIR, false);
|
||||
}
|
||||
|
||||
CBI biome = CBI.find(world.getBiome(x, z));
|
||||
IrisBiome biome = IrisBiome.find(world.getBiome(x, z));
|
||||
TreeType tt = biome.getTreeChanceSingle();
|
||||
|
||||
if(tt != null)
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris.atomics;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris.atomics;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
@ -7,7 +7,6 @@ import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.IBlockData;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.MB;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
|
||||
public class Catalyst12
|
||||
|
61
src/main/java/ninja/bytecode/iris/util/ChunkPlan.java
Normal file
61
src/main/java/ninja/bytecode/iris/util/ChunkPlan.java
Normal file
@ -0,0 +1,61 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import ninja.bytecode.iris.generator.biome.IrisBiome;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
|
||||
public class ChunkPlan
|
||||
{
|
||||
private final GMap<ChunkedVector, Double> heightCache;
|
||||
private final GMap<ChunkedVector, IrisBiome> biomeCache;
|
||||
|
||||
public ChunkPlan()
|
||||
{
|
||||
this.heightCache = new GMap<ChunkedVector, Double>();
|
||||
this.biomeCache = new GMap<ChunkedVector, IrisBiome>();
|
||||
}
|
||||
|
||||
public IrisBiome getBiome(int x, int z)
|
||||
{
|
||||
return biomeCache.get(new ChunkedVector(x, z));
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, IrisBiome cng)
|
||||
{
|
||||
biomeCache.put(new ChunkedVector(x, z), cng);
|
||||
}
|
||||
|
||||
public double getHeight(int x, int z, Supplier<Double> realHeight)
|
||||
{
|
||||
ChunkedVector c = new ChunkedVector(x, z);
|
||||
if(hasHeight(c))
|
||||
{
|
||||
return heightCache.get(c);
|
||||
}
|
||||
|
||||
double m = realHeight.get();
|
||||
setHeight(c, m);
|
||||
return m;
|
||||
}
|
||||
|
||||
public boolean hasHeight(ChunkedVector c)
|
||||
{
|
||||
return heightCache.containsKey(c);
|
||||
}
|
||||
|
||||
public boolean hasHeight(int x, int z)
|
||||
{
|
||||
return hasHeight(new ChunkedVector(x, z));
|
||||
}
|
||||
|
||||
public void setHeight(ChunkedVector c, double h)
|
||||
{
|
||||
heightCache.put(c, h);
|
||||
}
|
||||
|
||||
public void setHeight(int x, int z, double h)
|
||||
{
|
||||
setHeight(new ChunkedVector(x, z), h);
|
||||
}
|
||||
}
|
78
src/main/java/ninja/bytecode/iris/util/ChunkedVector.java
Normal file
78
src/main/java/ninja/bytecode/iris/util/ChunkedVector.java
Normal file
@ -0,0 +1,78 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
public class ChunkedVector
|
||||
{
|
||||
private byte x;
|
||||
private byte z;
|
||||
|
||||
public ChunkedVector(int x, int z)
|
||||
{
|
||||
this.x = (byte) (x);
|
||||
this.z = (byte) (z);
|
||||
}
|
||||
|
||||
public ChunkedVector(byte x, byte z)
|
||||
{
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public ChunkedVector(double x, double z)
|
||||
{
|
||||
this((int) Math.round(x), (int) Math.round(z));
|
||||
}
|
||||
|
||||
public ChunkedVector()
|
||||
{
|
||||
this((byte) 0, (byte) 0);
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(int x)
|
||||
{
|
||||
this.x = (byte) x;
|
||||
}
|
||||
|
||||
public int getZ()
|
||||
{
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(int z)
|
||||
{
|
||||
this.z = (byte) z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(obj == null)
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
ChunkedVector other = (ChunkedVector) obj;
|
||||
if(x != other.x)
|
||||
return false;
|
||||
if(z != other.z)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayer implements IGenLayer
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
public interface IGenLayer
|
||||
{
|
@ -0,0 +1,54 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
|
||||
public class IrisInterpolation
|
||||
{
|
||||
public static double lerp(double a, double b, double f)
|
||||
{
|
||||
return a + (f * (b - a));
|
||||
}
|
||||
|
||||
public static double blerp(double a, double b, double c, double d, double tx, double ty)
|
||||
{
|
||||
return lerp(lerp(a, b, tx), lerp(c, d, tx), ty);
|
||||
}
|
||||
|
||||
public static double getBilinearNoise(int x, int z, NoiseProvider n)
|
||||
{
|
||||
int h = 5;
|
||||
int fx = x >> h;
|
||||
int fz = z >> h;
|
||||
int xa = (fx << h) - 2;
|
||||
int za = (fz << h) - 2;
|
||||
int xb = ((fx + 1) << h) + 2;
|
||||
int zb = ((fz + 1) << h) + 2;
|
||||
double na = n.noise(xa, za);
|
||||
double nb = n.noise(xa, zb);
|
||||
double nc = n.noise(xb, za);
|
||||
double nd = n.noise(xb, zb);
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerp(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
|
||||
public static double getBicubicNoise(int x, int z, NoiseProvider n)
|
||||
{
|
||||
int h = 5;
|
||||
int fx = x >> h;
|
||||
int fz = z >> h;
|
||||
int xa = (fx << h);
|
||||
int za = (fz << h);
|
||||
int xb = ((fx + 1) << h);
|
||||
int zb = ((fz + 1) << h);
|
||||
double na = getBilinearNoise(xa, za, n);
|
||||
double nb = getBilinearNoise(xa, zb, n);
|
||||
double nc = getBilinearNoise(xb, za, n);
|
||||
double nd = getBilinearNoise(xb, zb, n);
|
||||
double px = M.rangeScale(0, 1, xa, xb, x);
|
||||
double pz = M.rangeScale(0, 1, za, zb, z);
|
||||
|
||||
return blerp(na, nc, nb, nd, px, pz);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
@ -17,7 +17,7 @@ public class MaxingGenerator
|
||||
|
||||
for(int i = 0; i < possibilities; i++)
|
||||
{
|
||||
gen[i] = new CNG(rng.nextRNG(), 1D, 1).scale(scale);
|
||||
gen[i] = new CNG(rng.nextParallelRNG((i * 15000) + 11285), 1D, 1).scale(scale);
|
||||
gen[i] = factory.apply(gen[i]);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface NoiseProvider
|
||||
{
|
||||
public double noise(double x, double z);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@ -8,10 +8,9 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import ninja.bytecode.iris.atomics.AtomicChunkData;
|
||||
import ninja.bytecode.iris.pop.PopulatorTrees;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.populator.PopulatorTrees;
|
||||
import ninja.bytecode.shuriken.Shuriken;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.execution.ChronoLatch;
|
||||
import ninja.bytecode.shuriken.execution.J;
|
||||
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
|
||||
@ -19,6 +18,7 @@ import ninja.bytecode.shuriken.execution.TaskExecutor.TaskResult;
|
||||
import ninja.bytecode.shuriken.format.F;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
import ninja.bytecode.shuriken.math.RollingSequence;
|
||||
import ninja.bytecode.shuriken.reaction.O;
|
||||
|
||||
public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
@ -69,6 +69,12 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
}, 20, 5);
|
||||
}
|
||||
|
||||
public void generateFullColumn(int a, int b, int c, int d, BiomeGrid g, ChunkPlan p)
|
||||
{
|
||||
g.setBiome(c, d, genColumn(a, b, c, d, p));
|
||||
decorateColumn(a, b, c, d, p);
|
||||
}
|
||||
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
|
||||
{
|
||||
this.world = world;
|
||||
@ -84,7 +90,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
}
|
||||
|
||||
tg = Iris.genPool.startWork();
|
||||
|
||||
O<ChunkPlan> plan = new O<ChunkPlan>();
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
wx = (x * 16) + i;
|
||||
@ -96,13 +102,13 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
int b = wz;
|
||||
int c = i;
|
||||
int d = j;
|
||||
tg.queue(() -> biome.setBiome(c, d, genColumn(a, b, c, d)));
|
||||
tg.queue(() -> generateFullColumn(a, b, c, d, biome, plan.get()));
|
||||
}
|
||||
}
|
||||
|
||||
onInitChunk(world, x, z, random);
|
||||
plan.set(onInitChunk(world, x, z, random));
|
||||
TaskResult r = tg.execute();
|
||||
onPostChunk(world, x, z, random, data);
|
||||
onPostChunk(world, x, z, random, data, plan.get());
|
||||
rs.put(r.timeElapsed);
|
||||
Shuriken.profiler.stop("chunkgen-" + world.getName());
|
||||
cg++;
|
||||
@ -129,11 +135,13 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
|
||||
public abstract void onInit(World world, Random random);
|
||||
|
||||
public abstract void onInitChunk(World world, int x, int z, Random random);
|
||||
public abstract ChunkPlan onInitChunk(World world, int x, int z, Random random);
|
||||
|
||||
public abstract GList<Runnable> onPostChunk(World world, int x, int z, Random random, AtomicChunkData data2);
|
||||
public abstract void onPostChunk(World world, int x, int z, Random random, AtomicChunkData data, ChunkPlan plan);
|
||||
|
||||
public abstract Biome genColumn(int wx, int wz, int x, int z);
|
||||
public abstract Biome genColumn(int wx, int wz, int x, int z, ChunkPlan plan);
|
||||
|
||||
public abstract void decorateColumn(int wx, int wz, int x, int z, ChunkPlan plan);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected void setBlock(int x, int y, int z, Material b)
|
@ -1,4 +1,4 @@
|
||||
package ninja.bytecode.iris;
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
public enum PerformanceMode
|
||||
{
|
@ -27,7 +27,7 @@ public class PolygonGenerator
|
||||
|
||||
for(int i = 0; i < bits; i++)
|
||||
{
|
||||
gen[i] = new CNG(rng.nextRNG(), 1D, 1).scale(scale);
|
||||
gen[i] = new CNG(rng.nextParallelRNG(2118 + (i * 3305)), 1D, 1).scale(scale);
|
||||
gen[i] = factory.apply(gen[i]);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import org.bukkit.block.Biome;
|
||||
import net.minecraft.server.v1_12_R1.BiomeBase;
|
||||
import net.minecraft.server.v1_12_R1.Block;
|
||||
import net.minecraft.server.v1_12_R1.IBlockData;
|
||||
import ninja.bytecode.iris.MB;
|
||||
import ninja.bytecode.shuriken.format.F;
|
||||
|
||||
public class RealBiome
|
||||
|
Loading…
x
Reference in New Issue
Block a user