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;