From b6592582b38944773c337671e4bd254c436f1a76 Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Sun, 2 Aug 2020 16:17:02 -0400 Subject: [PATCH] Fixes --- .../volmit/iris/gen/BiomeChunkGenerator.java | 6 ++-- .../iris/gen/TerrainChunkGenerator.java | 27 ++++++++++++---- .../volmit/iris/gen/layer/GenLayerBiome.java | 4 +-- .../com/volmit/iris/object/Dispersion.java | 4 +-- .../iris/object/IrisDepositGenerator.java | 4 +-- .../volmit/iris/object/IrisRegionRidge.java | 32 +++++++++++++++++++ .../volmit/iris/object/IrisRegionSpot.java | 25 +++++++++++++++ .../com/volmit/iris/util/BiomeResult.java | 12 +++++++ 8 files changed, 99 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/volmit/iris/gen/BiomeChunkGenerator.java b/src/main/java/com/volmit/iris/gen/BiomeChunkGenerator.java index 243193d7d..152e0185d 100644 --- a/src/main/java/com/volmit/iris/gen/BiomeChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/BiomeChunkGenerator.java @@ -101,16 +101,18 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator return getDimension().isInverted() ? ceilingGenerators : generators; } - protected double getBiomeHeight(double rx, double rz) + protected double getBiomeHeight(double rx, double rz, int x, int z) { double h = 0; + IrisRegion region = glBiome.getRegion(rx, rz); + BiomeResult r = glBiome.generateRegionData(rx, rz, x, z, region); for(IrisGenerator i : getGenerators().values()) { h += interpolateGenerator(rx, rz, i); } - return h; + return h + r.getHeightOffset(); } protected double interpolateGenerator(double rx, double rz, IrisGenerator gen) diff --git a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java index 4fb997f40..08b5ea344 100644 --- a/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java +++ b/src/main/java/com/volmit/iris/gen/TerrainChunkGenerator.java @@ -40,14 +40,14 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator private GenLayerCarve glCarve; private RNG rockRandom; private int[] cacheHeightMap; - private IrisBiome[] cacheTrueBiome; + private BiomeResult[] cacheTrueBiome; private ReentrantLock cacheLock; public TerrainChunkGenerator(String dimensionName, int threads) { super(dimensionName, threads); cacheHeightMap = new int[256]; - cacheTrueBiome = new IrisBiome[256]; + cacheTrueBiome = new BiomeResult[256]; cachingAllowed = true; cacheLock = new ReentrantLock(); } @@ -87,7 +87,9 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator int height = (int) Math.round(noise) + fluidHeight; boolean carvable = getDimension().isCarving() && height > getDimension().getCarvingMin(); IrisRegion region = sampleRegion(rx, rz); - IrisBiome biome = sampleTrueBiome(rx, rz).getBiome(); + BiomeResult biomeResult = sampleTrueBiome(rx, rz); + IrisBiome biome = biomeResult.getBiome(); + double airReversal = biomeResult.getHeightOffset(); if(biome == null) { @@ -98,7 +100,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator { try { - cacheTrueBiome[(z << 4) | x] = biome; + cacheTrueBiome[(z << 4) | x] = biomeResult; cacheHeightMap[(z << 4) | x] = height; } @@ -115,7 +117,18 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator KList cavernHeights = new KList<>(); int lastCavernHeight = -1; - for(int k = Math.max(height, fluidHeight); k < Math.max(height, fluidHeight) + 3; k++) + if(height > fluidHeight && airReversal < 0 && biomeResult.getAir() != null && biomeResult.getAir().getBlockData().isNotEmpty()) + { + RNG randomx = masterRandom.nextParallelRNG(95288); + int realHeight = (int) Math.floor(height - airReversal); + + for(int k = height + 1; k < realHeight; k++) + { + sliver.set(k, biomeResult.getAir().get(randomx, wx, k, wz)); + } + } + + for(int k = Math.max(height, fluidHeight); k < Math.max(height, fluidHeight) + 3 + Math.abs(airReversal); k++) { if(k < Math.max(height, fluidHeight) + 3) { @@ -474,7 +487,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator double wx = getZoomed(rx); double wz = getZoomed(rz); - return getBiomeHeight(wx, wz); + return getBiomeHeight(wx, wz, rx, rz); } public BiomeResult sampleTrueBiomeBase(int x, int z) @@ -552,7 +565,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator if(isSafe() && x >> 4 == cacheX && z >> 4 == cacheZ) { - return new BiomeResult(cacheTrueBiome[((z & 15) << 4) | (x & 15)], 0); + return cacheTrueBiome[((z & 15) << 4) | (x & 15)]; } double wx = getModifiedX(x, z); diff --git a/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java b/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java index 74ba3e7ea..7375dd344 100644 --- a/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java +++ b/src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java @@ -147,7 +147,7 @@ public class GenLayerBiome extends GenLayer { if(i.getType().equals(type) && i.isRidge(rng, rawX, rawZ)) { - return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5); + return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5, i.getRidgeHeight(rng, rawX, rawZ), i.getAir()); } } @@ -155,7 +155,7 @@ public class GenLayerBiome extends GenLayer { if(i.getType().equals(type) && i.isSpot(rng, rawX, rawZ)) { - return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5); + return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5, i.getSpotHeight(rng, rawX, rawZ), i.getAir()); } } diff --git a/src/main/java/com/volmit/iris/object/Dispersion.java b/src/main/java/com/volmit/iris/object/Dispersion.java index 8cc4cc414..338930182 100644 --- a/src/main/java/com/volmit/iris/object/Dispersion.java +++ b/src/main/java/com/volmit/iris/object/Dispersion.java @@ -6,7 +6,7 @@ public enum Dispersion { @DontObfuscate SCATTER, - + @DontObfuscate - WISPY, + WISPY; } diff --git a/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java b/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java index bd4303186..79558bca2 100644 --- a/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java +++ b/src/main/java/com/volmit/iris/object/IrisDepositGenerator.java @@ -176,7 +176,7 @@ public class IrisDepositGenerator int x = rng.i(af, bf); int z = rng.i(af, bf); - int height = (int) (Math.round(g.getTerrainWaterHeight(x, z))) - 5; + int height = (int) (Math.round(g.getTerrainWaterHeight(x, z))) - 2; if(height <= 0) { @@ -204,7 +204,7 @@ public class IrisDepositGenerator int ny = j.getBlockY() + h; int nz = j.getBlockZ() + z; - if(nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) + if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) { continue; } diff --git a/src/main/java/com/volmit/iris/object/IrisRegionRidge.java b/src/main/java/com/volmit/iris/object/IrisRegionRidge.java index 901f2156e..1d9e3e5f9 100644 --- a/src/main/java/com/volmit/iris/object/IrisRegionRidge.java +++ b/src/main/java/com/volmit/iris/object/IrisRegionRidge.java @@ -23,6 +23,10 @@ public class IrisRegionRidge @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; + @DontObfuscate + @Desc("Use the distance from cell value to add or remove noise value. (Forces depth or height)") + private double noiseMultiplier = 0; + @DontObfuscate @Desc("The chance this biome will be placed in a given spot") private double chance = 0.75; @@ -47,6 +51,10 @@ public class IrisRegionRidge @Desc("The thickness of the vein") private double thickness = 0.125; + @DontObfuscate + @Desc("If the noise multiplier is below zero, what should the air be filled with?") + private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero(); + private transient CellGenerator spot; private transient CellGenerator ridge; @@ -55,6 +63,30 @@ public class IrisRegionRidge } + public double getRidgeHeight(RNG rng, double x, double z) + { + if(getNoiseMultiplier() == 0) + { + return 0; + } + + if(ridge == null) + { + ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance()))); + ridge.setCellScale(scale); + ridge.setShuffle(shuffle); + } + + if(spot == null) + { + spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance()))); + spot.setCellScale(chanceScale); + spot.setShuffle(shuffle); + } + + return spot.getDistance(x, z) * ridge.getDistance(x, z) * getNoiseMultiplier(); + } + public boolean isRidge(RNG rng, double x, double z) { if(ridge == null) diff --git a/src/main/java/com/volmit/iris/object/IrisRegionSpot.java b/src/main/java/com/volmit/iris/object/IrisRegionSpot.java index a414b2591..59f3d9d94 100644 --- a/src/main/java/com/volmit/iris/object/IrisRegionSpot.java +++ b/src/main/java/com/volmit/iris/object/IrisRegionSpot.java @@ -23,6 +23,10 @@ public class IrisRegionSpot @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; + @DontObfuscate + @Desc("Use the distance from cell value to add or remove noise value. (Forces depth or height)") + private double noiseMultiplier = 0; + @DontObfuscate @Desc("The scale of splotches") private double scale = 1; @@ -35,6 +39,10 @@ public class IrisRegionSpot @Desc("The shuffle or how natural the splotch looks like (anti-polygon)") private double shuffle = 128; + @DontObfuscate + @Desc("If the noise multiplier is below zero, what should the air be filled with?") + private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero(); + private transient CellGenerator spot; public IrisRegionSpot() @@ -42,6 +50,23 @@ public class IrisRegionSpot } + public double getSpotHeight(RNG rng, double x, double z) + { + if(getNoiseMultiplier() == 0) + { + return 0; + } + + if(spot == null) + { + spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal()))); + spot.setCellScale(scale); + spot.setShuffle(shuffle); + } + + return spot.getDistance(x, z) * getNoiseMultiplier(); + } + public boolean isSpot(RNG rng, double x, double z) { if(spot == null) diff --git a/src/main/java/com/volmit/iris/util/BiomeResult.java b/src/main/java/com/volmit/iris/util/BiomeResult.java index 212e53d58..8d17c0e9c 100644 --- a/src/main/java/com/volmit/iris/util/BiomeResult.java +++ b/src/main/java/com/volmit/iris/util/BiomeResult.java @@ -1,6 +1,7 @@ package com.volmit.iris.util; import com.volmit.iris.object.IrisBiome; +import com.volmit.iris.object.IrisBiomePaletteLayer; import lombok.Data; @@ -8,12 +9,23 @@ import lombok.Data; public class BiomeResult { private IrisBiome biome; + private IrisBiomePaletteLayer air; + private double heightOffset; private double distance; public BiomeResult(IrisBiome biome, double distance) { this.biome = biome; this.distance = distance; + this.heightOffset = 0; + } + + public BiomeResult(IrisBiome biome, double distance, double height, IrisBiomePaletteLayer air) + { + this.biome = biome; + this.distance = distance; + this.heightOffset = height; + this.air = air; } public boolean is(BiomeResult r)