mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Max biomes
This commit is contained in:
parent
cecbad2eb9
commit
a82ba6503f
@ -5,31 +5,27 @@ import java.io.File;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import lombok.Data;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import ninja.bytecode.iris.object.Dispersion;
|
|
||||||
import ninja.bytecode.iris.object.IrisBiome;
|
import ninja.bytecode.iris.object.IrisBiome;
|
||||||
import ninja.bytecode.iris.object.IrisBiomePaletteLayer;
|
|
||||||
import ninja.bytecode.iris.object.IrisDimension;
|
import ninja.bytecode.iris.object.IrisDimension;
|
||||||
|
import ninja.bytecode.iris.object.IrisRegion;
|
||||||
import ninja.bytecode.iris.util.IO;
|
import ninja.bytecode.iris.util.IO;
|
||||||
import ninja.bytecode.iris.util.JSONObject;
|
|
||||||
import ninja.bytecode.iris.util.ResourceLoader;
|
import ninja.bytecode.iris.util.ResourceLoader;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class IrisDataManager
|
public class IrisDataManager
|
||||||
{
|
{
|
||||||
private File dataFolder;
|
private File dataFolder;
|
||||||
private File packs;
|
private File packs;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private ResourceLoader<IrisBiome> biomeLoader;
|
private ResourceLoader<IrisBiome> biomeLoader;
|
||||||
|
private ResourceLoader<IrisRegion> regionLoader;
|
||||||
@Getter
|
|
||||||
private ResourceLoader<IrisDimension> dimensionLoader;
|
private ResourceLoader<IrisDimension> dimensionLoader;
|
||||||
|
|
||||||
public void hotloaded()
|
public void hotloaded()
|
||||||
{
|
{
|
||||||
packs.mkdirs();
|
packs.mkdirs();
|
||||||
|
this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class);
|
||||||
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
|
this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class);
|
||||||
this.dimensionLoader = new ResourceLoader<>(packs, "dimensions", "Dimension", IrisDimension.class);
|
this.dimensionLoader = new ResourceLoader<>(packs, "dimensions", "Dimension", IrisDimension.class);
|
||||||
writeExamples();
|
writeExamples();
|
||||||
@ -46,32 +42,6 @@ public class IrisDataManager
|
|||||||
{
|
{
|
||||||
File examples = new File(dataFolder, "example");
|
File examples = new File(dataFolder, "example");
|
||||||
examples.mkdirs();
|
examples.mkdirs();
|
||||||
|
|
||||||
IrisBiome biome = new IrisBiome();
|
|
||||||
biome.getLayers().clear();
|
|
||||||
IrisBiomePaletteLayer grass = new IrisBiomePaletteLayer();
|
|
||||||
grass.add("GRASS_BLOCK");
|
|
||||||
grass.setDispersion(Dispersion.SCATTER);
|
|
||||||
grass.setMinHeight(1);
|
|
||||||
grass.setMaxHeight(1);
|
|
||||||
IrisBiomePaletteLayer dirt = new IrisBiomePaletteLayer();
|
|
||||||
grass.add("DIRT");
|
|
||||||
grass.setDispersion(Dispersion.SCATTER);
|
|
||||||
grass.setMinHeight(1);
|
|
||||||
grass.setMaxHeight(2);
|
|
||||||
IrisBiomePaletteLayer dirtThick = new IrisBiomePaletteLayer();
|
|
||||||
grass.add("DIRT");
|
|
||||||
grass.add("COARSE_DIRT");
|
|
||||||
grass.setDispersion(Dispersion.WISPY);
|
|
||||||
grass.setMinHeight(1);
|
|
||||||
grass.setMaxHeight(3);
|
|
||||||
|
|
||||||
biome.getLayers().add(dirtThick);
|
|
||||||
biome.getLayers().add(dirt);
|
|
||||||
biome.getLayers().add(grass);
|
|
||||||
|
|
||||||
IrisDimension dim = new IrisDimension();
|
|
||||||
dim.getBiomes().add("a_biome");
|
|
||||||
String biomes = "";
|
String biomes = "";
|
||||||
String envs = "";
|
String envs = "";
|
||||||
|
|
||||||
@ -91,14 +61,11 @@ public class IrisDataManager
|
|||||||
new File(examples, "example-pack/dimensions").mkdirs();
|
new File(examples, "example-pack/dimensions").mkdirs();
|
||||||
IO.writeAll(new File(examples, "biome-list.txt"), biomes);
|
IO.writeAll(new File(examples, "biome-list.txt"), biomes);
|
||||||
IO.writeAll(new File(examples, "environment-list.txt"), envs);
|
IO.writeAll(new File(examples, "environment-list.txt"), envs);
|
||||||
IO.writeAll(new File(examples, "example-pack/biomes/a_biome.json"), new JSONObject(new Gson().toJson(biome)).toString(4));
|
|
||||||
IO.writeAll(new File(examples, "example-pack/dimensions/a_dimension.json"), new JSONObject(new Gson().toJson(dim)).toString(4));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(Throwable e)
|
catch(Throwable e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,6 +15,7 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import ninja.bytecode.iris.layer.GenLayerBiome;
|
import ninja.bytecode.iris.layer.GenLayerBiome;
|
||||||
import ninja.bytecode.iris.object.IrisBiome;
|
import ninja.bytecode.iris.object.IrisBiome;
|
||||||
import ninja.bytecode.iris.object.IrisDimension;
|
import ninja.bytecode.iris.object.IrisDimension;
|
||||||
|
import ninja.bytecode.iris.object.IrisRegion;
|
||||||
import ninja.bytecode.iris.util.BiomeResult;
|
import ninja.bytecode.iris.util.BiomeResult;
|
||||||
import ninja.bytecode.iris.util.CNG;
|
import ninja.bytecode.iris.util.CNG;
|
||||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||||
@ -25,6 +26,7 @@ public class IrisGenerator extends ChunkGenerator
|
|||||||
{
|
{
|
||||||
// TODO REMOVE OR FIND A BETTER PLACE
|
// TODO REMOVE OR FIND A BETTER PLACE
|
||||||
private BlockData STONE = Material.STONE.createBlockData();
|
private BlockData STONE = Material.STONE.createBlockData();
|
||||||
|
private BlockData WATER = Material.WATER.createBlockData();
|
||||||
private String dimensionName;
|
private String dimensionName;
|
||||||
private GenLayerBiome glBiome;
|
private GenLayerBiome glBiome;
|
||||||
private CNG terrainNoise;
|
private CNG terrainNoise;
|
||||||
@ -64,44 +66,74 @@ public class IrisGenerator extends ChunkGenerator
|
|||||||
{
|
{
|
||||||
Iris.hotloader.check();
|
Iris.hotloader.check();
|
||||||
int i, j, k, height, depth;
|
int i, j, k, height, depth;
|
||||||
double wx, wz, rx, rz, heightLow, heightHigh, heightExponent;
|
double wx, wz, rx, rz, noise, ox, oz;
|
||||||
|
boolean underwater;
|
||||||
|
BlockData block;
|
||||||
int fluidHeight = getDimension().getFluidHeight();
|
int fluidHeight = getDimension().getFluidHeight();
|
||||||
BiomeResult biomeResult;
|
BiomeResult biomeResult;
|
||||||
IrisBiome biome;
|
IrisBiome biome;
|
||||||
|
IrisRegion region;
|
||||||
RNG random = new RNG(world.getSeed());
|
RNG random = new RNG(world.getSeed());
|
||||||
onInit(world, random.nextParallelRNG(0));
|
onInit(world, random.nextParallelRNG(0));
|
||||||
ChunkData data = Bukkit.createChunkData(world);
|
ChunkData data = Bukkit.createChunkData(world);
|
||||||
|
|
||||||
for(i = 0; i < 16; i++)
|
for(i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
rx = (x * 16) + i;
|
|
||||||
wx = ((double) (x * 16) + i) / getDimension().getTerrainZoom();
|
|
||||||
for(j = 0; j < 16; j++)
|
for(j = 0; j < 16; j++)
|
||||||
{
|
{
|
||||||
|
rx = (x * 16) + i;
|
||||||
rz = (z * 16) + j;
|
rz = (z * 16) + j;
|
||||||
wz = ((double) (z * 16) + j) / getDimension().getTerrainZoom();
|
ox = (getDimension().cosRotate() * rx) + (-getDimension().sinRotate() * rz) + getDimension().getCoordFracture(random, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz);
|
||||||
|
oz = (getDimension().sinRotate() * rx) + (getDimension().cosRotate() * rz) + getDimension().getCoordFracture(random, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz);
|
||||||
|
wx = (double) (ox) / getDimension().getTerrainZoom();
|
||||||
|
wz = (double) (oz) / getDimension().getTerrainZoom();
|
||||||
depth = 0;
|
depth = 0;
|
||||||
biomeResult = glBiome.generateData(wx, wz);
|
region = glBiome.getRegion(wx, wz);
|
||||||
|
biomeResult = glBiome.generateRegionData(wx, wz, region);
|
||||||
biome = biomeResult.getBiome();
|
biome = biomeResult.getBiome();
|
||||||
heightLow = interpolate(rx, rz, (b) -> b.getLowHeight());
|
double lo = interpolateHeight(ox, oz, (b) -> b.getLowHeight());
|
||||||
heightHigh = interpolate(rx, rz, (b) -> b.getHighHeight());
|
double hi = interpolateSurface(ox, oz, (b) -> b.getHighHeight());
|
||||||
heightExponent = interpolate(rx, rz, (b) -> b.getHeightExponent());
|
noise = lo + (terrainNoise.fitDoubleD(0, hi - lo, wx, wz));
|
||||||
height = (int) Math.round(terrainNoise.fitDoubleExponent(heightLow, heightHigh, heightExponent, wx, wz)) + fluidHeight;
|
height = (int) Math.round(noise) + fluidHeight;
|
||||||
|
|
||||||
|
// Remove Land biome surfaces from underwater
|
||||||
|
if(height < fluidHeight + 1)
|
||||||
|
{
|
||||||
|
if(biome.isLand())
|
||||||
|
{
|
||||||
|
biome = glBiome.generateShoreData(wx, wz, region).getBiome();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KList<BlockData> layers = biome.generateLayers(wx, wz, random, height);
|
KList<BlockData> layers = biome.generateLayers(wx, wz, random, height);
|
||||||
|
|
||||||
for(k = Math.max(height, fluidHeight); k >= 0; k--)
|
for(k = Math.max(height, fluidHeight); k >= 0; k--)
|
||||||
{
|
{
|
||||||
|
underwater = k > height && k <= fluidHeight;
|
||||||
biomeGrid.setBiome(i, k, j, biome.getDerivative());
|
biomeGrid.setBiome(i, k, j, biome.getDerivative());
|
||||||
data.setBlock(i, k, j, layers.hasIndex(depth) ? layers.get(depth) : STONE);
|
|
||||||
|
if(underwater)
|
||||||
|
{
|
||||||
|
block = WATER;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
block = layers.hasIndex(depth) ? layers.get(depth) : STONE;
|
||||||
depth++;
|
depth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.setBlock(i, k, j, block);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Iris.verbose("Generated " + x + " " + z);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double interpolate(double rx, double rz, Function<IrisBiome, Double> property)
|
public double interpolateHeight(double rx, double rz, Function<IrisBiome, Double> property)
|
||||||
{
|
{
|
||||||
return IrisInterpolation.getNoise(getDimension().getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationScale(), (xx, zz) ->
|
return IrisInterpolation.getNoise(getDimension().getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationScale(), (xx, zz) ->
|
||||||
{
|
{
|
||||||
@ -110,6 +142,15 @@ public class IrisGenerator extends ChunkGenerator
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double interpolateSurface(double rx, double rz, Function<IrisBiome, Double> property)
|
||||||
|
{
|
||||||
|
return IrisInterpolation.getNoise(getDimension().getInterpolationSurfaceFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationSurfaceScale(), (xx, zz) ->
|
||||||
|
{
|
||||||
|
BiomeResult neighborResult = glBiome.generateData(xx / getDimension().getTerrainZoom(), zz / getDimension().getTerrainZoom());
|
||||||
|
return property.apply(neighborResult.getBiome());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||||
{
|
{
|
||||||
|
@ -1,31 +1,141 @@
|
|||||||
package ninja.bytecode.iris.layer;
|
package ninja.bytecode.iris.layer;
|
||||||
|
|
||||||
|
import ninja.bytecode.iris.Iris;
|
||||||
import ninja.bytecode.iris.IrisGenerator;
|
import ninja.bytecode.iris.IrisGenerator;
|
||||||
|
import ninja.bytecode.iris.object.InferredType;
|
||||||
import ninja.bytecode.iris.object.IrisBiome;
|
import ninja.bytecode.iris.object.IrisBiome;
|
||||||
|
import ninja.bytecode.iris.object.IrisRegion;
|
||||||
import ninja.bytecode.iris.util.BiomeResult;
|
import ninja.bytecode.iris.util.BiomeResult;
|
||||||
import ninja.bytecode.iris.util.CellGenerator2D;
|
import ninja.bytecode.iris.util.CellGenerator;
|
||||||
import ninja.bytecode.iris.util.GenLayer;
|
import ninja.bytecode.iris.util.GenLayer;
|
||||||
import ninja.bytecode.iris.util.KList;
|
import ninja.bytecode.iris.util.KList;
|
||||||
import ninja.bytecode.iris.util.RNG;
|
import ninja.bytecode.iris.util.RNG;
|
||||||
|
|
||||||
public class GenLayerBiome extends GenLayer
|
public class GenLayerBiome extends GenLayer
|
||||||
{
|
{
|
||||||
private CellGenerator2D cells;
|
private CellGenerator region;
|
||||||
|
private CellGenerator bridge;
|
||||||
|
private CellGenerator land;
|
||||||
|
private CellGenerator shore;
|
||||||
|
private CellGenerator sea;
|
||||||
|
|
||||||
public GenLayerBiome(IrisGenerator iris, RNG rng)
|
public GenLayerBiome(IrisGenerator iris, RNG rng)
|
||||||
{
|
{
|
||||||
super(iris, rng);
|
super(iris, rng);
|
||||||
cells = new CellGenerator2D(rng.nextParallelRNG(2045662));
|
region = new CellGenerator(rng.nextParallelRNG(1188519));
|
||||||
|
bridge = new CellGenerator(rng.nextParallelRNG(1541462));
|
||||||
|
land = new CellGenerator(rng.nextParallelRNG(9045162));
|
||||||
|
shore = new CellGenerator(rng.nextParallelRNG(2342812));
|
||||||
|
sea = new CellGenerator(rng.nextParallelRNG(6135621));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getBiomes()
|
public IrisRegion getRegion(double bx, double bz)
|
||||||
{
|
{
|
||||||
return iris.getDimension().buildBiomeList();
|
region.setShuffle(32);
|
||||||
|
region.setCellScale(0.33 / iris.getDimension().getRegionZoom());
|
||||||
|
double x = bx / iris.getDimension().getBiomeZoom();
|
||||||
|
double z = bz / iris.getDimension().getBiomeZoom();
|
||||||
|
String regionId = iris.getDimension().getRegions().get(region.getIndex(x, z, iris.getDimension().getRegions().size()));
|
||||||
|
|
||||||
|
return Iris.data.getRegionLoader().load(regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult generateData(double x, double z)
|
public BiomeResult generateData(double bx, double bz)
|
||||||
{
|
{
|
||||||
return new BiomeResult(getBiomes().get(cells.getIndex(x / iris.getDimension().getBiomeZoom(), z / iris.getDimension().getBiomeZoom(), getBiomes().size())), cells.getDistance(x / iris.getDimension().getBiomeZoom(), z / iris.getDimension().getBiomeZoom()));
|
return generateRegionData(bx, bz, getRegion(bx, bz));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult generateRegionData(double bx, double bz, IrisRegion regionData)
|
||||||
|
{
|
||||||
|
bridge.setShuffle(32);
|
||||||
|
bridge.setCellScale(0.33 / iris.getDimension().getContinentZoom());
|
||||||
|
double x = bx / iris.getDimension().getBiomeZoom();
|
||||||
|
double z = bz / iris.getDimension().getBiomeZoom();
|
||||||
|
|
||||||
|
// Beach
|
||||||
|
if(bridge.getDistance(x, z) < regionData.getShoreRatio())
|
||||||
|
{
|
||||||
|
return generateShoreData(bx, bz, regionData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sea
|
||||||
|
else if(bridge.getIndex(x, z, 5) == 1)
|
||||||
|
{
|
||||||
|
return generateSeaData(bx, bz, regionData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Land
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return generateLandData(bx, bz, regionData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CellGenerator cell, KList<String> biomes, InferredType inferredType)
|
||||||
|
{
|
||||||
|
double x = bx / iris.getDimension().getBiomeZoom();
|
||||||
|
double z = bz / iris.getDimension().getBiomeZoom();
|
||||||
|
IrisBiome biome = Iris.data.getBiomeLoader().load(biomes.get(sea.getIndex(x, z, biomes.size())));
|
||||||
|
biome.setInferredType(inferredType);
|
||||||
|
|
||||||
|
return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult generateSeaData(double bx, double bz, IrisRegion regionData)
|
||||||
|
{
|
||||||
|
sea.setShuffle(32);
|
||||||
|
sea.setCellScale(0.56 / iris.getDimension().getSeaZoom());
|
||||||
|
return generateBiomeData(bx, bz, regionData, sea, regionData.getSeaBiomes(), InferredType.SEA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult generateLandData(double bx, double bz, IrisRegion regionData)
|
||||||
|
{
|
||||||
|
land.setShuffle(32);
|
||||||
|
land.setCellScale(0.6 / iris.getDimension().getLandZoom());
|
||||||
|
return generateBiomeData(bx, bz, regionData, land, regionData.getLandBiomes(), InferredType.LAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult generateShoreData(double bx, double bz, IrisRegion regionData)
|
||||||
|
{
|
||||||
|
shore.setShuffle(32);
|
||||||
|
shore.setCellScale(0.8 / iris.getDimension().getShoreZoom());
|
||||||
|
return generateBiomeData(bx, bz, regionData, shore, regionData.getShoreBiomes(), InferredType.SHORE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent)
|
||||||
|
{
|
||||||
|
return implode(bx, bz, regionData, parentCell, parent, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent, int hits)
|
||||||
|
{
|
||||||
|
if(hits > 9)
|
||||||
|
{
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
double x = bx / iris.getDimension().getBiomeZoom();
|
||||||
|
double z = bz / iris.getDimension().getBiomeZoom();
|
||||||
|
if(parent.getDistance() > regionData.getBiomeImplosionRatio())
|
||||||
|
{
|
||||||
|
if(!parent.getBiome().getChildren().isEmpty())
|
||||||
|
{
|
||||||
|
CellGenerator childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor());
|
||||||
|
int r = childCell.getIndex(x, z, parent.getBiome().getChildren().size() + 1);
|
||||||
|
|
||||||
|
if(r == parent.getBiome().getChildren().size())
|
||||||
|
{
|
||||||
|
return new BiomeResult(parent.getBiome(), childCell.getDistance(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisBiome biome = Iris.data.getBiomeLoader().load(parent.getBiome().getChildren().get(r));
|
||||||
|
biome.setInferredType(parent.getBiome().getInferredType());
|
||||||
|
|
||||||
|
return implode(bx, bz, regionData, childCell, new BiomeResult(biome, childCell.getDistance(x, z)), hits + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package ninja.bytecode.iris.object;
|
||||||
|
|
||||||
|
public enum InferredType
|
||||||
|
{
|
||||||
|
SHORE,
|
||||||
|
LAND,
|
||||||
|
SEA
|
||||||
|
}
|
@ -7,6 +7,7 @@ import org.bukkit.block.data.BlockData;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import ninja.bytecode.iris.util.CNG;
|
import ninja.bytecode.iris.util.CNG;
|
||||||
|
import ninja.bytecode.iris.util.CellGenerator;
|
||||||
import ninja.bytecode.iris.util.KList;
|
import ninja.bytecode.iris.util.KList;
|
||||||
import ninja.bytecode.iris.util.RNG;
|
import ninja.bytecode.iris.util.RNG;
|
||||||
|
|
||||||
@ -17,12 +18,27 @@ public class IrisBiome
|
|||||||
private Biome derivative = Biome.THE_VOID;
|
private Biome derivative = Biome.THE_VOID;
|
||||||
private double highHeight = 7;
|
private double highHeight = 7;
|
||||||
private double lowHeight = 1;
|
private double lowHeight = 1;
|
||||||
private double heightExponent = 1;
|
private double childShrinkFactor = 1.5;
|
||||||
|
private KList<String> children = new KList<>();
|
||||||
private KList<IrisBiomePaletteLayer> layers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
|
private KList<IrisBiomePaletteLayer> layers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
|
||||||
|
private KList<IrisBiomeDecorator> decorators = new KList<IrisBiomeDecorator>();
|
||||||
|
|
||||||
|
private transient CellGenerator childrenCell;
|
||||||
|
private transient InferredType inferredType;
|
||||||
private transient KList<CNG> layerHeightGenerators;
|
private transient KList<CNG> layerHeightGenerators;
|
||||||
private transient KList<CNG> layerSurfaceGenerators;
|
private transient KList<CNG> layerSurfaceGenerators;
|
||||||
|
|
||||||
|
public CellGenerator getChildrenGenerator(RNG random, int sig, double scale)
|
||||||
|
{
|
||||||
|
if(childrenCell == null)
|
||||||
|
{
|
||||||
|
childrenCell = new CellGenerator(random.nextParallelRNG(sig * 213));
|
||||||
|
childrenCell.setCellScale(scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return childrenCell;
|
||||||
|
}
|
||||||
|
|
||||||
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth)
|
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth)
|
||||||
{
|
{
|
||||||
KList<BlockData> data = new KList<>();
|
KList<BlockData> data = new KList<>();
|
||||||
@ -60,15 +76,11 @@ public class IrisBiome
|
|||||||
}
|
}
|
||||||
|
|
||||||
public KList<CNG> getLayerSurfaceGenerators(RNG rng)
|
public KList<CNG> getLayerSurfaceGenerators(RNG rng)
|
||||||
{
|
|
||||||
synchronized(this)
|
|
||||||
{
|
{
|
||||||
if(layerSurfaceGenerators == null)
|
if(layerSurfaceGenerators == null)
|
||||||
{
|
{
|
||||||
layerSurfaceGenerators = new KList<>();
|
layerSurfaceGenerators = new KList<>();
|
||||||
|
|
||||||
synchronized(layerSurfaceGenerators)
|
|
||||||
{
|
|
||||||
int m = 91235;
|
int m = 91235;
|
||||||
|
|
||||||
for(IrisBiomePaletteLayer i : getLayers())
|
for(IrisBiomePaletteLayer i : getLayers())
|
||||||
@ -76,22 +88,16 @@ public class IrisBiome
|
|||||||
layerSurfaceGenerators.add(i.getGenerator(rng.nextParallelRNG((m += 3) * m * m * m)));
|
layerSurfaceGenerators.add(i.getGenerator(rng.nextParallelRNG((m += 3) * m * m * m)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return layerSurfaceGenerators;
|
return layerSurfaceGenerators;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<CNG> getLayerHeightGenerators(RNG rng)
|
public KList<CNG> getLayerHeightGenerators(RNG rng)
|
||||||
{
|
|
||||||
synchronized(this)
|
|
||||||
{
|
{
|
||||||
if(layerHeightGenerators == null)
|
if(layerHeightGenerators == null)
|
||||||
{
|
{
|
||||||
layerHeightGenerators = new KList<>();
|
layerHeightGenerators = new KList<>();
|
||||||
|
|
||||||
synchronized(layerHeightGenerators)
|
|
||||||
{
|
|
||||||
int m = 7235;
|
int m = 7235;
|
||||||
|
|
||||||
for(IrisBiomePaletteLayer i : getLayers())
|
for(IrisBiomePaletteLayer i : getLayers())
|
||||||
@ -99,9 +105,22 @@ public class IrisBiome
|
|||||||
layerHeightGenerators.add(i.getGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
layerHeightGenerators.add(i.getGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return layerHeightGenerators;
|
return layerHeightGenerators;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLand()
|
||||||
|
{
|
||||||
|
return inferredType.equals(InferredType.LAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSea()
|
||||||
|
{
|
||||||
|
return inferredType.equals(InferredType.SEA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShore()
|
||||||
|
{
|
||||||
|
return inferredType.equals(InferredType.SHORE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
package ninja.bytecode.iris.object;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import ninja.bytecode.iris.util.CNG;
|
||||||
|
import ninja.bytecode.iris.util.KList;
|
||||||
|
import ninja.bytecode.iris.util.KMap;
|
||||||
|
import ninja.bytecode.iris.util.RNG;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IrisBiomeDecorator
|
||||||
|
{
|
||||||
|
private Dispersion dispersion = Dispersion.ZEBRA;
|
||||||
|
private int iterations = 5;
|
||||||
|
private double zoom = 1;
|
||||||
|
private KList<String> palette = new KList<String>().qadd("GRASS");
|
||||||
|
|
||||||
|
private transient KMap<Long, CNG> layerGenerators;
|
||||||
|
private transient KList<BlockData> blockData;
|
||||||
|
|
||||||
|
public CNG getGenerator(RNG rng)
|
||||||
|
{
|
||||||
|
long key = rng.nextParallelRNG(1).nextLong();
|
||||||
|
|
||||||
|
if(layerGenerators == null)
|
||||||
|
{
|
||||||
|
layerGenerators = new KMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!layerGenerators.containsKey(key))
|
||||||
|
{
|
||||||
|
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(iterations + getBlockData().size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return layerGenerators.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public KList<String> add(String b)
|
||||||
|
{
|
||||||
|
palette.add(b);
|
||||||
|
|
||||||
|
return palette;
|
||||||
|
}
|
||||||
|
|
||||||
|
public KList<BlockData> getBlockData()
|
||||||
|
{
|
||||||
|
if(blockData == null)
|
||||||
|
{
|
||||||
|
blockData = new KList<>();
|
||||||
|
for(String i : palette)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Material m = Material.valueOf(i);
|
||||||
|
|
||||||
|
if(m != null)
|
||||||
|
{
|
||||||
|
blockData.add(m.createBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return blockData;
|
||||||
|
}
|
||||||
|
}
|
@ -22,8 +22,6 @@ public class IrisBiomePaletteLayer
|
|||||||
private transient KList<BlockData> blockData;
|
private transient KList<BlockData> blockData;
|
||||||
|
|
||||||
public CNG getGenerator(RNG rng)
|
public CNG getGenerator(RNG rng)
|
||||||
{
|
|
||||||
synchronized(this)
|
|
||||||
{
|
{
|
||||||
long key = rng.nextParallelRNG(1).nextLong();
|
long key = rng.nextParallelRNG(1).nextLong();
|
||||||
|
|
||||||
@ -33,16 +31,12 @@ public class IrisBiomePaletteLayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!layerGenerators.containsKey(key))
|
if(!layerGenerators.containsKey(key))
|
||||||
{
|
|
||||||
synchronized(layerGenerators)
|
|
||||||
{
|
{
|
||||||
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size())));
|
layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size())));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return layerGenerators.get(key);
|
return layerGenerators.get(key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public KList<String> add(String b)
|
public KList<String> add(String b)
|
||||||
{
|
{
|
||||||
@ -52,14 +46,10 @@ public class IrisBiomePaletteLayer
|
|||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getBlockData()
|
public KList<BlockData> getBlockData()
|
||||||
{
|
|
||||||
synchronized(this)
|
|
||||||
{
|
{
|
||||||
if(blockData == null)
|
if(blockData == null)
|
||||||
{
|
{
|
||||||
blockData = new KList<>();
|
blockData = new KList<>();
|
||||||
synchronized(blockData)
|
|
||||||
{
|
|
||||||
for(String i : palette)
|
for(String i : palette)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -77,8 +67,6 @@ public class IrisBiomePaletteLayer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return blockData;
|
return blockData;
|
||||||
}
|
}
|
||||||
|
@ -3,46 +3,77 @@ package ninja.bytecode.iris.object;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import ninja.bytecode.iris.Iris;
|
import ninja.bytecode.iris.util.CNG;
|
||||||
import ninja.bytecode.iris.util.KList;
|
import ninja.bytecode.iris.util.KList;
|
||||||
|
import ninja.bytecode.iris.util.RNG;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class IrisDimension
|
public class IrisDimension
|
||||||
{
|
{
|
||||||
private String name = "A Dimension";
|
private String name = "A Dimension";
|
||||||
private InterpolationMethod interpolationFunction = InterpolationMethod.BILINEAR;
|
private InterpolationMethod interpolationFunction = InterpolationMethod.BICUBIC;
|
||||||
private double interpolationScale = 5.6;
|
private double interpolationScale = 63;
|
||||||
|
private InterpolationMethod interpolationSurfaceFunction = InterpolationMethod.BICUBIC;
|
||||||
|
private double interpolationSurfaceScale = 4;
|
||||||
private Environment environment = Environment.NORMAL;
|
private Environment environment = Environment.NORMAL;
|
||||||
private KList<String> biomes = new KList<>();
|
private KList<String> regions = new KList<>();
|
||||||
private int fluidHeight = 127;
|
private int fluidHeight = 127;
|
||||||
private double biomeZoom = 5D;
|
private double biomeZoom = 5D;
|
||||||
private double terrainZoom = 2D;
|
private double terrainZoom = 2D;
|
||||||
|
private double dimensionAngleDeg = 0;
|
||||||
private double roughnessZoom = 2D;
|
private double roughnessZoom = 2D;
|
||||||
private int roughnessHeight = 3;
|
private int roughnessHeight = 3;
|
||||||
private transient KList<IrisBiome> biomeCache;
|
private double coordFractureDistance = 20;
|
||||||
|
private double coordFractureZoom = 8;
|
||||||
|
private double landZoom = 1;
|
||||||
|
private double shoreZoom = 1;
|
||||||
|
private double seaZoom = 1;
|
||||||
|
private double continentZoom = 1;
|
||||||
|
private double regionZoom = 1;
|
||||||
|
|
||||||
public KList<IrisBiome> buildBiomeList()
|
private transient CNG coordFracture;
|
||||||
{
|
private transient Double sinr;
|
||||||
if(biomeCache == null)
|
private transient Double cosr;
|
||||||
{
|
private transient Double rad;
|
||||||
synchronized(this)
|
|
||||||
{
|
|
||||||
biomeCache = new KList<>();
|
|
||||||
|
|
||||||
synchronized(biomeCache)
|
public CNG getCoordFracture(RNG rng, int signature)
|
||||||
{
|
{
|
||||||
for(String i : biomes)
|
if(coordFracture == null)
|
||||||
{
|
{
|
||||||
IrisBiome biome = Iris.data.getBiomeLoader().load(i);
|
coordFracture = CNG.signature(rng.nextParallelRNG(signature));
|
||||||
if(biome != null)
|
coordFracture.scale(0.012 / coordFractureZoom);
|
||||||
{
|
|
||||||
biomeCache.add(biome);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return biomeCache;
|
return coordFracture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDimensionAngle()
|
||||||
|
{
|
||||||
|
if(rad == null)
|
||||||
|
{
|
||||||
|
rad = Math.toRadians(dimensionAngleDeg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rad;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double sinRotate()
|
||||||
|
{
|
||||||
|
if(sinr == null)
|
||||||
|
{
|
||||||
|
sinr = Math.sin(getDimensionAngle());
|
||||||
|
}
|
||||||
|
|
||||||
|
return sinr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double cosRotate()
|
||||||
|
{
|
||||||
|
if(cosr == null)
|
||||||
|
{
|
||||||
|
cosr = Math.cos(getDimensionAngle());
|
||||||
|
}
|
||||||
|
|
||||||
|
return cosr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
src/main/java/ninja/bytecode/iris/object/IrisRegion.java
Normal file
15
src/main/java/ninja/bytecode/iris/object/IrisRegion.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package ninja.bytecode.iris.object;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import ninja.bytecode.iris.util.KList;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IrisRegion
|
||||||
|
{
|
||||||
|
private String name = "A Region";
|
||||||
|
private double shoreRatio = 0.13;
|
||||||
|
private double biomeImplosionRatio = 0.4;
|
||||||
|
private KList<String> landBiomes = new KList<>();
|
||||||
|
private KList<String> seaBiomes = new KList<>();
|
||||||
|
private KList<String> shoreBiomes = new KList<>();
|
||||||
|
}
|
@ -166,6 +166,18 @@ public class CNG
|
|||||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double fitDoubleD(double min, double max, double... dim)
|
||||||
|
{
|
||||||
|
if(min == max)
|
||||||
|
{
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
double noise = noise(dim);
|
||||||
|
|
||||||
|
return IrisInterpolation.lerp(min, max, noise);
|
||||||
|
}
|
||||||
|
|
||||||
public int fitDoubleExponent(double min, double max, double exponent, double... dim)
|
public int fitDoubleExponent(double min, double max, double exponent, double... dim)
|
||||||
{
|
{
|
||||||
if(min == max)
|
if(min == max)
|
||||||
|
@ -6,7 +6,7 @@ import ninja.bytecode.iris.util.FastNoise.CellularDistanceFunction;
|
|||||||
import ninja.bytecode.iris.util.FastNoise.CellularReturnType;
|
import ninja.bytecode.iris.util.FastNoise.CellularReturnType;
|
||||||
import ninja.bytecode.iris.util.FastNoise.NoiseType;
|
import ninja.bytecode.iris.util.FastNoise.NoiseType;
|
||||||
|
|
||||||
public class CellGenerator2D
|
public class CellGenerator
|
||||||
{
|
{
|
||||||
private FastNoise fn;
|
private FastNoise fn;
|
||||||
private FastNoise fd;
|
private FastNoise fd;
|
||||||
@ -20,7 +20,7 @@ public class CellGenerator2D
|
|||||||
@Setter
|
@Setter
|
||||||
private double shuffle;
|
private double shuffle;
|
||||||
|
|
||||||
public CellGenerator2D(RNG rng)
|
public CellGenerator(RNG rng)
|
||||||
{
|
{
|
||||||
shuffle = 128;
|
shuffle = 128;
|
||||||
cellScale = 0.73;
|
cellScale = 0.73;
|
@ -1,6 +1,7 @@
|
|||||||
package ninja.bytecode.iris.util;
|
package ninja.bytecode.iris.util;
|
||||||
|
|
||||||
import ninja.bytecode.iris.object.InterpolationMethod;
|
import ninja.bytecode.iris.object.InterpolationMethod;
|
||||||
|
import ninja.bytecode.iris.object.IrisDimension;
|
||||||
|
|
||||||
public class IrisInterpolation
|
public class IrisInterpolation
|
||||||
{
|
{
|
||||||
@ -188,26 +189,6 @@ public class IrisInterpolation
|
|||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getNoise(InterpolationMethod method, int x, int z, double rad, NoiseProvider n)
|
|
||||||
{
|
|
||||||
if(method.equals(InterpolationMethod.BILINEAR))
|
|
||||||
{
|
|
||||||
return getBilinearNoise(x, z, rad, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(method.equals(InterpolationMethod.BICUBIC))
|
|
||||||
{
|
|
||||||
return getBicubicNoise(x, z, rad, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if(method.equals(InterpolationMethod.HERMITE))
|
|
||||||
{
|
|
||||||
return getHermiteNoise(x, z, rad, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
return n.noise(x, z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n)
|
public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n)
|
||||||
{
|
{
|
||||||
int fx = (int) Math.floor(x / rad);
|
int fx = (int) Math.floor(x / rad);
|
||||||
@ -240,10 +221,30 @@ public class IrisInterpolation
|
|||||||
n.noise(x3, z1),
|
n.noise(x3, z1),
|
||||||
n.noise(x3, z2),
|
n.noise(x3, z2),
|
||||||
n.noise(x3, z3),
|
n.noise(x3, z3),
|
||||||
px, pz, 0.00001, 0.5);
|
px, pz, 0.0000000001, 0.5);
|
||||||
//@done
|
//@done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getNoise(InterpolationMethod method, int x, int z, double rad, NoiseProvider n)
|
||||||
|
{
|
||||||
|
if(method.equals(InterpolationMethod.BILINEAR))
|
||||||
|
{
|
||||||
|
return getBilinearNoise(x, z, rad, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(method.equals(InterpolationMethod.BICUBIC))
|
||||||
|
{
|
||||||
|
return getBicubicNoise(x, z, rad, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(method.equals(InterpolationMethod.HERMITE))
|
||||||
|
{
|
||||||
|
return getHermiteNoise(x, z, rad, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
return n.noise(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b)
|
public static double rangeScale(double amin, double amax, double bmin, double bmax, double b)
|
||||||
{
|
{
|
||||||
return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));
|
return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user