mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Fix
This commit is contained in:
parent
f8cb0caa80
commit
5af98c5683
@ -174,6 +174,9 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
loadQueue.addAll(r.getLandBiomes());
|
||||
loadQueue.addAll(r.getSeaBiomes());
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -100,6 +100,12 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
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)
|
||||
{
|
||||
getMasterLock().lock("gpc");
|
||||
|
@ -16,6 +16,7 @@ import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicSliver;
|
||||
import ninja.bytecode.iris.util.BiomeMap;
|
||||
import ninja.bytecode.iris.util.BiomeResult;
|
||||
import ninja.bytecode.iris.util.CaveResult;
|
||||
import ninja.bytecode.iris.util.HeightMap;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
import ninja.bytecode.shuriken.collections.KList;
|
||||
@ -26,6 +27,7 @@ import ninja.bytecode.shuriken.math.M;
|
||||
public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
protected static final BlockData AIR = Material.AIR.createBlockData();
|
||||
protected static final BlockData WEB = Material.COBWEB.createBlockData();
|
||||
private long lastUpdateRequest = M.ms();
|
||||
private long lastChunkLoad = M.ms();
|
||||
private GenLayerCave glCave;
|
||||
@ -98,80 +100,54 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
|
||||
if(k == height && block.getMaterial().isSolid() && k < fluidHeight && biome.isSea())
|
||||
{
|
||||
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(k + 1, d);
|
||||
}
|
||||
|
||||
else if(k < fluidHeight - stack)
|
||||
{
|
||||
for(int l = 0; l < stack; l++)
|
||||
{
|
||||
sliver.set(k + l + 1, d);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
decorateUnderwater(biome, sliver, wx, k, wz, rx, rz, block);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -20,7 +20,9 @@ public class GenLayerBiome extends GenLayer
|
||||
private CellGenerator land;
|
||||
private CellGenerator shore;
|
||||
private CellGenerator sea;
|
||||
private CellGenerator cave;
|
||||
private DimensionChunkGenerator iris;
|
||||
private IrisBiome defaultCave;
|
||||
|
||||
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
|
||||
{
|
||||
@ -31,6 +33,10 @@ public class GenLayerBiome extends GenLayer
|
||||
land = new CellGenerator(rng.nextParallelRNG(9045162));
|
||||
shore = new CellGenerator(rng.nextParallelRNG(2342812));
|
||||
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)
|
||||
@ -81,75 +87,75 @@ public class GenLayerBiome extends GenLayer
|
||||
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.setCellScale(0.56 / iris.getDimension().getSeaZoom());
|
||||
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())
|
||||
{
|
||||
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())
|
||||
{
|
||||
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.setCellScale(0.6 / iris.getDimension().getLandZoom());
|
||||
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())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
return generateImpureData(rawX, rawZ, InferredType.LAND, regionData, generatePureLandData(bx, bz, rawX, rawZ, regionData));
|
||||
}
|
||||
|
||||
public BiomeResult generatePureShoreData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
shore.setShuffle(4);
|
||||
shore.setCellScale(0.8 / iris.getDimension().getShoreZoom());
|
||||
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)
|
||||
{
|
||||
return implode(bx, bz, regionData, parentCell, parent, 1);
|
||||
|
@ -1,20 +1,26 @@
|
||||
package ninja.bytecode.iris.layer;
|
||||
|
||||
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.object.atomics.AtomicSliver;
|
||||
import ninja.bytecode.iris.util.BlockDataTools;
|
||||
import ninja.bytecode.iris.util.CNG;
|
||||
import ninja.bytecode.iris.util.CaveResult;
|
||||
import ninja.bytecode.iris.util.FastNoise;
|
||||
import ninja.bytecode.iris.util.FastNoise.CellularDistanceFunction;
|
||||
import ninja.bytecode.iris.util.FastNoise.CellularReturnType;
|
||||
import ninja.bytecode.iris.util.FastNoise.NoiseType;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.HeightMap;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
import ninja.bytecode.shuriken.collections.KList;
|
||||
|
||||
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 shuffle;
|
||||
private FastNoise gg;
|
||||
@ -29,20 +35,21 @@ public class GenLayerCave extends GenLayer
|
||||
//@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())
|
||||
{
|
||||
return;
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
KList<CaveResult> result = new KList<>();
|
||||
shuffle.scale(0.01);
|
||||
double shuffleDistance = 72;
|
||||
gg.SetNoiseType(NoiseType.Cellular);
|
||||
gg.SetCellularReturnType(CellularReturnType.Distance2Sub);
|
||||
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 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 caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i)));
|
||||
caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3;
|
||||
|
||||
int ceiling = 0;
|
||||
int floor = 256;
|
||||
|
||||
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++)
|
||||
{
|
||||
double distance = (gg.GetCellular((float) wx + (10000 * i), (float) wz - (10000 * i)) + 1D) / 2D;
|
||||
if(distance < distanceCheck - (tunnelHeight * distanceTake))
|
||||
{
|
||||
int caveHeight = (int) Math.round(caveHeightNoise - drop);
|
||||
dig(x, (int) (caveHeight + tunnelHeight), z, data);
|
||||
dig(x, (int) (caveHeight - tunnelHeight), z, data);
|
||||
int pu = (int) (caveHeight + tunnelHeight);
|
||||
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)
|
||||
{
|
||||
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 b = data.getType(x, y, z + 1);
|
||||
Material c = data.getType(x, y + 1, z);
|
||||
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);
|
||||
Material a = data.getType(y);
|
||||
Material c = data.getType(y + 1);
|
||||
Material f = data.getType(y - 1);
|
||||
|
||||
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 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)
|
||||
|
@ -4,5 +4,7 @@ public enum InferredType
|
||||
{
|
||||
SHORE,
|
||||
LAND,
|
||||
SEA
|
||||
SEA,
|
||||
CAVE,
|
||||
DEFER;
|
||||
}
|
||||
|
@ -112,6 +112,11 @@ public class IrisBiome extends IrisRegistrant
|
||||
{
|
||||
KList<BlockData> data = new KList<>();
|
||||
|
||||
if(maxDepth <= 0)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
for(int i = 0; i < layers.size(); i++)
|
||||
{
|
||||
CNG hgen = getLayerHeightGenerators(random).get(i);
|
||||
@ -149,6 +154,12 @@ public class IrisBiome extends IrisRegistrant
|
||||
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)
|
||||
{
|
||||
KList<BlockData> data = new KList<>();
|
||||
|
@ -82,6 +82,7 @@ public class IrisDepositGenerator
|
||||
rot.setZAxis(zc);
|
||||
p.setRotation(rot);
|
||||
p.setUnderwater(true);
|
||||
p.setMeld(true);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
@ -81,6 +81,9 @@ public class IrisDimension extends IrisRegistrant
|
||||
@Desc("This zooms in the land space")
|
||||
private double landZoom = 1;
|
||||
|
||||
@Desc("This zooms in the cave biome space")
|
||||
private double caveBiomeZoom = 1;
|
||||
|
||||
@Desc("This can zoom the shores")
|
||||
private double shoreZoom = 1;
|
||||
|
||||
|
@ -173,6 +173,11 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
|
||||
if(config.isMeld() && !placer.isSolid(xx, yy, zz))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
placer.set(xx, yy, zz, data);
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,9 @@ public class IrisObjectPlacement
|
||||
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
|
||||
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()
|
||||
{
|
||||
|
||||
|
@ -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.")
|
||||
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")
|
||||
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")
|
||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||
|
||||
private transient KList<String> cacheRidge;
|
||||
private transient KList<String> cacheSpot;
|
||||
private transient CNG shoreHeightGenerator;
|
||||
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)
|
||||
{
|
||||
if(shoreHeightGenerator == null)
|
||||
|
@ -13,6 +13,8 @@ public class IrisRegionRidge
|
||||
private String biome;
|
||||
@Desc("The type this biome should override (land sea or shore)")
|
||||
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")
|
||||
private double chance = 0.75;
|
||||
@Desc("The scale of the biome ridge. Higher values = wider veins & bigger connected cells")
|
||||
|
@ -4,6 +4,7 @@ import lombok.Data;
|
||||
import ninja.bytecode.iris.util.CellGenerator;
|
||||
import ninja.bytecode.iris.util.Desc;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
@Desc("A spot config")
|
||||
@Data
|
||||
public class IrisRegionSpot
|
||||
@ -12,6 +13,8 @@ public class IrisRegionSpot
|
||||
private String biome;
|
||||
@Desc("Where this spot overrides. Land sea or shore")
|
||||
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")
|
||||
private double scale = 1;
|
||||
@Desc("Rarity is how often this splotch appears. higher = less often")
|
||||
|
@ -4,6 +4,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
@ -17,7 +18,7 @@ import ninja.bytecode.shuriken.collections.KMap;
|
||||
@Data
|
||||
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, Biome> biome;
|
||||
private int highestBlock = 0;
|
||||
@ -33,6 +34,23 @@ public class AtomicSliver
|
||||
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)
|
||||
{
|
||||
if(d == null)
|
||||
@ -54,6 +72,11 @@ public class AtomicSliver
|
||||
block.put(h, d);
|
||||
}
|
||||
|
||||
public boolean isSolid(int h)
|
||||
{
|
||||
return getType(h).isSolid();
|
||||
}
|
||||
|
||||
public void set(int h, Biome d)
|
||||
{
|
||||
biome.put(h, d);
|
||||
|
16
src/main/java/ninja/bytecode/iris/util/CaveResult.java
Normal file
16
src/main/java/ninja/bytecode/iris/util/CaveResult.java
Normal 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;
|
||||
}
|
||||
}
|
@ -13,4 +13,6 @@ public interface IObjectPlacer
|
||||
public BlockData get(int x, int y, int z);
|
||||
|
||||
public boolean isPreventingDecay();
|
||||
|
||||
public boolean isSolid(int x, int y, int z);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user