mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-13 14:58:35 +00:00
Some cleanup of mutables
This commit is contained in:
@ -2079,7 +2079,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
int px = mutableBlockVector3.getBlockX();
|
||||
int py = mutableBlockVector3.getBlockY();
|
||||
int pz = mutableBlockVector3.getBlockZ();
|
||||
MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
final int ceilRadiusX = (int) Math.ceil(radiusX);
|
||||
final int ceilRadiusZ = (int) Math.ceil(radiusZ);
|
||||
@ -2122,10 +2121,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block);
|
||||
this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block);
|
||||
this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block);
|
||||
this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz + z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz + z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz - z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz - z), block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2158,10 +2157,10 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
//FAWE start - mutable
|
||||
this.setBlock(mutable.setComponents(px + x, py + y, pz + z), block);
|
||||
this.setBlock(mutable.setComponents(px - x, py + y, pz + z), block);
|
||||
this.setBlock(mutable.setComponents(px + x, py + y, pz - z), block);
|
||||
this.setBlock(mutable.setComponents(px - x, py + y, pz - z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz + z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz + z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px + x, py + y, pz - z), block);
|
||||
this.setBlock(mutableBlockVector3.setComponents(px - x, py + y, pz - z), block);
|
||||
//FAWE end
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
*/
|
||||
public class NoiseFilter extends AbstractMask {
|
||||
|
||||
//FAWE start - mutable
|
||||
private MutableVector3 mutable;
|
||||
//FAWE end
|
||||
private NoiseGenerator noiseGenerator;
|
||||
private double density;
|
||||
|
||||
@ -65,6 +68,9 @@ public class NoiseFilter extends AbstractMask {
|
||||
public void setNoiseGenerator(NoiseGenerator noiseGenerator) {
|
||||
checkNotNull(noiseGenerator);
|
||||
this.noiseGenerator = noiseGenerator;
|
||||
//FAWE start - mutable
|
||||
this.mutable = new MutableVector3();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,11 +89,16 @@ public class NoiseFilter extends AbstractMask {
|
||||
checkArgument(density >= 0, "density must be >= 0");
|
||||
checkArgument(density <= 1, "density must be <= 1");
|
||||
this.density = density;
|
||||
//FAWE start - mutable
|
||||
this.mutable = new MutableVector3();
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(BlockVector3 vector) {
|
||||
return noiseGenerator.noise(MutableVector3.get(vector.getX(), vector.getY(), vector.getZ())) <= density;
|
||||
//FAWE start - mutable
|
||||
return noiseGenerator.noise(mutable.setComponents(vector.getX(), vector.getZ(), vector.getZ())) <= density;
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
Reference in New Issue
Block a user