mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-07-12 18:04:01 +00:00
c
This commit is contained in:
@@ -963,6 +963,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
int lowest = Integer.MAX_VALUE;
|
||||
int topLayer = Integer.MIN_VALUE;
|
||||
int vacuumLowest = Integer.MAX_VALUE;
|
||||
int vacuumHighest = Integer.MIN_VALUE;
|
||||
y += yrand;
|
||||
readLock.lock();
|
||||
|
||||
@@ -1132,6 +1133,9 @@ public class IrisObject extends IrisRegistrant {
|
||||
if (vacuuming && yy < vacuumLowest) {
|
||||
vacuumLowest = yy;
|
||||
}
|
||||
if (vacuuming && yy > vacuumHighest) {
|
||||
vacuumHighest = yy;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@@ -1370,7 +1374,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
int highZ = IrisObjectVacuum.footprintHigh(rotDim.getBlockZ());
|
||||
int centerX = x + config.getTranslate().getX();
|
||||
int centerZ = z + config.getTranslate().getZ();
|
||||
vacuumTerrain(placer, config, centerX, centerZ, lowX, highX, lowZ, highZ, vacuumLowest);
|
||||
vacuumTerrain(placer, config, centerX, centerZ, lowX, highX, lowZ, highZ, vacuumLowest, vacuumHighest);
|
||||
}
|
||||
|
||||
if (heightmap != null) {
|
||||
@@ -1409,7 +1413,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
+ "(forcePlace=false, fromBottom=false, mode!=FLOATING). Skipping to protect bedrock.");
|
||||
}
|
||||
|
||||
private void vacuumTerrain(IObjectPlacer placer, IrisObjectPlacement config, int centerX, int centerZ, int lowX, int highX, int lowZ, int highZ, int baseY) {
|
||||
private void vacuumTerrain(IObjectPlacer placer, IrisObjectPlacement config, int centerX, int centerZ, int lowX, int highX, int lowZ, int highZ, int baseY, int topY) {
|
||||
ObjectPlaceMode mode = config.getMode();
|
||||
IrisVacuumSettings settings = config.getVacuumSettings();
|
||||
int radius = IrisObjectVacuum.resolveRadius(mode, settings);
|
||||
@@ -1448,7 +1452,9 @@ public class IrisObject extends IrisRegistrant {
|
||||
placer.set(cx, yy, cz, fill);
|
||||
}
|
||||
} else if (targetY < origY) {
|
||||
for (int yy = origY; yy > targetY; yy--) {
|
||||
boolean inside = IrisObjectVacuum.outset(dx, lowX, highX) == 0 && IrisObjectVacuum.outset(dz, lowZ, highZ) == 0;
|
||||
int carveFloor = IrisObjectVacuum.carveFloorY(targetY, topY, inside);
|
||||
for (int yy = origY; yy >= carveFloor; yy--) {
|
||||
placer.set(cx, yy, cz, AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,4 +90,12 @@ public final class IrisObjectVacuum {
|
||||
double factor = Math.pow(t, Math.max(0.25, falloff));
|
||||
return (int) Math.round(originalY + ((meetY - originalY) * factor));
|
||||
}
|
||||
|
||||
public static int carveFloorY(int targetY, int objectTopY, boolean insideFootprint) {
|
||||
int floor = targetY + 1;
|
||||
if (insideFootprint) {
|
||||
floor = Math.max(floor, objectTopY + 1);
|
||||
}
|
||||
return floor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,4 +126,21 @@ public class IrisObjectVacuumTest {
|
||||
assertFalse(IrisObjectVacuum.isVacuumMode(ObjectPlaceMode.PAINT));
|
||||
assertFalse(IrisObjectVacuum.isVacuumMode(ObjectPlaceMode.FLOATING));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void carveFloorPreservesBuriedObjectInsideFootprint() {
|
||||
int surfaceY = 122;
|
||||
int baseY = 110;
|
||||
int topY = 119;
|
||||
int meetY = baseY - 1;
|
||||
|
||||
int insideFloor = IrisObjectVacuum.carveFloorY(meetY, topY, true);
|
||||
assertEquals("inside the footprint the carve must stop one above the object top", topY + 1, insideFloor);
|
||||
assertTrue("inside carve must not reach the object's blocks", insideFloor > topY);
|
||||
assertTrue("inside carve still removes the terrain burying the object", insideFloor <= surfaceY + 1);
|
||||
|
||||
int ringFloor = IrisObjectVacuum.carveFloorY(meetY, topY, false);
|
||||
assertEquals("the ring carves down to the deformation target (the crater floor)", meetY + 1, ringFloor);
|
||||
assertTrue("ring crater is deeper than the object-protected inside floor", ringFloor < insideFloor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user