fix: correctly trim the max chunk section (#2753)

- fixes #2727
- fixes IntellectualSites/Plotsquared#4436
This commit is contained in:
Jordan
2024-06-05 21:23:12 +02:00
committed by GitHub
parent a7e4d19605
commit 5714a52675
3 changed files with 12 additions and 18 deletions

View File

@ -58,7 +58,7 @@ public interface IBatchProcessor {
/**
* Utility method to trim a chunk based on min and max Y (inclusive).
*
* @param keepInsideRange if all blocks inside the range (inclusive) should be kept (default)
* @param keepInsideRange if all blocks inside the range (inclusive) should be kept (default), or removed
* @return false if chunk is empty of blocks
*/
default boolean trimY(IChunkSet set, int minY, int maxY, final boolean keepInsideRange) {
@ -74,16 +74,14 @@ public interface IBatchProcessor {
for (int i = 0; i < index; i++) {
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
}
} else {
arr = new char[4096];
set.setBlocks(layer, arr);
}
set.setBlocks(layer, arr);
} else {
set.setBlocks(layer, null);
}
}
}
for (int layer = maxLayer; layer < set.getMaxSectionPosition(); layer++) {
for (int layer = maxLayer; layer <= set.getMaxSectionPosition(); layer++) {
if (set.hasSection(layer)) {
if (layer == maxLayer) {
char[] arr = set.loadIfPresent(layer);
@ -92,10 +90,8 @@ public interface IBatchProcessor {
for (int i = index; i < arr.length; i++) {
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
}
} else {
arr = new char[4096];
set.setBlocks(layer, arr);
}
set.setBlocks(layer, arr);
} else {
set.setBlocks(layer, null);
}

View File

@ -828,7 +828,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
return set;
}
for (int layer = get.getMinSectionPosition(); layer < get.getMaxSectionPosition(); layer++) {
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
if (!set.hasSection(layer)) {
continue;
}
@ -912,7 +912,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
boolean trimX = lowerX != 0 || upperX != 15;
boolean trimZ = lowerZ != 0 || upperZ != 15;
for (int layer = get.getMinSectionPosition(); layer < get.getMaxSectionPosition(); layer++) {
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
if (!set.hasSection(layer)) {
continue;
}