mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Check native structures against the real transformed object bounds
The native-structure veto used a square envelope of half the largest object side, so rotated or off-centre objects reaching past it were never checked. It now uses the prepared transformed bounds, with Y widened by the warp margin. IrisObject.copy() now reads under the read lock instead of the object monitor.
Upstream: d55c77572
This commit is contained in:
1 parent
a81a3abb9f
commit
8e0e6d7d45
4 files changed
+140
-25
No files matched your search
@@ -22,7 +22,7 @@ import art.arcane.iris.builtin.anchor.PlaceTrait;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.objects.ObjectRun;
|
||||
import art.arcane.iris.builtin.terrain.BedrockSettings;
|
||||
import art.arcane.iris.modules.placement.ObjectShape;
|
||||
import art.arcane.iris.builtin.prepare.TransformedBounds;
|
||||
import art.arcane.iris.modules.placement.PlacementSettings;
|
||||
import art.arcane.iris.modules.placement.PlacementStages;
|
||||
import art.arcane.iris.modules.placement.PreparedPlacement;
|
||||
@@ -156,15 +156,19 @@ public final class ValidateModule implements IrisModule {
|
||||
}
|
||||
int x = placement.x();
|
||||
int z = placement.z();
|
||||
int margin = nativeStructureMargin(placement.object(), prepared);
|
||||
StructureVolumes volumes = terrain.structureVolumes(x - margin, z - margin, x + margin, z + margin);
|
||||
TransformedBounds bounds = prepared.bounds();
|
||||
int minX = x + bounds.minX();
|
||||
int maxX = x + bounds.maxX();
|
||||
int minZ = z + bounds.minZ();
|
||||
int maxZ = z + bounds.maxZ();
|
||||
StructureVolumes volumes = terrain.structureVolumes(minX, minZ, maxX, maxZ);
|
||||
if (volumes.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
boolean painted = WorldVolume.isPainted(placement, prepared);
|
||||
int envelopeMinY = painted ? Integer.MIN_VALUE : y - margin;
|
||||
int envelopeMaxY = painted ? Integer.MAX_VALUE : y + margin;
|
||||
if (!volumes.intersects(x - margin, envelopeMinY, z - margin, x + margin, envelopeMaxY, z + margin)) {
|
||||
int envelopeMinY = painted ? Integer.MIN_VALUE : y + bounds.minY() - prepared.warpMargin();
|
||||
int envelopeMaxY = painted ? Integer.MAX_VALUE : y + bounds.maxY() + prepared.warpMargin();
|
||||
if (!volumes.intersects(minX, envelopeMinY, minZ, maxX, envelopeMaxY, maxZ)) {
|
||||
return false;
|
||||
}
|
||||
for (ObjectBlock block : context.request().object().blocks()) {
|
||||
@@ -185,16 +189,6 @@ public final class ValidateModule implements IrisModule {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** How far around the anchor any block of the transformed object can reach. */
|
||||
private static int nativeStructureMargin(ObjectShape object, PreparedPlacement prepared) {
|
||||
int margin = (Math.max(object.width(), Math.max(object.height(), object.depth())) / 2) + 1 + prepared.warpMargin();
|
||||
if (prepared.translation() == null) {
|
||||
return margin;
|
||||
}
|
||||
return margin + Math.max(Math.abs(prepared.translation().getBlockX()),
|
||||
Math.max(Math.abs(prepared.translation().getBlockY()), Math.abs(prepared.translation().getBlockZ())));
|
||||
}
|
||||
|
||||
private static boolean isAir(BlockState state) {
|
||||
return AIR_MATERIALS.contains(state.material().toString());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user