From 5af98c5683f23fb33b5e2dc96bfaf9332dc283d7 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Sun, 26 Jul 2020 05:28:22 -0400 Subject: [PATCH] Fix --- .../iris/generator/BiomeChunkGenerator.java | 13 ++ .../generator/ParallaxChunkGenerator.java | 6 + .../iris/generator/TerrainChunkGenerator.java | 214 ++++++++++++------ .../bytecode/iris/layer/GenLayerBiome.java | 82 +++---- .../bytecode/iris/layer/GenLayerCave.java | 66 ++++-- .../bytecode/iris/object/InferredType.java | 4 +- .../ninja/bytecode/iris/object/IrisBiome.java | 11 + .../iris/object/IrisDepositGenerator.java | 1 + .../bytecode/iris/object/IrisDimension.java | 3 + .../bytecode/iris/object/IrisObject.java | 5 + .../iris/object/IrisObjectPlacement.java | 3 + .../bytecode/iris/object/IrisRegion.java | 31 +++ .../bytecode/iris/object/IrisRegionRidge.java | 2 + .../bytecode/iris/object/IrisRegionSpot.java | 3 + .../iris/object/atomics/AtomicSliver.java | 25 +- .../ninja/bytecode/iris/util/CaveResult.java | 16 ++ .../bytecode/iris/util/IObjectPlacer.java | 2 + 17 files changed, 353 insertions(+), 134 deletions(-) create mode 100644 src/main/java/ninja/bytecode/iris/util/CaveResult.java diff --git a/src/main/java/ninja/bytecode/iris/generator/BiomeChunkGenerator.java b/src/main/java/ninja/bytecode/iris/generator/BiomeChunkGenerator.java index 06560857f..e26d5570d 100644 --- a/src/main/java/ninja/bytecode/iris/generator/BiomeChunkGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/BiomeChunkGenerator.java @@ -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; + } } diff --git a/src/main/java/ninja/bytecode/iris/generator/ParallaxChunkGenerator.java b/src/main/java/ninja/bytecode/iris/generator/ParallaxChunkGenerator.java index b9c2fdf3d..40d5ccfb4 100644 --- a/src/main/java/ninja/bytecode/iris/generator/ParallaxChunkGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/ParallaxChunkGenerator.java @@ -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"); diff --git a/src/main/java/ninja/bytecode/iris/generator/TerrainChunkGenerator.java b/src/main/java/ninja/bytecode/iris/generator/TerrainChunkGenerator.java index 1265d1263..4316ee765 100644 --- a/src/main/java/ninja/bytecode/iris/generator/TerrainChunkGenerator.java +++ b/src/main/java/ninja/bytecode/iris/generator/TerrainChunkGenerator.java @@ -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 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 ceilingLayers = caveBiome.generateLayers(wx + c.getCeiling(), wz + c.getCeiling(), masterRandom, (height - c.getCeiling()) - 1); + KList 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) diff --git a/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java b/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java index 49ffc187b..12b2c556d 100644 --- a/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java +++ b/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java @@ -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); diff --git a/src/main/java/ninja/bytecode/iris/layer/GenLayerCave.java b/src/main/java/ninja/bytecode/iris/layer/GenLayerCave.java index 4d015df95..fe610fa90 100644 --- a/src/main/java/ninja/bytecode/iris/layer/GenLayerCave.java +++ b/src/main/java/ninja/bytecode/iris/layer/GenLayerCave.java @@ -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 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 genCaves(double wxx, double wzz, int x, int z, AtomicSliver data) { if(!iris.getDimension().isCaves()) { - return; + return EMPTY; } + KList 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) diff --git a/src/main/java/ninja/bytecode/iris/object/InferredType.java b/src/main/java/ninja/bytecode/iris/object/InferredType.java index 0f9bd0137..b3c4db94e 100644 --- a/src/main/java/ninja/bytecode/iris/object/InferredType.java +++ b/src/main/java/ninja/bytecode/iris/object/InferredType.java @@ -4,5 +4,7 @@ public enum InferredType { SHORE, LAND, - SEA + SEA, + CAVE, + DEFER; } diff --git a/src/main/java/ninja/bytecode/iris/object/IrisBiome.java b/src/main/java/ninja/bytecode/iris/object/IrisBiome.java index 1c46998e8..c708d69c0 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisBiome.java @@ -112,6 +112,11 @@ public class IrisBiome extends IrisRegistrant { KList 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 generateSeaLayers(double wx, double wz, RNG random, int maxDepth) { KList data = new KList<>(); diff --git a/src/main/java/ninja/bytecode/iris/object/IrisDepositGenerator.java b/src/main/java/ninja/bytecode/iris/object/IrisDepositGenerator.java index 928fdfde5..aa303b80c 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisDepositGenerator.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisDepositGenerator.java @@ -82,6 +82,7 @@ public class IrisDepositGenerator rot.setZAxis(zc); p.setRotation(rot); p.setUnderwater(true); + p.setMeld(true); return p; } diff --git a/src/main/java/ninja/bytecode/iris/object/IrisDimension.java b/src/main/java/ninja/bytecode/iris/object/IrisDimension.java index 2a4150e4a..6f91e57b4 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisDimension.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisDimension.java @@ -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; diff --git a/src/main/java/ninja/bytecode/iris/object/IrisObject.java b/src/main/java/ninja/bytecode/iris/object/IrisObject.java index 02ca93f30..feffafdf7 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisObject.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisObject.java @@ -173,6 +173,11 @@ public class IrisObject extends IrisRegistrant } } + if(config.isMeld() && !placer.isSolid(xx, yy, zz)) + { + continue; + } + placer.set(xx, yy, zz, data); } diff --git a/src/main/java/ninja/bytecode/iris/object/IrisObjectPlacement.java b/src/main/java/ninja/bytecode/iris/object/IrisObjectPlacement.java index 75f5b40af..50253fceb 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisObjectPlacement.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisObjectPlacement.java @@ -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() { diff --git a/src/main/java/ninja/bytecode/iris/object/IrisRegion.java b/src/main/java/ninja/bytecode/iris/object/IrisRegion.java index e8bd56994..e775b8685 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisRegion.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisRegion.java @@ -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 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 caveBiomes = new KList<>(); + @Desc("Ridge biomes create a vein-like network like rivers through this region") private KList 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 deposits = new KList<>(); + private transient KList cacheRidge; + private transient KList cacheSpot; private transient CNG shoreHeightGenerator; private transient ReentrantLock lock = new ReentrantLock(); + public KList getRidgeBiomeKeys() + { + lock.lock(); + if(cacheRidge == null) + { + cacheRidge = new KList(); + ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome())); + } + lock.unlock(); + + return cacheRidge; + } + + public KList getSpotBiomeKeys() + { + lock.lock(); + if(cacheSpot == null) + { + cacheSpot = new KList(); + spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome())); + } + lock.unlock(); + + return cacheSpot; + } + public double getShoreHeight(double x, double z) { if(shoreHeightGenerator == null) diff --git a/src/main/java/ninja/bytecode/iris/object/IrisRegionRidge.java b/src/main/java/ninja/bytecode/iris/object/IrisRegionRidge.java index 65dd058d9..6c8f69095 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisRegionRidge.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisRegionRidge.java @@ -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") diff --git a/src/main/java/ninja/bytecode/iris/object/IrisRegionSpot.java b/src/main/java/ninja/bytecode/iris/object/IrisRegionSpot.java index 8962fafc8..15a47328a 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisRegionSpot.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisRegionSpot.java @@ -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") diff --git a/src/main/java/ninja/bytecode/iris/object/atomics/AtomicSliver.java b/src/main/java/ninja/bytecode/iris/object/atomics/AtomicSliver.java index 4c1bc5cee..a3447136e 100644 --- a/src/main/java/ninja/bytecode/iris/object/atomics/AtomicSliver.java +++ b/src/main/java/ninja/bytecode/iris/object/atomics/AtomicSliver.java @@ -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 block; private KMap 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); diff --git a/src/main/java/ninja/bytecode/iris/util/CaveResult.java b/src/main/java/ninja/bytecode/iris/util/CaveResult.java new file mode 100644 index 000000000..96bf251c1 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/util/CaveResult.java @@ -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; + } +} diff --git a/src/main/java/ninja/bytecode/iris/util/IObjectPlacer.java b/src/main/java/ninja/bytecode/iris/util/IObjectPlacer.java index 509fd43bb..93e68f1df 100644 --- a/src/main/java/ninja/bytecode/iris/util/IObjectPlacer.java +++ b/src/main/java/ninja/bytecode/iris/util/IObjectPlacer.java @@ -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); }