This commit is contained in:
Daniel Mills 2020-07-26 05:28:22 -04:00
parent f8cb0caa80
commit 5af98c5683
17 changed files with 353 additions and 134 deletions

View File

@ -174,6 +174,9 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
loadQueue.addAll(r.getLandBiomes()); loadQueue.addAll(r.getLandBiomes());
loadQueue.addAll(r.getSeaBiomes()); loadQueue.addAll(r.getSeaBiomes());
loadQueue.addAll(r.getShoreBiomes()); loadQueue.addAll(r.getShoreBiomes());
loadQueue.addAll(r.getCaveBiomes());
loadQueue.addAll(r.getRidgeBiomeKeys());
loadQueue.addAll(r.getSpotBiomeKeys());
} }
} }
@ -245,4 +248,14 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
return res; return res;
} }
public BiomeResult sampleCaveBiome(int x, int y, int z)
{
double wx = getModifiedX(x - y, z + y);
double wz = getModifiedZ(x + y, z - y);
IrisRegion region = glBiome.getRegion(wx, wz);
BiomeResult res = glBiome.generateCaveData(wx, wz, x, z, region);
return res;
}
} }

View File

@ -100,6 +100,12 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
return b == null ? AIR : b; return b == null ? AIR : b;
} }
@Override
public boolean isSolid(int x, int y, int z)
{
return get(x, y, z).getMaterial().isSolid();
}
public AtomicSliver getParallaxSliver(int wx, int wz) public AtomicSliver getParallaxSliver(int wx, int wz)
{ {
getMasterLock().lock("gpc"); getMasterLock().lock("gpc");

View File

@ -16,6 +16,7 @@ import ninja.bytecode.iris.object.IrisRegion;
import ninja.bytecode.iris.object.atomics.AtomicSliver; import ninja.bytecode.iris.object.atomics.AtomicSliver;
import ninja.bytecode.iris.util.BiomeMap; import ninja.bytecode.iris.util.BiomeMap;
import ninja.bytecode.iris.util.BiomeResult; import ninja.bytecode.iris.util.BiomeResult;
import ninja.bytecode.iris.util.CaveResult;
import ninja.bytecode.iris.util.HeightMap; import ninja.bytecode.iris.util.HeightMap;
import ninja.bytecode.iris.util.RNG; import ninja.bytecode.iris.util.RNG;
import ninja.bytecode.shuriken.collections.KList; import ninja.bytecode.shuriken.collections.KList;
@ -26,6 +27,7 @@ import ninja.bytecode.shuriken.math.M;
public abstract class TerrainChunkGenerator extends ParallelChunkGenerator public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
{ {
protected static final BlockData AIR = Material.AIR.createBlockData(); protected static final BlockData AIR = Material.AIR.createBlockData();
protected static final BlockData WEB = Material.COBWEB.createBlockData();
private long lastUpdateRequest = M.ms(); private long lastUpdateRequest = M.ms();
private long lastChunkLoad = M.ms(); private long lastChunkLoad = M.ms();
private GenLayerCave glCave; private GenLayerCave glCave;
@ -98,80 +100,54 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
if(k == height && block.getMaterial().isSolid() && k < fluidHeight && biome.isSea()) if(k == height && block.getMaterial().isSolid() && k < fluidHeight && biome.isSea())
{ {
int j = 0; decorateUnderwater(biome, sliver, wx, k, wz, rx, rz, block);
for(IrisBiomeDecorator i : biome.getDecorators())
{
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
if(d != null)
{
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
if(stack == 1)
{
sliver.set(k + 1, d);
}
else if(k < fluidHeight - stack)
{
for(int l = 0; l < stack; l++)
{
sliver.set(k + l + 1, d);
}
}
break;
}
}
} }
if(k == Math.max(height, fluidHeight) && block.getMaterial().isSolid() && k < 255 && !biome.isSea()) if(k == Math.max(height, fluidHeight) && block.getMaterial().isSolid() && k < 255 && !biome.isSea())
{ {
int j = 0; decorateLand(biome, sliver, wx, k, wz, rx, rz, block);
}
}
for(IrisBiomeDecorator i : biome.getDecorators()) KList<CaveResult> r = glCave.genCaves(rx, rz, x, z, sliver);
for(CaveResult c : r)
{
if(c.getCeiling() <= 0 || c.getFloor() >= 255 || c.getFloor() >= c.getCeiling())
{
continue;
}
IrisBiome caveBiome = sampleCaveBiome(x, 0, z).getBiome();
if(caveBiome.getLoadKey().equals("default"))
{
continue;
}
KList<BlockData> ceilingLayers = caveBiome.generateLayers(wx + c.getCeiling(), wz + c.getCeiling(), masterRandom, (height - c.getCeiling()) - 1);
KList<BlockData> floorLayers = caveBiome.generateLayers(wx - c.getFloor(), wz - c.getFloor(), masterRandom, c.getFloor());
for(int k = c.getFloor(); k <= c.getCeiling(); k++)
{
if(k >= height || k < 0 || k > 255)
{ {
if(i.getPartOf().equals(DecorationPart.SHORE_LINE) && !touchesSea(rx, rz)) continue;
{
continue;
}
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
if(d != null)
{
if(d instanceof Bisected && k < 254)
{
Bisected t = ((Bisected) d.clone());
t.setHalf(Half.TOP);
Bisected b = ((Bisected) d.clone());
b.setHalf(Half.BOTTOM);
sliver.set(k + 1, b);
sliver.set(k + 2, t);
}
else
{
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
if(stack == 1)
{
sliver.set(k + 1, d);
}
else if(k < 255 - stack)
{
for(int l = 0; l < stack; l++)
{
sliver.set(k + l + 1, d);
}
}
}
break;
}
} }
sliver.set(k, caveBiome.getGroundBiome(masterRandom, rx, k, rz));
}
for(int k = 0; k < ceilingLayers.size(); k++)
{
sliver.set(k + c.getCeiling(), caveBiome.getGroundBiome(masterRandom, rx, k, rz));
sliver.set(k + c.getCeiling(), ceilingLayers.get(k));
}
for(int k = 0; k < floorLayers.size(); k++)
{
sliver.set(c.getFloor() - k, caveBiome.getGroundBiome(masterRandom, rx, k, rz));
sliver.set(c.getFloor() - k, floorLayers.get(k));
} }
} }
} }
@ -182,6 +158,102 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
} }
} }
protected boolean canPlace(Material mat, Material onto)
{
if(onto.equals(Material.GRASS_PATH))
{
if(!mat.isSolid())
{
return false;
}
}
return true;
}
private void decorateLand(IrisBiome biome, AtomicSliver sliver, double wx, int k, double wz, int rx, int rz, BlockData block)
{
int j = 0;
for(IrisBiomeDecorator i : biome.getDecorators())
{
if(i.getPartOf().equals(DecorationPart.SHORE_LINE) && !touchesSea(rx, rz))
{
continue;
}
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
if(d != null)
{
if(!canPlace(d.getMaterial(), block.getMaterial()))
{
continue;
}
if(d instanceof Bisected && k < 254)
{
Bisected t = ((Bisected) d.clone());
t.setHalf(Half.TOP);
Bisected b = ((Bisected) d.clone());
b.setHalf(Half.BOTTOM);
sliver.set(k + 1, b);
sliver.set(k + 2, t);
}
else
{
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
if(stack == 1)
{
sliver.set(k + 1, d);
}
else if(k < 255 - stack)
{
for(int l = 0; l < stack; l++)
{
sliver.set(k + l + 1, d);
}
}
}
break;
}
}
}
private void decorateUnderwater(IrisBiome biome, AtomicSliver sliver, double wx, int y, double wz, int rx, int rz, BlockData block)
{
int j = 0;
for(IrisBiomeDecorator i : biome.getDecorators())
{
BlockData d = i.getBlockData(getMasterRandom().nextParallelRNG(biome.hashCode() + j++), wx, wz);
if(d != null)
{
int stack = i.getHeight(getMasterRandom().nextParallelRNG(39456 + i.hashCode()), wx, wz);
if(stack == 1)
{
sliver.set(y + 1, d);
}
else if(y < getFluidHeight() - stack)
{
for(int l = 0; l < stack; l++)
{
sliver.set(y + l + 1, d);
}
}
break;
}
}
}
@Override @Override
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap) protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
{ {
@ -195,13 +267,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
protected void onPostParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap) protected void onPostParallaxPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height, BiomeMap biomeMap)
{ {
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 16; j++)
{
glCave.genCaves((x << 4) + i, (z << 4) + j, i, j, data, height);
}
}
} }
protected double getNoiseHeight(int rx, int rz) protected double getNoiseHeight(int rx, int rz)

View File

@ -20,7 +20,9 @@ public class GenLayerBiome extends GenLayer
private CellGenerator land; private CellGenerator land;
private CellGenerator shore; private CellGenerator shore;
private CellGenerator sea; private CellGenerator sea;
private CellGenerator cave;
private DimensionChunkGenerator iris; private DimensionChunkGenerator iris;
private IrisBiome defaultCave;
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng) public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
{ {
@ -31,6 +33,10 @@ public class GenLayerBiome extends GenLayer
land = new CellGenerator(rng.nextParallelRNG(9045162)); land = new CellGenerator(rng.nextParallelRNG(9045162));
shore = new CellGenerator(rng.nextParallelRNG(2342812)); shore = new CellGenerator(rng.nextParallelRNG(2342812));
sea = new CellGenerator(rng.nextParallelRNG(6135621)); sea = new CellGenerator(rng.nextParallelRNG(6135621));
cave = new CellGenerator(rng.nextParallelRNG(9985621));
defaultCave = new IrisBiome();
defaultCave.getLayers().clear();
defaultCave.setLoadKey("default");
} }
public IrisRegion getRegion(double bx, double bz) public IrisRegion getRegion(double bx, double bz)
@ -81,75 +87,75 @@ public class GenLayerBiome extends GenLayer
return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z))); return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z)));
} }
public BiomeResult generateSeaData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData) public BiomeResult generatePureSeaData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{ {
for(IrisRegionRidge i : regionData.getRidgeBiomes())
{
if(i.getType().equals(InferredType.SEA) && i.isRidge(rng, rawX, rawZ))
{
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()), 0.5);
}
}
for(IrisRegionSpot i : regionData.getSpotBiomes())
{
if(i.getType().equals(InferredType.SEA) && i.isSpot(rng, rawX, rawZ))
{
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()), 0.5);
}
}
sea.setShuffle(42); sea.setShuffle(42);
sea.setCellScale(0.56 / iris.getDimension().getSeaZoom()); sea.setCellScale(0.56 / iris.getDimension().getSeaZoom());
return generateBiomeData(bx, bz, regionData, sea, regionData.getSeaBiomes(), InferredType.SEA); return generateBiomeData(bx, bz, regionData, sea, regionData.getSeaBiomes(), InferredType.SEA);
} }
public BiomeResult generateLandData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData) public BiomeResult generateImpureData(int rawX, int rawZ, InferredType type, IrisRegion regionData, BiomeResult pureResult)
{ {
for(IrisRegionRidge i : regionData.getRidgeBiomes()) for(IrisRegionRidge i : regionData.getRidgeBiomes())
{ {
if(i.getType().equals(InferredType.LAND) && i.isRidge(rng, rawX, rawZ)) if(i.getType().equals(type) && i.isRidge(rng, rawX, rawZ))
{ {
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()), 0.5); return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5);
} }
} }
for(IrisRegionSpot i : regionData.getSpotBiomes()) for(IrisRegionSpot i : regionData.getSpotBiomes())
{ {
if(i.getType().equals(InferredType.LAND) && i.isSpot(rng, rawX, rawZ)) if(i.getType().equals(type) && i.isSpot(rng, rawX, rawZ))
{ {
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()), 0.5); return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5);
} }
} }
return pureResult;
}
public BiomeResult generateSeaData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{
return generateImpureData(rawX, rawZ, InferredType.SEA, regionData, generatePureSeaData(bx, bz, rawX, rawZ, regionData));
}
public BiomeResult generatePureLandData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{
land.setShuffle(12); land.setShuffle(12);
land.setCellScale(0.6 / iris.getDimension().getLandZoom()); land.setCellScale(0.6 / iris.getDimension().getLandZoom());
return generateBiomeData(bx, bz, regionData, land, regionData.getLandBiomes(), InferredType.LAND); return generateBiomeData(bx, bz, regionData, land, regionData.getLandBiomes(), InferredType.LAND);
} }
public BiomeResult generateShoreData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData) public BiomeResult generateLandData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{ {
for(IrisRegionRidge i : regionData.getRidgeBiomes()) return generateImpureData(rawX, rawZ, InferredType.LAND, regionData, generatePureLandData(bx, bz, rawX, rawZ, regionData));
{ }
if(i.getType().equals(InferredType.SHORE) && i.isRidge(rng, rawX, rawZ))
{
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()), 0.5);
}
}
for(IrisRegionSpot i : regionData.getSpotBiomes())
{
if(i.getType().equals(InferredType.SHORE) && i.isSpot(rng, rawX, rawZ))
{
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()), 0.5);
}
}
public BiomeResult generatePureShoreData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{
shore.setShuffle(4); shore.setShuffle(4);
shore.setCellScale(0.8 / iris.getDimension().getShoreZoom()); shore.setCellScale(0.8 / iris.getDimension().getShoreZoom());
return generateBiomeData(bx, bz, regionData, shore, regionData.getShoreBiomes(), InferredType.SHORE); return generateBiomeData(bx, bz, regionData, shore, regionData.getShoreBiomes(), InferredType.SHORE);
} }
public BiomeResult generateShoreData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{
return generateImpureData(rawX, rawZ, InferredType.SHORE, regionData, generatePureShoreData(bx, bz, rawX, rawZ, regionData));
}
public BiomeResult generateCaveData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
{
if(regionData.getCaveBiomes().isEmpty())
{
return new BiomeResult(defaultCave, 0);
}
cave.setShuffle(12);
cave.setCellScale(0.6 / iris.getDimension().getCaveBiomeZoom());
return generateBiomeData(bx, bz, regionData, cave, regionData.getCaveBiomes(), InferredType.CAVE);
}
public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent) public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent)
{ {
return implode(bx, bz, regionData, parentCell, parent, 1); return implode(bx, bz, regionData, parentCell, parent, 1);

View File

@ -1,20 +1,26 @@
package ninja.bytecode.iris.layer; package ninja.bytecode.iris.layer;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.generator.ChunkGenerator.ChunkData; import org.bukkit.block.data.BlockData;
import ninja.bytecode.iris.generator.DimensionChunkGenerator; import ninja.bytecode.iris.generator.DimensionChunkGenerator;
import ninja.bytecode.iris.object.atomics.AtomicSliver;
import ninja.bytecode.iris.util.BlockDataTools;
import ninja.bytecode.iris.util.CNG; import ninja.bytecode.iris.util.CNG;
import ninja.bytecode.iris.util.CaveResult;
import ninja.bytecode.iris.util.FastNoise; import ninja.bytecode.iris.util.FastNoise;
import ninja.bytecode.iris.util.FastNoise.CellularDistanceFunction; 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;
import ninja.bytecode.iris.util.GenLayer; import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.HeightMap;
import ninja.bytecode.iris.util.RNG; import ninja.bytecode.iris.util.RNG;
import ninja.bytecode.shuriken.collections.KList;
public class GenLayerCave extends GenLayer public class GenLayerCave extends GenLayer
{ {
public static final BlockData CAVE_AIR = BlockDataTools.getBlockData("CAVE_AIR");
public static final BlockData AIR = BlockDataTools.getBlockData("AIR");
private static final KList<CaveResult> EMPTY = new KList<>();
private CNG gincline; private CNG gincline;
private CNG shuffle; private CNG shuffle;
private FastNoise gg; private FastNoise gg;
@ -29,20 +35,21 @@ public class GenLayerCave extends GenLayer
//@done //@done
} }
public void genCaves(double wxx, double wzz, int x, int z, ChunkData data, HeightMap height) public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, AtomicSliver data)
{ {
if(!iris.getDimension().isCaves()) if(!iris.getDimension().isCaves())
{ {
return; return EMPTY;
} }
KList<CaveResult> result = new KList<>();
shuffle.scale(0.01); shuffle.scale(0.01);
double shuffleDistance = 72; double shuffleDistance = 72;
gg.SetNoiseType(NoiseType.Cellular); gg.SetNoiseType(NoiseType.Cellular);
gg.SetCellularReturnType(CellularReturnType.Distance2Sub); gg.SetCellularReturnType(CellularReturnType.Distance2Sub);
gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural); gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural);
for(int i = 0; i < 4; i++) for(int i = 0; i < 2; i++)
{ {
double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance); double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance);
double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance); double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance);
@ -53,46 +60,65 @@ public class GenLayerCave extends GenLayer
double drop = (-i * 7) + 44 + iris.getDimension().getCaveShift(); double drop = (-i * 7) + 44 + iris.getDimension().getCaveShift();
double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i))); double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i)));
caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3; caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3;
int ceiling = 0;
int floor = 256;
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++) for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++)
{ {
double distance = (gg.GetCellular((float) wx + (10000 * i), (float) wz - (10000 * i)) + 1D) / 2D; double distance = (gg.GetCellular((float) wx + (10000 * i), (float) wz - (10000 * i)) + 1D) / 2D;
if(distance < distanceCheck - (tunnelHeight * distanceTake)) if(distance < distanceCheck - (tunnelHeight * distanceTake))
{ {
int caveHeight = (int) Math.round(caveHeightNoise - drop); int caveHeight = (int) Math.round(caveHeightNoise - drop);
dig(x, (int) (caveHeight + tunnelHeight), z, data); int pu = (int) (caveHeight + tunnelHeight);
dig(x, (int) (caveHeight - tunnelHeight), z, data); int pd = (int) (caveHeight - tunnelHeight);
if(dig(x, pu, z, data))
{
ceiling = pu > ceiling ? pu : ceiling;
floor = pu < floor ? pu : floor;
}
if(dig(x, pd, z, data))
{
ceiling = pd > ceiling ? pd : ceiling;
floor = pd < floor ? pd : floor;
}
if(tunnelHeight == 1) if(tunnelHeight == 1)
{ {
dig(x, (int) (caveHeight), z, data); if(dig(x, (int) (caveHeight), z, data))
{
ceiling = caveHeight > ceiling ? caveHeight : ceiling;
floor = caveHeight < floor ? caveHeight : floor;
}
} }
} }
} }
result.add(new CaveResult(floor, ceiling));
} }
return result;
} }
public boolean dig(int x, int y, int z, ChunkData data) public boolean dig(int x, int y, int z, AtomicSliver data)
{ {
Material a = data.getType(x, y, z); Material a = data.getType(y);
Material b = data.getType(x, y, z + 1); Material c = data.getType(y + 1);
Material c = data.getType(x, y + 1, z); Material f = data.getType(y - 1);
Material d = data.getType(x + 1, y, z);
Material e = data.getType(x, y, z - 1);
Material f = data.getType(x, y - 1, z);
Material g = data.getType(x - 1, y, z);
if(can(a) && cann(b) && cann(c) && cann(d) && cann(e) && cann(f) && cann(g)) if(can(a) && canAir(c) && canAir(f))
{ {
data.setBlock(x, y, z, Material.AIR); data.set(y, CAVE_AIR);
return true; return true;
} }
return false; return false;
} }
public boolean cann(Material m) public boolean canAir(Material m)
{ {
return m.isSolid() || m.equals(Material.AIR) && !m.equals(Material.BEDROCK); return (m.isSolid() || m.equals(Material.AIR) || m.equals(Material.CAVE_AIR)) && !m.equals(Material.BEDROCK);
} }
public boolean can(Material m) public boolean can(Material m)

View File

@ -4,5 +4,7 @@ public enum InferredType
{ {
SHORE, SHORE,
LAND, LAND,
SEA SEA,
CAVE,
DEFER;
} }

View File

@ -112,6 +112,11 @@ public class IrisBiome extends IrisRegistrant
{ {
KList<BlockData> data = new KList<>(); KList<BlockData> data = new KList<>();
if(maxDepth <= 0)
{
return data;
}
for(int i = 0; i < layers.size(); i++) for(int i = 0; i < layers.size(); i++)
{ {
CNG hgen = getLayerHeightGenerators(random).get(i); CNG hgen = getLayerHeightGenerators(random).get(i);
@ -149,6 +154,12 @@ public class IrisBiome extends IrisRegistrant
return data; return data;
} }
public IrisBiome infer(InferredType t, InferredType type)
{
setInferredType(t.equals(InferredType.DEFER) ? type : t);
return this;
}
public KList<BlockData> generateSeaLayers(double wx, double wz, RNG random, int maxDepth) public KList<BlockData> generateSeaLayers(double wx, double wz, RNG random, int maxDepth)
{ {
KList<BlockData> data = new KList<>(); KList<BlockData> data = new KList<>();

View File

@ -82,6 +82,7 @@ public class IrisDepositGenerator
rot.setZAxis(zc); rot.setZAxis(zc);
p.setRotation(rot); p.setRotation(rot);
p.setUnderwater(true); p.setUnderwater(true);
p.setMeld(true);
return p; return p;
} }

View File

@ -81,6 +81,9 @@ public class IrisDimension extends IrisRegistrant
@Desc("This zooms in the land space") @Desc("This zooms in the land space")
private double landZoom = 1; private double landZoom = 1;
@Desc("This zooms in the cave biome space")
private double caveBiomeZoom = 1;
@Desc("This can zoom the shores") @Desc("This can zoom the shores")
private double shoreZoom = 1; private double shoreZoom = 1;

View File

@ -173,6 +173,11 @@ public class IrisObject extends IrisRegistrant
} }
} }
if(config.isMeld() && !placer.isSolid(xx, yy, zz))
{
continue;
}
placer.set(xx, yy, zz, data); placer.set(xx, yy, zz, data);
} }

View File

@ -33,6 +33,9 @@ public class IrisObjectPlacement
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.") @Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
private boolean underwater = false; private boolean underwater = false;
@Desc("If set to true, this object will only place parts of itself where blocks already exist.")
private boolean meld = false;
public IrisObjectPlacement() public IrisObjectPlacement()
{ {

View File

@ -40,6 +40,9 @@ public class IrisRegion extends IrisRegistrant
@Desc("A list of root-level biomes in this region. Don't specify child biomes of other biomes here. Just the root parents.") @Desc("A list of root-level biomes in this region. Don't specify child biomes of other biomes here. Just the root parents.")
private KList<String> shoreBiomes = new KList<>(); private KList<String> shoreBiomes = new KList<>();
@Desc("A list of root-level biomes in this region. Don't specify child biomes of other biomes here. Just the root parents.")
private KList<String> caveBiomes = new KList<>();
@Desc("Ridge biomes create a vein-like network like rivers through this region") @Desc("Ridge biomes create a vein-like network like rivers through this region")
private KList<IrisRegionRidge> ridgeBiomes = new KList<>(); private KList<IrisRegionRidge> ridgeBiomes = new KList<>();
@ -49,9 +52,37 @@ public class IrisRegion extends IrisRegistrant
@Desc("Define regional deposit generators that add onto the global deposit generators") @Desc("Define regional deposit generators that add onto the global deposit generators")
private KList<IrisDepositGenerator> deposits = new KList<>(); private KList<IrisDepositGenerator> deposits = new KList<>();
private transient KList<String> cacheRidge;
private transient KList<String> cacheSpot;
private transient CNG shoreHeightGenerator; private transient CNG shoreHeightGenerator;
private transient ReentrantLock lock = new ReentrantLock(); private transient ReentrantLock lock = new ReentrantLock();
public KList<String> getRidgeBiomeKeys()
{
lock.lock();
if(cacheRidge == null)
{
cacheRidge = new KList<String>();
ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome()));
}
lock.unlock();
return cacheRidge;
}
public KList<String> getSpotBiomeKeys()
{
lock.lock();
if(cacheSpot == null)
{
cacheSpot = new KList<String>();
spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome()));
}
lock.unlock();
return cacheSpot;
}
public double getShoreHeight(double x, double z) public double getShoreHeight(double x, double z)
{ {
if(shoreHeightGenerator == null) if(shoreHeightGenerator == null)

View File

@ -13,6 +13,8 @@ public class IrisRegionRidge
private String biome; private String biome;
@Desc("The type this biome should override (land sea or shore)") @Desc("The type this biome should override (land sea or shore)")
private InferredType type = InferredType.LAND; private InferredType type = InferredType.LAND;
@Desc("What type this spot is (i.e. target SEA but as LAND) like an island. Default matches the target type")
private InferredType as = InferredType.DEFER;
@Desc("The chance this biome will be placed in a given spot") @Desc("The chance this biome will be placed in a given spot")
private double chance = 0.75; private double chance = 0.75;
@Desc("The scale of the biome ridge. Higher values = wider veins & bigger connected cells") @Desc("The scale of the biome ridge. Higher values = wider veins & bigger connected cells")

View File

@ -4,6 +4,7 @@ import lombok.Data;
import ninja.bytecode.iris.util.CellGenerator; import ninja.bytecode.iris.util.CellGenerator;
import ninja.bytecode.iris.util.Desc; import ninja.bytecode.iris.util.Desc;
import ninja.bytecode.iris.util.RNG; import ninja.bytecode.iris.util.RNG;
@Desc("A spot config") @Desc("A spot config")
@Data @Data
public class IrisRegionSpot public class IrisRegionSpot
@ -12,6 +13,8 @@ public class IrisRegionSpot
private String biome; private String biome;
@Desc("Where this spot overrides. Land sea or shore") @Desc("Where this spot overrides. Land sea or shore")
private InferredType type = InferredType.LAND; private InferredType type = InferredType.LAND;
@Desc("What type this spot is (i.e. target SEA but as LAND) like an island. Default matches the target type")
private InferredType as = InferredType.DEFER;
@Desc("The scale of splotches") @Desc("The scale of splotches")
private double scale = 1; private double scale = 1;
@Desc("Rarity is how often this splotch appears. higher = less often") @Desc("Rarity is how often this splotch appears. higher = less often")

View File

@ -4,6 +4,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import org.bukkit.Material;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.BiomeGrid;
@ -17,7 +18,7 @@ import ninja.bytecode.shuriken.collections.KMap;
@Data @Data
public class AtomicSliver public class AtomicSliver
{ {
private static final BlockData AIR = BlockDataTools.getBlockData("AIR"); public static final BlockData AIR = BlockDataTools.getBlockData("AIR");
private KMap<Integer, BlockData> block; private KMap<Integer, BlockData> block;
private KMap<Integer, Biome> biome; private KMap<Integer, Biome> biome;
private int highestBlock = 0; private int highestBlock = 0;
@ -33,6 +34,23 @@ public class AtomicSliver
this.biome = new KMap<>(); this.biome = new KMap<>();
} }
public Material getType(int h)
{
return get(h).getMaterial();
}
public BlockData get(int h)
{
BlockData b = block.get(h);
if(b == null)
{
return AIR;
}
return b;
}
public void set(int h, BlockData d) public void set(int h, BlockData d)
{ {
if(d == null) if(d == null)
@ -54,6 +72,11 @@ public class AtomicSliver
block.put(h, d); block.put(h, d);
} }
public boolean isSolid(int h)
{
return getType(h).isSolid();
}
public void set(int h, Biome d) public void set(int h, Biome d)
{ {
biome.put(h, d); biome.put(h, d);

View File

@ -0,0 +1,16 @@
package ninja.bytecode.iris.util;
import lombok.Data;
@Data
public class CaveResult
{
private int floor;
private int ceiling;
public CaveResult(int floor, int ceiling)
{
this.floor = floor;
this.ceiling = ceiling;
}
}

View File

@ -13,4 +13,6 @@ public interface IObjectPlacer
public BlockData get(int x, int y, int z); public BlockData get(int x, int y, int z);
public boolean isPreventingDecay(); public boolean isPreventingDecay();
public boolean isSolid(int x, int y, int z);
} }