add force place for stronghold

This commit is contained in:
Julian Krings 2024-10-17 18:48:17 +02:00
parent 8b803a87f0
commit 94a7692735
3 changed files with 11 additions and 6 deletions

View File

@ -60,7 +60,7 @@ public class CommandJigsaw implements DecreeExecutor {
try { try {
var world = world(); var world = world();
WorldObjectPlacer placer = new WorldObjectPlacer(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(); VolmitSender sender = sender();
sender.sendMessage(C.GREEN + "Generated " + ps.getPieces().size() + " pieces in " + Form.duration(p.getMilliseconds(), 2)); 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!")); ps.place(placer, failed -> sender.sendMessage(failed ? C.GREEN + "Placed the structure!" : C.RED + "Failed to place the structure!"));

View File

@ -50,16 +50,18 @@ public class PlannedStructure {
private IrisPosition position; private IrisPosition position;
private IrisData data; private IrisData data;
private RNG rng; private RNG rng;
private boolean forcePlace;
private boolean verbose; private boolean verbose;
private boolean terminating; private boolean terminating;
public PlannedStructure(IrisJigsawStructure structure, IrisPosition position, RNG rng) { public PlannedStructure(IrisJigsawStructure structure, IrisPosition position, RNG rng, boolean forcePlace) {
terminating = false; terminating = false;
verbose = true; verbose = true;
this.pieces = new KList<>(); this.pieces = new KList<>();
this.structure = structure; this.structure = structure;
this.position = position; this.position = position;
this.rng = rng; this.rng = rng;
this.forcePlace = forcePlace;
this.data = structure.getLoader(); this.data = structure.getLoader();
generateStartPiece(); generateStartPiece();
@ -108,6 +110,9 @@ public class PlannedStructure {
} else { } else {
options.setMode(i.getPiece().getPlaceMode()); options.setMode(i.getPiece().getPlaceMode());
} }
if (forcePlace) {
options.setForcePlace(true);
}
IrisObject v = i.getObject(); IrisObject v = i.getObject();
int sx = (v.getW() / 2); int sx = (v.getW() / 2);

View File

@ -66,7 +66,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
for (Position2 pos : poss) { for (Position2 pos : poss) {
if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) { if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold()); 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; return;
} }
} }
@ -92,7 +92,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
RNG rng = new RNG(seed); RNG rng = new RNG(seed);
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
return place(writer, position, structure, rng); return place(writer, position, structure, rng, false);
} }
@ChunkCoordinates @ChunkCoordinates
@ -161,8 +161,8 @@ public class MantleJigsawComponent extends IrisMantleComponent {
} }
@BlockCoordinates @BlockCoordinates
private boolean place(MantleWriter writer, IrisPosition position, IrisJigsawStructure structure, RNG rng) { private boolean place(MantleWriter writer, IrisPosition position, IrisJigsawStructure structure, RNG rng, boolean forcePlace) {
return new PlannedStructure(structure, position, rng).place(writer, getMantle(), writer.getEngine()); return new PlannedStructure(structure, position, rng, forcePlace).place(writer, getMantle(), writer.getEngine());
} }
private long jigsaw() { private long jigsaw() {