From 9843f18c96959b8bf8007eaaeb506814ee1b526c Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Wed, 22 Nov 2023 13:45:55 +0100 Subject: [PATCH 1/3] Fix jigsaw piece collision/merging --- .../java/com/volmit/iris/engine/jigsaw/PlannedStructure.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java b/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java index c8d0dcad4..762534340 100644 --- a/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java +++ b/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java @@ -28,7 +28,6 @@ import com.volmit.iris.engine.object.*; import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.math.RNG; -import com.volmit.iris.util.matter.slices.JigsawPieceMatter; import com.volmit.iris.util.matter.slices.container.JigsawPieceContainer; import lombok.Data; import org.bukkit.Axis; @@ -361,10 +360,6 @@ public class PlannedStructure { public boolean collidesWith(PlannedPiece piece, PlannedPiece ignore) { for (PlannedPiece i : pieces) { - if (i.equals(ignore)) { - continue; - } - if (i.collidesWith(piece)) { return true; } From b098c210ceec39c961196336add627f6da0a8791 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Fri, 24 Nov 2023 17:03:32 +0100 Subject: [PATCH 2/3] removed unnecessary code --- .../iris/engine/jigsaw/PlannedStructure.java | 71 ++----------------- 1 file changed, 6 insertions(+), 65 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java b/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java index 762534340..81986c252 100644 --- a/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java +++ b/core/src/main/java/com/volmit/iris/engine/jigsaw/PlannedStructure.java @@ -74,7 +74,7 @@ public class PlannedStructure { } } - public void place(MantleWriter placer, Mantle e, Engine eng) { + public void place(IObjectPlacer placer, Mantle e, Engine eng) { IrisObjectPlacement options = new IrisObjectPlacement(); options.getRotation().setEnabled(false); int startHeight = pieces.get(0).getPosition().getY(); @@ -84,7 +84,7 @@ public class PlannedStructure { } } - public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, MantleWriter placer, Mantle e, Engine eng) { + public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, Mantle e, Engine eng) { IrisObjectPlacement options = o; if (i.getPiece().getPlacementOptions() != null) { @@ -122,69 +122,10 @@ public class PlannedStructure { int id = rng.i(0, Integer.MAX_VALUE); JigsawPieceContainer container = JigsawPieceContainer.toContainer(i.getPiece()); - vo.place(xx, height, zz, new IObjectPlacer() { - @Override - public int getHighest(int x, int z, IrisData data) { - return placer.getHighest(x, z, data); - } - - @Override - public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) { - return placer.getHighest(x, z, data, ignoreFluid); - } - - @Override - public void set(int x, int y, int z, BlockData d) { - placer.setData(x, y, z, container); - placer.set(x, y, z, d); - } - - @Override - public BlockData get(int x, int y, int z) { - placer.setData(x, y, z, container); - return placer.get(x, y, z); - } - - @Override - public boolean isPreventingDecay() { - return placer.isPreventingDecay(); - } - - @Override - public boolean isCarved(int x, int y, int z) { - return placer.isCarved(x, y, z); - } - - @Override - public boolean isSolid(int x, int y, int z) { - return placer.isSolid(x, y, z); - } - - @Override - public boolean isUnderwater(int x, int z) { - return placer.isUnderwater(x, z); - } - - @Override - public int getFluidHeight() { - return placer.getFluidHeight(); - } - - @Override - public boolean isDebugSmartBore() { - return placer.isDebugSmartBore(); - } - - @Override - public void setTile(int xx, int yy, int zz, TileData tile) { - placer.setTile(xx, yy, zz, tile); - } - - @Override - public Engine getEngine() { - return placer.getEngine(); - } - }, options, rng, (b, data) -> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData()); + vo.place(xx, height, zz, placer, options, rng, (b, data) -> { + e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id); + e.set(b.getX(), b.getY(), b.getZ(), container); + }, null, getData()); } public void place(World world) { From 7263d102c74b7c8099246b4023ecbe8f95b775ca Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Wed, 29 Nov 2023 14:34:00 +0100 Subject: [PATCH 3/3] cleanup / possibly fix a bug --- .../components/MantleJigsawComponent.java | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java b/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java index fccbd9630..fdb272015 100644 --- a/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java +++ b/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java @@ -23,6 +23,7 @@ import com.volmit.iris.engine.mantle.EngineMantle; import com.volmit.iris.engine.mantle.IrisMantleComponent; import com.volmit.iris.engine.mantle.MantleWriter; import com.volmit.iris.engine.object.*; +import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.context.ChunkContext; import com.volmit.iris.util.documentation.BlockCoordinates; import com.volmit.iris.util.documentation.ChunkCoordinates; @@ -53,8 +54,6 @@ public class MantleJigsawComponent extends IrisMantleComponent { @ChunkCoordinates private void generateJigsaw(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) { - boolean placed = false; - if (getDimension().getStronghold() != null) { List poss = getDimension().getStrongholds(seed()); @@ -63,43 +62,30 @@ public class MantleJigsawComponent extends IrisMantleComponent { if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) { IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold()); place(writer, pos.toIris(), structure, rng); - placed = true; + return; } } } } - if (!placed) { - for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { - IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); - IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); - place(writer, position, structure, rng); - placed = true; - } - } - } + boolean placed = placeStructures(writer, rng, x, z, biome.getJigsawStructures()); + if (!placed) + placed = placeStructures(writer, rng, x, z, region.getJigsawStructures()); + if (!placed) + placeStructures(writer, rng, x, z, getDimension().getJigsawStructures()); + } - if (!placed) { - for (IrisJigsawStructurePlacement i : region.getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { - IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); - IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); - place(writer, position, structure, rng); - placed = true; - } - } - } - - if (!placed) { - for (IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) { - if (rng.nextInt(i.getRarity()) == 0) { - IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); - IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); - place(writer, position, structure, rng); - } + @ChunkCoordinates + private boolean placeStructures(MantleWriter writer, RNG rng, int x, int z, KList structures) { + for (IrisJigsawStructurePlacement i : structures) { + if (rng.nextInt(i.getRarity()) == 0) { + IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); + IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); + place(writer, position, structure, rng); + return true; } } + return false; } @ChunkCoordinates