mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 02:04:51 +00:00
Fix structure river findings
- End object placements in a finally at all four MantleObjectComponent sites - Split recordObjectPlacement for accepted ranges from endObjectPlacement for the water flag - Place forced single-piece structures after admission and let the MantleWriter veto protect the water - Drop the allowWater parameter from piecePlacement - Validate allowWater as a boolean and add it to anonymous grid identity when true - Add placement exit, forced piece, REPLACE_SOURCE, world Y -1 and placePieces failure tests - Add modded stage river start and policy water tests - Rename the misleading planner river test
This commit is contained in:
18 files changed
+922
-64
No files matched your search
@@ -165,7 +165,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
stilt != null && stilt.isSupportNonOccluding(), placement.isAllowWater());
|
||||
ObjectPlaceMode mode = structure.getPlaceMode();
|
||||
int failedPieces = 0;
|
||||
int water = writer.beginObjectPlacement(run.allowWater());
|
||||
writer.beginObjectPlacement(run.allowWater());
|
||||
try {
|
||||
if (placement.isAnchoredUnderground()) {
|
||||
ObjectPlaceMode undergroundMode = (mode == ObjectPlaceMode.ORGANIC_STILT || mode == ObjectPlaceMode.CEILING_HANG)
|
||||
@@ -190,7 +190,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
placeFoundation(writer, run.foundationColumns(), stilt, rng, !placement.isAnchoredUnderground());
|
||||
}
|
||||
} finally {
|
||||
writer.endObjectPlacement(water);
|
||||
writer.endObjectPlacement();
|
||||
}
|
||||
return failedPieces;
|
||||
}
|
||||
@@ -569,7 +569,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
boolean sampledHeight) {
|
||||
IrisObject object = p.getObject();
|
||||
String objectKey = object.getLoadKey();
|
||||
IrisObjectPlacement config = piecePlacement(run.structure(), p, mode, run.allowWater());
|
||||
IrisObjectPlacement config = piecePlacement(run.structure(), p, mode);
|
||||
String marker = structurePlacementMarker(run.structure(), p, objectKey);
|
||||
BiConsumer<BlockPosition, NativeBlockState> listener = (position, state) -> {
|
||||
StructureFoundationPlanner.recordBaseCell(
|
||||
@@ -584,8 +584,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
: object.place(p.getX(), p.getY() - getEngineMantle().getEngine().getMinHeight(), p.getZ(), writer, config, run.rng(), listener, null, getData());
|
||||
}
|
||||
|
||||
static IrisObjectPlacement piecePlacement(IrisStructure structure, PlacedStructurePiece piece, ObjectPlaceMode mode,
|
||||
boolean allowWater) {
|
||||
static IrisObjectPlacement piecePlacement(IrisStructure structure, PlacedStructurePiece piece, ObjectPlaceMode mode) {
|
||||
IrisObjectPlacement config = structure.createLootPlacement(piece.getObject().getLoadKey());
|
||||
config.setMode(mode);
|
||||
config.setRotation(piece.getRotation());
|
||||
@@ -594,7 +593,7 @@ public class IrisStructureComponent extends IrisMantleComponent {
|
||||
}
|
||||
if (mode != ObjectPlaceMode.STRUCTURE_PIECE && mode != ObjectPlaceMode.FLOATING) {
|
||||
config.setForcePlace(true);
|
||||
config.setForcedByStructure(!allowWater);
|
||||
config.setForcedByStructure(true);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -794,7 +794,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
}, null, getData());
|
||||
}
|
||||
if (placeResult >= 0 && (!carving || commitResult == CaveObjectPlacementTransaction.CommitResult.COMMITTED)) {
|
||||
writer.endObjectPlacement(continuation);
|
||||
writer.recordObjectPlacement(continuation);
|
||||
}
|
||||
if (golden) {
|
||||
IrisLogging.debug("Goldendebug procedural result: chunk=" + x + "," + z
|
||||
@@ -809,6 +809,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
GenerationFailures.rethrowEngineFailure(e);
|
||||
IrisLogging.reportError(e);
|
||||
IrisLogging.error("Failed to place procedural object '" + p.getName() + "' in " + scope);
|
||||
} finally {
|
||||
writer.endObjectPlacement();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1027,7 +1029,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
}, null, getData());
|
||||
|
||||
if (result >= 0) {
|
||||
writer.endObjectPlacement(continuation);
|
||||
writer.recordObjectPlacement(continuation);
|
||||
placed++;
|
||||
} else {
|
||||
rejected++;
|
||||
@@ -1062,6 +1064,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
+ " densityIndex=" + i
|
||||
+ " density=" + density
|
||||
+ " error=" + e.getClass().getSimpleName() + ":" + e.getMessage());
|
||||
} finally {
|
||||
writer.endObjectPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1216,7 +1220,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
int result = contained.resultY();
|
||||
boolean wroteBlocks = contained.commitResult() == CaveObjectPlacementTransaction.CommitResult.COMMITTED;
|
||||
if (wroteBlocks) {
|
||||
writer.endObjectPlacement(continuation);
|
||||
writer.recordObjectPlacement(continuation);
|
||||
placed++;
|
||||
} else {
|
||||
rejected++;
|
||||
@@ -1284,6 +1288,8 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
y,
|
||||
e
|
||||
);
|
||||
} finally {
|
||||
writer.endObjectPlacement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,20 +1401,24 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
boolean treePlacement = isTreePlacement(v, objectPlacement);
|
||||
String marker = placementMarker(v, id, "upper");
|
||||
int continuation = writer.beginObjectPlacement(placement.entersWater());
|
||||
int result = v.place(xx, anchorY, zz, writer, placement, rng, (b, data) -> {
|
||||
if (marker != null) {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), marker);
|
||||
int result;
|
||||
try {
|
||||
result = v.place(xx, anchorY, zz, writer, placement, rng, (b, data) -> {
|
||||
if (marker != null) {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), marker);
|
||||
}
|
||||
if (treePlacement && marker != null) {
|
||||
writeTreeMaterial(writer, b.getX(), b.getY(), b.getZ(), data);
|
||||
}
|
||||
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
||||
}
|
||||
}, null, getData());
|
||||
if (result >= 0) {
|
||||
writer.recordObjectPlacement(continuation);
|
||||
}
|
||||
if (treePlacement && marker != null) {
|
||||
writeTreeMaterial(writer, b.getX(), b.getY(), b.getZ(), data);
|
||||
}
|
||||
if (placement.isDolphinTarget() && placement.isUnderwater() && B.isStorageChest(data)) {
|
||||
writer.setData(b.getX(), b.getY(), b.getZ(), MatterStructurePOI.BURIED_TREASURE);
|
||||
}
|
||||
}, null, getData());
|
||||
|
||||
if (result >= 0) {
|
||||
writer.endObjectPlacement(continuation);
|
||||
} finally {
|
||||
writer.endObjectPlacement();
|
||||
}
|
||||
if (traceRegen) {
|
||||
IrisLogging.debug("Upper object placement: chunk=" + chunkX + "," + chunkZ
|
||||
|
||||
@@ -227,7 +227,7 @@ public class MantleWriter implements ObjectPassPlacer, AutoCloseable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endObjectPlacement(int checkpoint) {
|
||||
public void endObjectPlacement() {
|
||||
objectWater.remove();
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -79,13 +79,17 @@ final class ObjectDestinationTransaction implements ObjectPassPlacer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endObjectPlacement(int checkpoint) {
|
||||
waterPlacement = false;
|
||||
public void recordObjectPlacement(int checkpoint) {
|
||||
if (checkpoint >= 0 && checkpoint < log.size()) {
|
||||
placements.add(new PlacementRange(checkpoint, log.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endObjectPlacement() {
|
||||
waterPlacement = false;
|
||||
}
|
||||
|
||||
void apply(ObjectSourcePlan plan) {
|
||||
int slot = plan.destinationSlot(destinationChunkX, destinationChunkZ);
|
||||
if (slot < 0) {
|
||||
|
||||
@@ -12,7 +12,10 @@ public interface ObjectPassPlacer extends IObjectPlacer {
|
||||
return -1;
|
||||
}
|
||||
|
||||
default void endObjectPlacement(int checkpoint) {
|
||||
default void recordObjectPlacement(int checkpoint) {
|
||||
}
|
||||
|
||||
default void endObjectPlacement() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -223,6 +223,7 @@ final class PackStructurePlacementValidator {
|
||||
path, placement, "maxHeight", Integer.MIN_VALUE, Integer.MAX_VALUE, blockingErrors);
|
||||
PackJsonFieldChecks.validateOptionalBoolean(path, placement, "underground", blockingErrors);
|
||||
PackJsonFieldChecks.validateOptionalBoolean(path, placement, "underwater", blockingErrors);
|
||||
PackJsonFieldChecks.validateOptionalBoolean(path, placement, "allowWater", blockingErrors);
|
||||
PackJsonFieldChecks.validateOptionalEnum(path, placement, "nativeSuppression",
|
||||
Set.of("NONE", "REPLACE_SOURCE"), blockingErrors);
|
||||
|
||||
@@ -299,6 +300,9 @@ final class PackStructurePlacementValidator {
|
||||
appendIdentity(identity, integerValue(placement, "maxHeight", 2032));
|
||||
appendIdentity(identity, placement.opt("underground") instanceof Boolean underground && underground);
|
||||
appendIdentity(identity, placement.opt("underwater") instanceof Boolean underwater && underwater);
|
||||
if (placement.opt("allowWater") instanceof Boolean allowWater && allowWater) {
|
||||
appendIdentity(identity, "allowWater");
|
||||
}
|
||||
JSONArray structures = placement.optJSONArray("structures");
|
||||
JSONArray nativeStructures = placement.optJSONArray("nativeStructures");
|
||||
if (structures != null && structures.length() > 0) {
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ final class PlacementModuleSurfaceSupport implements PlacementModule {
|
||||
|
||||
private static String hydrologyRejection(PlacementContext context, PlacementState state) {
|
||||
IrisObjectPlacement config = state.config;
|
||||
if (!context.automatic || !config.getCarvingSupport().supportsSurface()
|
||||
if (!context.automatic || config.isForcedByStructure() || !config.getCarvingSupport().supportsSurface()
|
||||
|| config.getMode() == ObjectPlaceMode.FLOATING || config.getMode() == ObjectPlaceMode.STRUCTURE_PIECE) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user