Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-27 03:12:37 +01:00
fix: correctly trim the max chunk section (#2753)
- fixes #2727 - fixes IntellectualSites/Plotsquared#4436
Dieser Commit ist enthalten in:
Ursprung
a7e4d19605
Commit
5714a52675
@ -1,6 +1,5 @@
|
||||
package com.fastasyncworldedit.bukkit.regions.plotsquared;
|
||||
|
||||
import com.fastasyncworldedit.core.FaweAPI;
|
||||
import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
||||
@ -174,22 +173,21 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
Region maskedRegion;
|
||||
if (regions.size() == 1) {
|
||||
final World world = player.getWorld();
|
||||
int min = area != null ? area.getMinBuildHeight() : world.getMinY();
|
||||
// PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1
|
||||
int max = area != null ? Math.min(world.getMaxY(), area.getMaxBuildHeight() - 1) : world.getMaxY();
|
||||
Region maskedRegion;
|
||||
if (regions.size() == 1) {
|
||||
|
||||
final CuboidRegion region = regions.iterator().next();
|
||||
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
|
||||
final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
|
||||
maskedRegion = new CuboidRegion(pos1, pos2);
|
||||
} else {
|
||||
World world = FaweAPI.getWorld(area.getWorldName());
|
||||
List<Region> weRegions = regions.stream().map(
|
||||
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
|
||||
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())
|
||||
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), min, r.getMinimumZ()),
|
||||
BlockVector3.at(r.getMaximumX(), max, r.getMaximumZ())
|
||||
)).collect(Collectors.toList());
|
||||
maskedRegion = new RegionIntersection(world, weRegions);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
set.setBlocks(layer, null);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren