From 9fff77c088f2cf69192987249d2ff0f0248f07b1 Mon Sep 17 00:00:00 2001 From: Hannes Greule Date: Sun, 22 Oct 2023 16:29:38 +0200 Subject: [PATCH] Avoid premature trimming in RegionIntersection (#2471) avoid premature trimming --- .../sk89q/worldedit/regions/RegionIntersection.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java index 8298a8b00..7a3e91343 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java @@ -164,14 +164,23 @@ public class RegionIntersection extends AbstractRegion { int bz = chunk.getZ() << 4; int tx = bx + 15; int tz = bz + 15; + List intersecting = new ArrayList<>(2); for (Region region : regions) { BlockVector3 regMin = region.getMinimumPoint(); BlockVector3 regMax = region.getMaximumPoint(); if (tx >= regMin.getX() && bx <= regMax.getX() && tz >= regMin.getZ() && bz <= regMax.getZ()) { - return region.processSet(chunk, get, set); + intersecting.add(region); } } - return null; + if (intersecting.isEmpty()) { + return null; + } + if (intersecting.size() == 1) { + return intersecting.get(0).processSet(chunk, get, set); + } + // if multiple regions intersect with this chunk, we must be more careful, otherwise one region might trim content of + // another region + return super.processSet(chunk, get, set); } @Override