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 {
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!"));

View File

@ -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);

View File

@ -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() {