From 94a7692735e6711cf2c7c6bcd1eedbc7ee50d045 Mon Sep 17 00:00:00 2001 From: Julian Krings Date: Thu, 17 Oct 2024 18:48:17 +0200 Subject: [PATCH] add force place for stronghold --- .../java/com/volmit/iris/core/commands/CommandJigsaw.java | 2 +- .../com/volmit/iris/engine/jigsaw/PlannedStructure.java | 7 ++++++- .../engine/mantle/components/MantleJigsawComponent.java | 8 ++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java b/core/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java index 710184027..3022b866c 100644 --- a/core/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java +++ b/core/src/main/java/com/volmit/iris/core/commands/CommandJigsaw.java @@ -60,7 +60,7 @@ public class CommandJigsaw implements DecreeExecutor { try { var world = world(); WorldObjectPlacer placer = new WorldObjectPlacer(world); - PlannedStructure ps = new PlannedStructure(structure, new IrisPosition(player().getLocation().add(0, world.getMinHeight(), 0)), new RNG()); + PlannedStructure ps = new PlannedStructure(structure, new IrisPosition(player().getLocation().add(0, world.getMinHeight(), 0)), new RNG(), true); VolmitSender sender = sender(); sender.sendMessage(C.GREEN + "Generated " + ps.getPieces().size() + " pieces in " + Form.duration(p.getMilliseconds(), 2)); ps.place(placer, failed -> sender.sendMessage(failed ? C.GREEN + "Placed the structure!" : C.RED + "Failed to place the structure!")); 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 9ee15169b..b2ba86d4f 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 @@ -50,16 +50,18 @@ public class PlannedStructure { private IrisPosition position; private IrisData data; private RNG rng; + private boolean forcePlace; private boolean verbose; private boolean terminating; - public PlannedStructure(IrisJigsawStructure structure, IrisPosition position, RNG rng) { + public PlannedStructure(IrisJigsawStructure structure, IrisPosition position, RNG rng, boolean forcePlace) { terminating = false; verbose = true; this.pieces = new KList<>(); this.structure = structure; this.position = position; this.rng = rng; + this.forcePlace = forcePlace; this.data = structure.getLoader(); generateStartPiece(); @@ -108,6 +110,9 @@ public class PlannedStructure { } else { options.setMode(i.getPiece().getPlaceMode()); } + if (forcePlace) { + options.setForcePlace(true); + } IrisObject v = i.getObject(); int sx = (v.getW() / 2); 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 17e192c19..ac091e346 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 @@ -66,7 +66,7 @@ public class MantleJigsawComponent extends IrisMantleComponent { for (Position2 pos : poss) { if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) { IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold()); - place(writer, pos.toIris(), structure, new RNG(seed)); + place(writer, pos.toIris(), structure, new RNG(seed), true); return; } } @@ -92,7 +92,7 @@ public class MantleJigsawComponent extends IrisMantleComponent { RNG rng = new RNG(seed); IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); - return place(writer, position, structure, rng); + return place(writer, position, structure, rng, false); } @ChunkCoordinates @@ -161,8 +161,8 @@ public class MantleJigsawComponent extends IrisMantleComponent { } @BlockCoordinates - private boolean place(MantleWriter writer, IrisPosition position, IrisJigsawStructure structure, RNG rng) { - return new PlannedStructure(structure, position, rng).place(writer, getMantle(), writer.getEngine()); + private boolean place(MantleWriter writer, IrisPosition position, IrisJigsawStructure structure, RNG rng, boolean forcePlace) { + return new PlannedStructure(structure, position, rng, forcePlace).place(writer, getMantle(), writer.getEngine()); } private long jigsaw() {