geforkt von Mirrors/FastAsyncWorldEdit
Some code cleanup
- Simplify MaskFilter slightly - Improve thread safety of LocalBlockVectorSet - Simplify if statement in SingleThreadQueueExtent - Better error in MathMan#tripleSearchCoords for handling of the error in some cases
Dieser Commit ist enthalten in:
Ursprung
e85586db80
Commit
6e586da83e
@ -7,7 +7,6 @@ import com.sk89q.worldedit.function.mask.AbstractExtentMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Filter with an attached Mask used for deciding whether a block is eligible for being applied to.
|
||||
@ -16,25 +15,15 @@ import java.util.function.Supplier;
|
||||
*/
|
||||
public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
|
||||
|
||||
private final Supplier<Mask> supplier;
|
||||
private final Mask mask;
|
||||
private final AtomicInteger changes;
|
||||
|
||||
public MaskFilter(T other, Mask mask) {
|
||||
this(other, () -> mask);
|
||||
public MaskFilter(T other, Mask root) {
|
||||
this(other, root, new AtomicInteger());
|
||||
}
|
||||
|
||||
public MaskFilter(T other, Supplier<Mask> supplier) {
|
||||
this(other, supplier, supplier.get());
|
||||
}
|
||||
|
||||
public MaskFilter(T other, Supplier<Mask> supplier, Mask root) {
|
||||
this(other, supplier, root, new AtomicInteger());
|
||||
}
|
||||
|
||||
public MaskFilter(T other, Supplier<Mask> supplier, Mask root, AtomicInteger changes) {
|
||||
public MaskFilter(T other, Mask root, AtomicInteger changes) {
|
||||
super(other);
|
||||
this.supplier = supplier;
|
||||
this.mask = root;
|
||||
this.changes = changes;
|
||||
}
|
||||
@ -63,12 +52,12 @@ public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
|
||||
|
||||
@Override
|
||||
public MaskFilter<?> newInstance(Filter other) {
|
||||
return new MaskFilter<>(other, supplier);
|
||||
return new MaskFilter<>(other, mask);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Filter fork() {
|
||||
return new MaskFilter<>(getParent().fork(), mask::copy, mask.copy(), changes);
|
||||
return new MaskFilter<>(getParent().fork(), mask.copy(), changes);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ import java.util.Set;
|
||||
public class LocalBlockVectorSet implements Set<BlockVector3> {
|
||||
|
||||
private final SparseBitSet set;
|
||||
private int offsetX;
|
||||
private int offsetZ;
|
||||
private volatile int offsetX;
|
||||
private volatile int offsetZ;
|
||||
|
||||
public LocalBlockVectorSet() {
|
||||
offsetX = offsetZ = Integer.MAX_VALUE;
|
||||
@ -211,7 +211,7 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
||||
}
|
||||
|
||||
public boolean add(int x, int y, int z) {
|
||||
if (offsetX == Integer.MAX_VALUE) {
|
||||
if (offsetX == Integer.MAX_VALUE || offsetZ == Integer.MAX_VALUE) {
|
||||
offsetX = x;
|
||||
offsetZ = z;
|
||||
}
|
||||
|
@ -305,8 +305,6 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
|
||||
if (chunk != null) {
|
||||
lastPair = pair;
|
||||
lastChunk = chunk;
|
||||
}
|
||||
if (chunk != null) {
|
||||
return chunk;
|
||||
}
|
||||
final int size = chunks.size();
|
||||
|
@ -201,7 +201,7 @@ public class MathMan {
|
||||
*/
|
||||
public static int tripleSearchCoords(int x, int y, int z) {
|
||||
if (x > 1023 || x < -1024 || y > 255 || y < -256 || z > 1023 || z < -1024) {
|
||||
throw new IndexOutOfBoundsException(String.format("Check range on x=%s, y=%s and z=%s!", x, y, z));
|
||||
throw new UnsupportedOperationException(String.format("Check range on x=%s, y=%s and z=%s!", x, y, z));
|
||||
}
|
||||
int b1 = Math.abs(y) & 0xff;
|
||||
int b3 = x & 0xff;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren