mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-12 08:18:35 +00:00
Some cleanup of mutables
This commit is contained in:
@ -213,10 +213,11 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
}
|
||||
|
||||
default int getHighestTerrainBlock(final int x, final int z, int minY, int maxY, Mask filter) {
|
||||
maxY = Math.min(maxY, Math.max(0, maxY));
|
||||
minY = Math.max(0, minY);
|
||||
maxY = Math.min(maxY, getMaxY());
|
||||
minY = Math.max(getMinY(), minY);
|
||||
BlockVector3 pos = MutableBlockVector3.at(x, minY, z);
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
if (filter.test(MutableBlockVector3.get(x, y, z))) {
|
||||
if (filter.test(pos.mutY(y))) {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
@ -286,28 +287,29 @@ public interface Extent extends InputExtent, OutputExtent {
|
||||
int clearanceAbove = maxY - y;
|
||||
int clearanceBelow = y - minY;
|
||||
int clearance = Math.min(clearanceAbove, clearanceBelow);
|
||||
boolean state = !mask.test(MutableBlockVector3.get(x, y, z));
|
||||
BlockVector3 pos = MutableBlockVector3.get(x, y, z);
|
||||
boolean state = !mask.test(pos);
|
||||
int offset = state ? 0 : 1;
|
||||
for (int d = 0; d <= clearance; d++) {
|
||||
int y1 = y + d;
|
||||
if (mask.test(MutableBlockVector3.get(x, y1, z)) != state) {
|
||||
if (mask.test(pos.mutY(y1)) != state) {
|
||||
return y1 - offset;
|
||||
}
|
||||
int y2 = y - d;
|
||||
if (mask.test(MutableBlockVector3.get(x, y2, z)) != state) {
|
||||
if (mask.test(pos.mutY(y2)) != state) {
|
||||
return y2 + offset;
|
||||
}
|
||||
}
|
||||
if (clearanceAbove != clearanceBelow) {
|
||||
if (clearanceAbove < clearanceBelow) {
|
||||
for (int layer = y - clearance - 1; layer >= minY; layer--) {
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) {
|
||||
if (mask.test(pos.mutY(layer)) != state) {
|
||||
return layer + offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int layer = y + clearance + 1; layer <= maxY; layer++) {
|
||||
if (mask.test(MutableBlockVector3.get(x, layer, z)) != state) {
|
||||
if (mask.test(pos.mutY(layer)) != state) {
|
||||
return layer - offset;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user