mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
fix: correctly trim the max chunk section (#2753)
- fixes #2727 - fixes IntellectualSites/Plotsquared#4436
This commit is contained in:
parent
a7e4d19605
commit
5714a52675
@ -1,6 +1,5 @@
|
|||||||
package com.fastasyncworldedit.bukkit.regions.plotsquared;
|
package com.fastasyncworldedit.bukkit.regions.plotsquared;
|
||||||
|
|
||||||
import com.fastasyncworldedit.core.FaweAPI;
|
|
||||||
import com.fastasyncworldedit.core.configuration.Caption;
|
import com.fastasyncworldedit.core.configuration.Caption;
|
||||||
import com.fastasyncworldedit.core.regions.FaweMask;
|
import com.fastasyncworldedit.core.regions.FaweMask;
|
||||||
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
import com.fastasyncworldedit.core.regions.FaweMaskManager;
|
||||||
@ -174,22 +173,21 @@ public class PlotSquaredFeature extends FaweMaskManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region maskedRegion;
|
|
||||||
if (regions.size() == 1) {
|
|
||||||
final World world = player.getWorld();
|
final World world = player.getWorld();
|
||||||
int min = area != null ? area.getMinBuildHeight() : world.getMinY();
|
int min = area != null ? area.getMinBuildHeight() : world.getMinY();
|
||||||
// PlotSquared uses exclusive max height, WorldEdit uses inclusive max height -> subtract 1
|
// 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();
|
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 CuboidRegion region = regions.iterator().next();
|
||||||
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
|
final BlockVector3 pos1 = BlockVector3.at(region.getMinimumX(), min, region.getMinimumZ());
|
||||||
final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
|
final BlockVector3 pos2 = BlockVector3.at(region.getMaximumX(), max, region.getMaximumZ());
|
||||||
maskedRegion = new CuboidRegion(pos1, pos2);
|
maskedRegion = new CuboidRegion(pos1, pos2);
|
||||||
} else {
|
} else {
|
||||||
World world = FaweAPI.getWorld(area.getWorldName());
|
|
||||||
List<Region> weRegions = regions.stream().map(
|
List<Region> weRegions = regions.stream().map(
|
||||||
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), r.getMinimumY(), r.getMinimumZ()),
|
r -> new CuboidRegion(world, BlockVector3.at(r.getMinimumX(), min, r.getMinimumZ()),
|
||||||
BlockVector3.at(r.getMaximumX(), r.getMaximumY(), r.getMaximumZ())
|
BlockVector3.at(r.getMaximumX(), max, r.getMaximumZ())
|
||||||
)).collect(Collectors.toList());
|
)).collect(Collectors.toList());
|
||||||
maskedRegion = new RegionIntersection(world, weRegions);
|
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).
|
* 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
|
* @return false if chunk is empty of blocks
|
||||||
*/
|
*/
|
||||||
default boolean trimY(IChunkSet set, int minY, int maxY, final boolean keepInsideRange) {
|
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++) {
|
for (int i = 0; i < index; i++) {
|
||||||
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
arr = new char[4096];
|
|
||||||
}
|
|
||||||
set.setBlocks(layer, arr);
|
set.setBlocks(layer, arr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
set.setBlocks(layer, null);
|
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 (set.hasSection(layer)) {
|
||||||
if (layer == maxLayer) {
|
if (layer == maxLayer) {
|
||||||
char[] arr = set.loadIfPresent(layer);
|
char[] arr = set.loadIfPresent(layer);
|
||||||
@ -92,10 +90,8 @@ public interface IBatchProcessor {
|
|||||||
for (int i = index; i < arr.length; i++) {
|
for (int i = index; i < arr.length; i++) {
|
||||||
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
arr[i] = BlockTypesCache.ReservedIDs.__RESERVED__;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
arr = new char[4096];
|
|
||||||
}
|
|
||||||
set.setBlocks(layer, arr);
|
set.setBlocks(layer, arr);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
set.setBlocks(layer, null);
|
set.setBlocks(layer, null);
|
||||||
}
|
}
|
||||||
|
@ -828,7 +828,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int layer = get.getMinSectionPosition(); layer < get.getMaxSectionPosition(); layer++) {
|
for (int layer = get.getMinSectionPosition(); layer <= get.getMaxSectionPosition(); layer++) {
|
||||||
if (!set.hasSection(layer)) {
|
if (!set.hasSection(layer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -912,7 +912,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
|||||||
boolean trimX = lowerX != 0 || upperX != 15;
|
boolean trimX = lowerX != 0 || upperX != 15;
|
||||||
boolean trimZ = lowerZ != 0 || upperZ != 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)) {
|
if (!set.hasSection(layer)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user