From 64f361d4b1207780a700fd5f44b0f2e8fc92e7f0 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Mon, 26 Jul 2021 20:04:06 +1200 Subject: [PATCH 1/6] Cave Decorator Changes - Surface decorators are no longer placed below liquids in caves - SEA_FLOOR and SEA_SURFACE decorators now function within caves relative to the cave liquid - Fixed stacked decorators going above the height of caves and the map --- .../engine/actuator/IrisDecorantActuator.java | 39 ++++++++++++++--- .../decorator/IrisSeaFloorDecorator.java | 42 ++++++++----------- .../decorator/IrisSeaSurfaceDecorator.java | 6 +-- .../decorator/IrisShoreLineDecorator.java | 2 +- .../decorator/IrisSurfaceDecorator.java | 3 +- 5 files changed, 58 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java index 51aaefb61..398413ff0 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java @@ -18,12 +18,14 @@ package com.volmit.iris.engine.actuator; +import com.volmit.iris.Iris; import com.volmit.iris.engine.decorator.*; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.EngineAssignedActuator; import com.volmit.iris.engine.framework.EngineDecorator; import com.volmit.iris.engine.hunk.Hunk; import com.volmit.iris.engine.object.IrisBiome; +import com.volmit.iris.engine.object.IrisCaveLayer; import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.scheduling.PrecisionStopwatch; @@ -31,10 +33,12 @@ import lombok.Getter; import org.bukkit.Material; import org.bukkit.block.data.BlockData; +import java.util.function.BiPredicate; import java.util.function.Predicate; public class IrisDecorantActuator extends EngineAssignedActuator { private static final Predicate PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA); + private static BiPredicate PREDICATE_CAVELIQUID = (d, i) -> false; private final RNG rng; @Getter private final EngineDecorator surfaceDecorator; @@ -57,6 +61,21 @@ public class IrisDecorantActuator extends EngineAssignedActuator { seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine()); shoreLineDecorator = new IrisShoreLineDecorator(getEngine()); seaFloorDecorator = new IrisSeaFloorDecorator(getEngine()); + + PREDICATE_CAVELIQUID = (b, y) -> { + for (IrisCaveLayer layer : getEngine().getDimension().getCaveLayers()) { + if (!layer.getFluid().hasFluid(getData())) { + continue; + } + + if (layer.getFluid().isInverseHeight() && y >= layer.getFluid().getFluidHeight()) { + if (b.matches(layer.getFluid().getFluid(getData()))) return true; + } else if (!layer.getFluid().isInverseHeight() && y <= layer.getFluid().getFluidHeight()) { + if (b.matches(layer.getFluid().getFluid(getData()))) return true; + } + } + return false; + }; } @BlockCoordinates @@ -71,10 +90,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator { int j, realX, realZ, height; IrisBiome biome, cave; + for (int i = 0; i < output.getWidth(); i++) { for (j = 0; j < output.getDepth(); j++) { - boolean solid; + boolean solid, liquid; int emptyFor = 0; + int liquidFor = 0; int lastSolid = 0; realX = (int) Math.round(modX(x + i)); realZ = (int) Math.round(modZ(z + j)); @@ -90,12 +111,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator { getShoreLineDecorator().decorate(i, j, realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)), realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)), - output, biome, height, getEngine().getHeight() - height); + output, biome, height, getEngine().getHeight()); } else if (height == getDimension().getFluidHeight() + 1) { getSeaSurfaceDecorator().decorate(i, j, realX, (int) Math.round(modX(x + i + 1)), (int) Math.round(modX(x + i - 1)), realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)), - output, biome, height, getEngine().getHeight() - getDimension().getFluidHeight()); + output, biome, height, getEngine().getHeight()); } else if (height < getDimension().getFluidHeight()) { getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight()); } @@ -105,16 +126,24 @@ public class IrisDecorantActuator extends EngineAssignedActuator { if (cave != null && cave.getDecorators().isNotEmpty()) { for (int k = height; k > 0; k--) { solid = PREDICATE_SOLID.test(output.get(i, k, j)); + liquid = PREDICATE_CAVELIQUID.test(output.get(i, k + 1, j), k + 1); if (solid) { if (emptyFor > 0) { - getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor); - getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor); + if (liquid) { + getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - emptyFor); + getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k + liquidFor + 1, emptyFor - liquidFor + lastSolid); + } else { + getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor); + getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor); + } emptyFor = 0; + liquidFor = 0; } lastSolid = k; } else { emptyFor++; + if (liquid) liquidFor++; } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java index 5caa572d0..b0a45e309 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java @@ -35,36 +35,30 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { @BlockCoordinates @Override public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk data, IrisBiome biome, int height, int max) { - if (height <= getDimension().getFluidHeight()) { + IrisDecorator decorator = getDecorator(biome, realX, realZ); - IrisDecorator decorator = getDecorator(biome, realX, realZ); + if (decorator != null) { + if (!decorator.isStacking()) { + if (height >= 0 || height < getEngine().getHeight()) { + data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + } + } else { + int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); + stack = Math.min(stack, max - height + 1); - if (decorator != null) { - if (!decorator.isStacking()) { - if (height >= 0 || height < getEngine().getHeight()) { - data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); + BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + + for (int i = 0; i < stack; i++) { + if (height + i > max || height + i > getEngine().getHeight()) { + continue; } - } else { - int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(stack, getDimension().getFluidHeight() - height + 2); - BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); - BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); - - for (int i = 0; i < stack; i++) { - if (height - i < 0 || height - i > getEngine().getHeight()) { - continue; - } - - if (height + i > getDimension().getFluidHeight()) { - continue; - } - - double threshold = ((double) i) / (stack - 1); - data.set(x, height + i, z, threshold >= decorator.getTopThreshold() ? top : fill); - } + double threshold = ((double) i) / (stack - 1); + data.set(x, height + i, z, threshold >= decorator.getTopThreshold() ? top : fill); } } } + } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java index 6c19c5825..a00280bcf 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java @@ -40,7 +40,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { if (height >= 0 || height < getEngine().getHeight()) { - data.set(x, getDimension().getFluidHeight() + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); @@ -48,12 +48,12 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); for (int i = 0; i < stack; i++) { - if (height - i < 0 || height - i > getEngine().getHeight()) { + if (height + i >= max || height + i >= getEngine().getHeight()) { continue; } double threshold = ((double) i) / (stack - 1); - data.set(x, getDimension().getFluidHeight() + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill); + data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java index 7cd34c40a..768e89c87 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java @@ -49,7 +49,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - + stack = Math.min(max - height + 1, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java index caff5114e..e6d10a507 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java @@ -73,10 +73,11 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { } else { if (height < getDimension().getFluidHeight()) { - max = getDimension().getFluidHeight() - height; + max = getDimension().getFluidHeight(); } int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); + stack = Math.min(height - max + 1, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); From 5fabec6a42b8f47292e4379fd4c78325ca78a651 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Mon, 26 Jul 2021 20:27:07 +1200 Subject: [PATCH 2/6] Minor patches to decorators --- .../engine/actuator/IrisDecorantActuator.java | 2 +- .../decorator/IrisSeaFloorDecorator.java | 2 +- .../decorator/IrisShoreLineDecorator.java | 2 +- .../decorator/IrisSurfaceDecorator.java | 2 +- .../iris/engine/object/IrisCaveBiome.java | 86 +++++++++++++++++++ 5 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java index 398413ff0..09c84d3cf 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java @@ -134,7 +134,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator { getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - emptyFor); getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k + liquidFor + 1, emptyFor - liquidFor + lastSolid); } else { - getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor); + getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid); getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid - 1, emptyFor); } emptyFor = 0; diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java index b0a45e309..6ddbb59f7 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java @@ -44,7 +44,7 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(stack, max - height + 1); + stack = Math.min(stack, max - height + 2); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java index 768e89c87..e54aeb1c3 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java @@ -49,7 +49,7 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(max - height + 1, stack); + stack = Math.min(max - height, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java index e6d10a507..04e4bfe8a 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java @@ -77,7 +77,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { } int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(height - max + 1, stack); + stack = Math.min(height - max, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java b/src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java new file mode 100644 index 000000000..79427e68a --- /dev/null +++ b/src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java @@ -0,0 +1,86 @@ +/* + * Iris is a World Generator for Minecraft Bukkit Servers + * Copyright (c) 2021 Arcane Arts (Volmit Software) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.volmit.iris.engine.object; + +import com.volmit.iris.Iris; +import com.volmit.iris.core.IrisDataManager; +import com.volmit.iris.core.gui.components.RenderType; +import com.volmit.iris.engine.IrisComplex; +import com.volmit.iris.engine.cache.AtomicCache; +import com.volmit.iris.engine.data.B; +import com.volmit.iris.engine.data.DataProvider; +import com.volmit.iris.engine.framework.Engine; +import com.volmit.iris.engine.framework.IrisAccess; +import com.volmit.iris.engine.noise.CNG; +import com.volmit.iris.engine.object.annotations.ArrayType; +import com.volmit.iris.engine.object.annotations.DependsOn; +import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.MaxNumber; +import com.volmit.iris.engine.object.annotations.MinNumber; +import com.volmit.iris.engine.object.annotations.RegistryListBiome; +import com.volmit.iris.engine.object.annotations.Required; +import com.volmit.iris.engine.object.common.IRare; +import com.volmit.iris.util.collection.KList; +import com.volmit.iris.util.collection.KMap; +import com.volmit.iris.util.collection.KSet; +import com.volmit.iris.util.data.VanillaBiomeMap; +import com.volmit.iris.util.inventorygui.RandomColor; +import com.volmit.iris.util.math.RNG; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import org.bukkit.block.Biome; +import org.bukkit.block.data.BlockData; + +import java.awt.*; + +@SuppressWarnings("DefaultAnnotationParam") +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor + +@Desc("Represents a cave biome in iris. Cave biomes are placed inside of caves and hold objects.\nA biome consists of layers (block palletes), decorations, objects & generators.") +@Data +@EqualsAndHashCode(callSuper = true) +public class IrisCaveBiome extends IrisBiome { + + @Required + @ArrayType(min = 1, type = IrisBiomePaletteLayer.class) + @Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.") + private KList lavaLayers = new KList().qadd(new IrisBiomePaletteLayer()); + + @Required + @ArrayType(min = 1, type = IrisBiomePaletteLayer.class) + @Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.") + private KList waterLayers = new KList().qadd(new IrisBiomePaletteLayer()); + + + public KList getLavaLayers() { + return lavaLayers.isEmpty() ? getLayers() : lavaLayers; + } + + public KList getWaterLayers() { + return waterLayers.isEmpty() ? getLayers() : waterLayers; + } + + public boolean freezeLava = false; + public boolean freezeWater = false; +} From 21ce09a5b56e0eef277f8deee1170aa503ed83f9 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Tue, 27 Jul 2021 00:04:17 +1200 Subject: [PATCH 3/6] Added scaleStack property to decorators - Added scaleStack to decorators. It allows the size of the stack to scale to the size of the cave, using stackMin and stackMax as a min/max percentage - Fixed stacks missing a block in size when the top block isn't defined - Changed decorator stacks of a single block to place the top block instead of the body - Fixed tab sound playing to other players --- .../iris/engine/actuator/IrisDecorantActuator.java | 5 +++-- .../iris/engine/decorator/IrisCeilingDecorator.java | 10 +++++++++- .../iris/engine/decorator/IrisSeaFloorDecorator.java | 11 ++++++++++- .../engine/decorator/IrisSeaSurfaceDecorator.java | 6 +++++- .../iris/engine/decorator/IrisShoreLineDecorator.java | 5 ++++- .../iris/engine/decorator/IrisSurfaceDecorator.java | 10 +++++++++- .../com/volmit/iris/engine/object/IrisDecorator.java | 9 ++++++--- .../com/volmit/iris/util/plugin/MortarCommand.java | 2 +- 8 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java index 09c84d3cf..24f512354 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java @@ -118,11 +118,12 @@ public class IrisDecorantActuator extends EngineAssignedActuator { realZ, (int) Math.round(modZ(z + j + 1)), (int) Math.round(modZ(z + j - 1)), output, biome, height, getEngine().getHeight()); } else if (height < getDimension().getFluidHeight()) { - getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight()); + getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight() + 1); } getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height); + if (cave != null && cave.getDecorators().isNotEmpty()) { for (int k = height; k > 0; k--) { solid = PREDICATE_SOLID.test(output.get(i, k, j)); @@ -131,7 +132,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator { if (solid) { if (emptyFor > 0) { if (liquid) { - getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - emptyFor); + getSeaFloorDecorator().decorate(i, j, realX, realZ, output, cave, k + 1, liquidFor + lastSolid - emptyFor + 1); getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k + liquidFor + 1, emptyFor - liquidFor + lastSolid); } else { getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, lastSolid); diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java index 0c6703d8b..5fc0c7279 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java @@ -44,11 +44,19 @@ public class IrisCeilingDecorator extends IrisEngineDecorator { } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(max + 1, stack); + if (decorator.isScaleStack()) { + int maxStack = max - height; + stack = (int) Math.ceil((double)maxStack * ((double)stack / 100)); + } else stack = Math.min(max + 1, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + if (stack == 1) { + data.set(x, height, z, top); + return; + } + for (int i = 0; i < stack; i++) { if (height - i < 0 || height - i > getEngine().getHeight()) { continue; diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java index 6ddbb59f7..675a10dce 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java @@ -18,6 +18,7 @@ package com.volmit.iris.engine.decorator; +import com.volmit.iris.Iris; import com.volmit.iris.engine.cache.Cache; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.hunk.Hunk; @@ -44,11 +45,19 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(stack, max - height + 2); + if (decorator.isScaleStack()) { + int maxStack = max - height; + stack = (int)Math.ceil((double)maxStack * ((double)stack / 100)); + } else stack = Math.min(stack, max - height); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + if (stack == 1) { + data.set(x, height, z, top); + return; + } + for (int i = 0; i < stack; i++) { if (height + i > max || height + i > getEngine().getHeight()) { continue; diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java index a00280bcf..0c3e7217e 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java @@ -18,6 +18,7 @@ package com.volmit.iris.engine.decorator; +import com.volmit.iris.Iris; import com.volmit.iris.engine.cache.Cache; import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.hunk.Hunk; @@ -44,7 +45,10 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - + if (decorator.isScaleStack()) { + int maxStack = max - height; + stack = (int) Math.ceil((double)maxStack * ((double)stack / 100)); + } BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); for (int i = 0; i < stack; i++) { diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java index e54aeb1c3..f68b03581 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java @@ -49,7 +49,10 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(max - height, stack); + if (decorator.isScaleStack()) { + int maxStack = max - height; + stack = (int)Math.ceil((double)maxStack * ((double)stack / 100)); + } else stack = Math.min(max - height, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java index 04e4bfe8a..1545e67eb 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java @@ -77,10 +77,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { } int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); - stack = Math.min(height - max, stack); + if (decorator.isScaleStack()) { + int maxStack = max - height; + stack = (int) Math.ceil((double)maxStack * ((double)stack / 100)); + } else stack = Math.min(height - max, stack); BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + if (stack == 1) { + data.set(x, height, z, top); + return; + } + for (int i = 0; i < stack; i++) { double threshold = ((double) i) / (stack - 1); bd = threshold >= decorator.getTopThreshold() ? top : fill; diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java index 6b08a5d67..8c512230c 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java @@ -56,17 +56,20 @@ public class IrisDecorator { @DependsOn({"stackMin", "stackMax"}) @MinNumber(1) @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The minimum repeat stack height (setting to 3 would stack 3 of on top of each other") private int stackMin = 1; @DependsOn({"stackMin", "stackMax"}) @MinNumber(1) @MaxNumber(256) // TODO: WARNING HEIGHT - @Desc("The maximum repeat stack height") private int stackMax = 1; + @DependsOn({"stackMin", "stackMax"}) + @Desc("Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height" + + "\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height") + private boolean scaleStack = false; + @Required @MinNumber(0) @MaxNumber(1) @@ -168,7 +171,7 @@ public class IrisDecorator { public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) { if (getBlockDataTops(data).isEmpty()) { - return null; + return getBlockData100(b, rng, x, z, data); } double xx = x / style.getZoom(); diff --git a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java index 741b75892..04db9e6f9 100644 --- a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java @@ -72,7 +72,7 @@ public abstract class MortarCommand implements ICommand { } if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { - sender.player().getWorld().playSound(sender.player().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f); + sender.player().playSound(sender.player().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f); } return v; From 38776e74bc1785f949ddf51014fd6cbb462019a6 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Tue, 27 Jul 2021 04:12:34 +1200 Subject: [PATCH 4/6] Decorator Changes & Jigsaw Fix - Fixed Jigsaw pieces with rotation disabled rotating randomly. They will now inherit the parent's rotation - Fixed pallete of blocks in stacked blocks not being chosen randomly on the Y axis Fixes for issues in the last commit: - Fixed CEILING decorators not working with scaleStack --- .../decorator/IrisCeilingDecorator.java | 19 +++++++++---------- .../decorator/IrisSeaFloorDecorator.java | 14 +++++++------- .../decorator/IrisSeaSurfaceDecorator.java | 17 ++++++++++++----- .../decorator/IrisShoreLineDecorator.java | 14 ++++++++++---- .../decorator/IrisSurfaceDecorator.java | 11 ++++++----- .../iris/engine/jigsaw/PlannedPiece.java | 10 ++++++---- .../iris/engine/jigsaw/PlannedStructure.java | 16 ++++++++++++++-- .../iris/engine/object/IrisDecorator.java | 14 ++++++++------ 8 files changed, 72 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java index 5fc0c7279..c7cde5469 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisCeilingDecorator.java @@ -40,30 +40,29 @@ public class IrisCeilingDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { if (height >= 0 || height < getEngine().getHeight()) { - data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); if (decorator.isScaleStack()) { - int maxStack = max - height; - stack = (int) Math.ceil((double)maxStack * ((double)stack / 100)); - } else stack = Math.min(max + 1, stack); - - BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); - BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + stack = (int) Math.ceil((double)max * ((double)stack / 100)); + } else stack = Math.min(max, stack); if (stack == 1) { - data.set(x, height, z, top); + data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } for (int i = 0; i < stack; i++) { - if (height - i < 0 || height - i > getEngine().getHeight()) { + int h = height - i; + if (h < getEngine().getMinHeight()) { continue; } double threshold = (((double) i) / (double) (stack - 1)); - data.set(x, height - i, z, threshold >= decorator.getTopThreshold() ? top : fill); + data.set(x, h, z, threshold >= decorator.getTopThreshold() ? + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java index 675a10dce..9cedfdfe1 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaFloorDecorator.java @@ -41,7 +41,7 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { if (height >= 0 || height < getEngine().getHeight()) { - data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); @@ -50,21 +50,21 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator { stack = (int)Math.ceil((double)maxStack * ((double)stack / 100)); } else stack = Math.min(stack, max - height); - BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); - BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); - if (stack == 1) { - data.set(x, height, z, top); + data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } for (int i = 0; i < stack; i++) { - if (height + i > max || height + i > getEngine().getHeight()) { + int h = height + i; + if (h > max || h > getEngine().getHeight()) { continue; } double threshold = ((double) i) / (stack - 1); - data.set(x, height + i, z, threshold >= decorator.getTopThreshold() ? top : fill); + data.set(x, h, z, threshold >= decorator.getTopThreshold() ? + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java index 0c3e7217e..9ad2250b7 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSeaSurfaceDecorator.java @@ -41,7 +41,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { if (height >= 0 || height < getEngine().getHeight()) { - data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); @@ -49,15 +49,22 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator { int maxStack = max - height; stack = (int) Math.ceil((double)maxStack * ((double)stack / 100)); } - BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); - BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + + if (stack == 1) { + data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); + return; + } + for (int i = 0; i < stack; i++) { - if (height + i >= max || height + i >= getEngine().getHeight()) { + int h = height + i; + if (h >= max || h >= getEngine().getHeight()) { continue; } double threshold = ((double) i) / (stack - 1); - data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill); + data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ? + decorator.getBlockDataForTop(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java index f68b03581..ef2d8fef2 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisShoreLineDecorator.java @@ -46,19 +46,25 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { - data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); + data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData())); } else { int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData()); if (decorator.isScaleStack()) { int maxStack = max - height; stack = (int)Math.ceil((double)maxStack * ((double)stack / 100)); } else stack = Math.min(max - height, stack); - BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); - BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + + if (stack == 1) { + data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); + return; + } for (int i = 0; i < stack; i++) { + int h = height + i; double threshold = ((double) i) / (stack - 1); - data.set(x, height + 1 + i, z, threshold >= decorator.getTopThreshold() ? top : fill); + data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ? + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData())); } } } diff --git a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java index 1545e67eb..7b3d14e5a 100644 --- a/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java +++ b/src/main/java/com/volmit/iris/engine/decorator/IrisSurfaceDecorator.java @@ -49,7 +49,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { if (decorator != null) { if (!decorator.isStacking()) { - bd = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); + bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()); if (!underwater) { if (!canGoOn(bd, bdx)) { @@ -81,17 +81,18 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator { int maxStack = max - height; stack = (int) Math.ceil((double)maxStack * ((double)stack / 100)); } else stack = Math.min(height - max, stack); - BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()); - BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData()); if (stack == 1) { - data.set(x, height, z, top); + data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData())); return; } for (int i = 0; i < stack; i++) { + int h = height + i; double threshold = ((double) i) / (stack - 1); - bd = threshold >= decorator.getTopThreshold() ? top : fill; + bd = threshold >= decorator.getTopThreshold() ? + decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) : + decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()); if (bd == null) { break; diff --git a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java index d323ab8c3..b8357151e 100644 --- a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java +++ b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedPiece.java @@ -49,7 +49,6 @@ public class PlannedPiece { private IrisDataManager data; private KList connected; private boolean dead = false; - private int rotationKey; private AxisAlignedBB box; private PlannedStructure structure; @@ -58,11 +57,14 @@ public class PlannedPiece { } public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, int rx, int ry, int rz) { + this(structure, position, piece, IrisObjectRotation.of(rx * 90D, ry * 90D, rz * 90D)); + } + + public PlannedPiece(PlannedStructure structure, IrisPosition position, IrisJigsawPiece piece, IrisObjectRotation rot) { this.structure = structure; this.position = position; - rotationKey = (rz * 100) + (rx * 10) + ry; this.data = piece.getLoader(); - this.rotation = IrisObjectRotation.of(rx * 90D, ry * 90D, rz * 90D); + this.setRotation(rot); this.object = structure.rotated(piece, rotation); this.piece = rotation.rotateCopy(piece); this.piece.setLoadKey(piece.getLoadKey()); @@ -76,7 +78,7 @@ public class PlannedPiece { } public String toString() { - return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotationKey + "]"; + return piece.getLoadKey() + "@(" + position.getX() + "," + position.getY() + "," + position.getZ() + ")[rot:" + rotation.toString() + "]"; } public AxisAlignedBB getBox() { diff --git a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java index a147a281c..6168c1a7b 100644 --- a/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java +++ b/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java @@ -211,6 +211,12 @@ public class PlannedStructure { } private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea) { + if (!piece.getPiece().getPlacementOptions().getRotation().isEnabled()) { + if (generateRotatedPiece(piece, pieceConnector, idea, 0, 0, 0)) { + return true; + } + } + KList forder1 = new KList().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng); KList forder2 = new KList().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng); @@ -238,8 +244,10 @@ public class PlannedStructure { return false; } - private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, int x, int y, int z) { - PlannedPiece test = new PlannedPiece(this, piece.getPosition(), idea, x, y, z); + private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, IrisObjectRotation rotation) { + if (!idea.getPlacementOptions().getRotation().isEnabled()) rotation = piece.getRotation(); //Inherit parent rotation + + PlannedPiece test = new PlannedPiece(this, piece.getPosition(), idea, rotation); for (IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) { if (generatePositionedPiece(piece, pieceConnector, test, j)) { @@ -250,6 +258,10 @@ public class PlannedStructure { return false; } + private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, int x, int y, int z) { + return generateRotatedPiece(piece, pieceConnector, idea, IrisObjectRotation.of(x, y, z)); + } + private boolean generatePositionedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, PlannedPiece test, diff --git a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java index 8c512230c..99d5dd2c6 100644 --- a/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java +++ b/src/main/java/com/volmit/iris/engine/object/IrisDecorator.java @@ -148,17 +148,19 @@ public class IrisDecorator { return null; } - public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) { + public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisDataManager data) { if (getBlockData(data).isEmpty()) { Iris.warn("Empty Block Data for " + b.getName()); return null; } double xx = x; + double yy = y; double zz = z; if (!getVarianceGenerator(rng, data).isStatic()) { xx = x / style.getZoom(); + yy = y / style.getZoom(); zz = z / style.getZoom(); } @@ -166,23 +168,23 @@ public class IrisDecorator { return getBlockData(data).get(0); } - return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x).clone(); //X and Z must be switched + return getVarianceGenerator(rng, data).fit(getBlockData(data), z, y, x).clone(); //X and Z must be switched } - public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) { + public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisDataManager data) { if (getBlockDataTops(data).isEmpty()) { - return getBlockData100(b, rng, x, z, data); + return getBlockData100(b, rng, x, y, z, data); } double xx = x / style.getZoom(); double zz = z / style.getZoom(); - if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { + if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here if (getBlockData(data).size() == 1) { return getBlockDataTops(data).get(0); } - return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, x); //X and Z must be switched + return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, y, x); //X and Z must be switched } return null; From 3beda9c201e9db2b00fb01d60bf1966ee56b700f Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Tue, 27 Jul 2021 14:33:46 +1200 Subject: [PATCH 5/6] Black Hole --- .../engine/actuator/IrisDecorantActuator.java | 29 ++++--- .../iris/engine/object/IrisCaveBiome.java | 86 ------------------- 2 files changed, 16 insertions(+), 99 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java index 24f512354..6d2c245f4 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java @@ -38,7 +38,7 @@ import java.util.function.Predicate; public class IrisDecorantActuator extends EngineAssignedActuator { private static final Predicate PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA); - private static BiPredicate PREDICATE_CAVELIQUID = (d, i) -> false; + private static BiPredicate PREDICATE_CAVELIQUID = null; private final RNG rng; @Getter private final EngineDecorator surfaceDecorator; @@ -62,20 +62,23 @@ public class IrisDecorantActuator extends EngineAssignedActuator { shoreLineDecorator = new IrisShoreLineDecorator(getEngine()); seaFloorDecorator = new IrisSeaFloorDecorator(getEngine()); - PREDICATE_CAVELIQUID = (b, y) -> { - for (IrisCaveLayer layer : getEngine().getDimension().getCaveLayers()) { - if (!layer.getFluid().hasFluid(getData())) { - continue; - } + //Can't be created without an instance of the actuator due to referencing the engine + if (PREDICATE_CAVELIQUID == null) { + PREDICATE_CAVELIQUID = (b, y) -> { + for (IrisCaveLayer layer : getEngine().getDimension().getCaveLayers()) { + if (!layer.getFluid().hasFluid(getData())) { + continue; + } - if (layer.getFluid().isInverseHeight() && y >= layer.getFluid().getFluidHeight()) { - if (b.matches(layer.getFluid().getFluid(getData()))) return true; - } else if (!layer.getFluid().isInverseHeight() && y <= layer.getFluid().getFluidHeight()) { - if (b.matches(layer.getFluid().getFluid(getData()))) return true; + if (layer.getFluid().isInverseHeight() && y >= layer.getFluid().getFluidHeight()) { + if (b.matches(layer.getFluid().getFluid(getData()))) return true; + } else if (!layer.getFluid().isInverseHeight() && y <= layer.getFluid().getFluidHeight()) { + if (b.matches(layer.getFluid().getFluid(getData()))) return true; + } } - } - return false; - }; + return false; + }; + } } @BlockCoordinates diff --git a/src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java b/src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java deleted file mode 100644 index 79427e68a..000000000 --- a/src/main/java/com/volmit/iris/engine/object/IrisCaveBiome.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2021 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.volmit.iris.engine.object; - -import com.volmit.iris.Iris; -import com.volmit.iris.core.IrisDataManager; -import com.volmit.iris.core.gui.components.RenderType; -import com.volmit.iris.engine.IrisComplex; -import com.volmit.iris.engine.cache.AtomicCache; -import com.volmit.iris.engine.data.B; -import com.volmit.iris.engine.data.DataProvider; -import com.volmit.iris.engine.framework.Engine; -import com.volmit.iris.engine.framework.IrisAccess; -import com.volmit.iris.engine.noise.CNG; -import com.volmit.iris.engine.object.annotations.ArrayType; -import com.volmit.iris.engine.object.annotations.DependsOn; -import com.volmit.iris.engine.object.annotations.Desc; -import com.volmit.iris.engine.object.annotations.MaxNumber; -import com.volmit.iris.engine.object.annotations.MinNumber; -import com.volmit.iris.engine.object.annotations.RegistryListBiome; -import com.volmit.iris.engine.object.annotations.Required; -import com.volmit.iris.engine.object.common.IRare; -import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.collection.KMap; -import com.volmit.iris.util.collection.KSet; -import com.volmit.iris.util.data.VanillaBiomeMap; -import com.volmit.iris.util.inventorygui.RandomColor; -import com.volmit.iris.util.math.RNG; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.Accessors; -import org.bukkit.block.Biome; -import org.bukkit.block.data.BlockData; - -import java.awt.*; - -@SuppressWarnings("DefaultAnnotationParam") -@Accessors(chain = true) -@NoArgsConstructor -@AllArgsConstructor - -@Desc("Represents a cave biome in iris. Cave biomes are placed inside of caves and hold objects.\nA biome consists of layers (block palletes), decorations, objects & generators.") -@Data -@EqualsAndHashCode(callSuper = true) -public class IrisCaveBiome extends IrisBiome { - - @Required - @ArrayType(min = 1, type = IrisBiomePaletteLayer.class) - @Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.") - private KList lavaLayers = new KList().qadd(new IrisBiomePaletteLayer()); - - @Required - @ArrayType(min = 1, type = IrisBiomePaletteLayer.class) - @Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.") - private KList waterLayers = new KList().qadd(new IrisBiomePaletteLayer()); - - - public KList getLavaLayers() { - return lavaLayers.isEmpty() ? getLayers() : lavaLayers; - } - - public KList getWaterLayers() { - return waterLayers.isEmpty() ? getLayers() : waterLayers; - } - - public boolean freezeLava = false; - public boolean freezeWater = false; -} From 1797df7017b322240c04c527da6e71a070c28159 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Tue, 27 Jul 2021 14:40:14 +1200 Subject: [PATCH 6/6] Reblackhole --- .../engine/actuator/IrisDecorantActuator.java | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java index 6d2c245f4..b9a4ef0de 100644 --- a/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java +++ b/src/main/java/com/volmit/iris/engine/actuator/IrisDecorantActuator.java @@ -38,7 +38,7 @@ import java.util.function.Predicate; public class IrisDecorantActuator extends EngineAssignedActuator { private static final Predicate PREDICATE_SOLID = (b) -> b != null && !b.getMaterial().isAir() && !b.getMaterial().equals(Material.WATER) && !b.getMaterial().equals(Material.LAVA); - private static BiPredicate PREDICATE_CAVELIQUID = null; + private BiPredicate PREDICATE_CAVELIQUID = null; private final RNG rng; @Getter private final EngineDecorator surfaceDecorator; @@ -63,22 +63,21 @@ public class IrisDecorantActuator extends EngineAssignedActuator { seaFloorDecorator = new IrisSeaFloorDecorator(getEngine()); //Can't be created without an instance of the actuator due to referencing the engine - if (PREDICATE_CAVELIQUID == null) { - PREDICATE_CAVELIQUID = (b, y) -> { - for (IrisCaveLayer layer : getEngine().getDimension().getCaveLayers()) { - if (!layer.getFluid().hasFluid(getData())) { - continue; - } - - if (layer.getFluid().isInverseHeight() && y >= layer.getFluid().getFluidHeight()) { - if (b.matches(layer.getFluid().getFluid(getData()))) return true; - } else if (!layer.getFluid().isInverseHeight() && y <= layer.getFluid().getFluidHeight()) { - if (b.matches(layer.getFluid().getFluid(getData()))) return true; - } + PREDICATE_CAVELIQUID = (b, y) -> { + for (IrisCaveLayer layer : getEngine().getDimension().getCaveLayers()) { + if (!layer.getFluid().hasFluid(getData())) { + continue; } - return false; - }; - } + + if (layer.getFluid().isInverseHeight() && y >= layer.getFluid().getFluidHeight()) { + if (b.matches(layer.getFluid().getFluid(getData()))) return true; + } else if (!layer.getFluid().isInverseHeight() && y <= layer.getFluid().getFluidHeight()) { + if (b.matches(layer.getFluid().getFluid(getData()))) return true; + } + } + return false; + }; + } @BlockCoordinates