geforkt von Mirrors/FastAsyncWorldEdit
Javadocs to LocalBlockVectorSet
Dieser Commit ist enthalten in:
Ursprung
8c8419a1c5
Commit
8e214b1232
@ -20,12 +20,27 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
private int offsetX;
|
private int offsetX;
|
||||||
private int offsetZ;
|
private int offsetZ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New LocalBlockVectorSet that will set the offset x and z to the first value given
|
||||||
|
*/
|
||||||
public LocalBlockVectorSet() {
|
public LocalBlockVectorSet() {
|
||||||
offsetX = offsetZ = Integer.MAX_VALUE;
|
offsetX = offsetZ = Integer.MAX_VALUE;
|
||||||
this.set = new SparseBitSet();
|
this.set = new SparseBitSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalBlockVectorSet(int x, int z, SparseBitSet set) {
|
/**
|
||||||
|
* New LocalBlockVectorSet with a given offset
|
||||||
|
*
|
||||||
|
* @param x x offset
|
||||||
|
* @param z z offset
|
||||||
|
*/
|
||||||
|
public LocalBlockVectorSet(int x, int z) {
|
||||||
|
this.offsetX = x;
|
||||||
|
this.offsetZ = z;
|
||||||
|
this.set = new SparseBitSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalBlockVectorSet(int x, int z, SparseBitSet set) {
|
||||||
this.offsetX = x;
|
this.offsetX = x;
|
||||||
this.offsetZ = z;
|
this.offsetZ = z;
|
||||||
this.set = set;
|
this.set = set;
|
||||||
@ -41,6 +56,14 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return set.isEmpty();
|
return set.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the set contains a position
|
||||||
|
*
|
||||||
|
* @param x x position
|
||||||
|
* @param y y position
|
||||||
|
* @param z z position
|
||||||
|
* @return if the set contains the position
|
||||||
|
*/
|
||||||
public boolean contains(int x, int y, int z) {
|
public boolean contains(int x, int y, int z) {
|
||||||
// take 128 to fit -256<y<255
|
// take 128 to fit -256<y<255
|
||||||
return set.get(MathMan.tripleSearchCoords(x - offsetX, y - 128, z - offsetZ));
|
return set.get(MathMan.tripleSearchCoords(x - offsetX, y - 128, z - offsetZ));
|
||||||
@ -60,6 +83,15 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return new LocalBlockVectorSet(offsetX, offsetZ, set.clone());
|
return new LocalBlockVectorSet(offsetX, offsetZ, set.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a radius is contained by the set
|
||||||
|
*
|
||||||
|
* @param x x radius center
|
||||||
|
* @param y y radius center
|
||||||
|
* @param z z radius center
|
||||||
|
* @param radius
|
||||||
|
* @return if radius is contained by the set
|
||||||
|
*/
|
||||||
public boolean containsRadius(int x, int y, int z, int radius) {
|
public boolean containsRadius(int x, int y, int z, int radius) {
|
||||||
if (radius <= 0) {
|
if (radius <= 0) {
|
||||||
return contains(x, y, z);
|
return contains(x, y, z);
|
||||||
@ -94,11 +126,12 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOffset(int x, int z) {
|
/**
|
||||||
this.offsetX += x;
|
* Set the offset applied to values when storing and reading to keep the values within -1024 to 1023
|
||||||
this.offsetZ += z;
|
*
|
||||||
}
|
* @param x x offset
|
||||||
|
* @param z z offset
|
||||||
|
*/
|
||||||
public void setOffset(int x, int z) {
|
public void setOffset(int x, int z) {
|
||||||
this.offsetX = x;
|
this.offsetX = x;
|
||||||
this.offsetZ = z;
|
this.offsetZ = z;
|
||||||
@ -198,6 +231,14 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a position is contained by the bounds of the set
|
||||||
|
*
|
||||||
|
* @param x x position
|
||||||
|
* @param y y position
|
||||||
|
* @param z z position
|
||||||
|
* @return true if position is contained by the bounds of the set
|
||||||
|
*/
|
||||||
public boolean canAdd(int x, int y, int z) {
|
public boolean canAdd(int x, int y, int z) {
|
||||||
if (offsetX == Integer.MAX_VALUE) {
|
if (offsetX == Integer.MAX_VALUE) {
|
||||||
return false;
|
return false;
|
||||||
@ -210,6 +251,14 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return y >= -128 && y <= 383;
|
return y >= -128 && y <= 383;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a position to the set if not present
|
||||||
|
*
|
||||||
|
* @param x x position
|
||||||
|
* @param y y position
|
||||||
|
* @param z z position
|
||||||
|
* @return true if not already present
|
||||||
|
*/
|
||||||
public boolean add(int x, int y, int z) {
|
public boolean add(int x, int y, int z) {
|
||||||
if (offsetX == Integer.MAX_VALUE) {
|
if (offsetX == Integer.MAX_VALUE) {
|
||||||
offsetX = x;
|
offsetX = x;
|
||||||
@ -233,6 +282,12 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a position to the set if not present
|
||||||
|
*
|
||||||
|
* @param vector position
|
||||||
|
* @return true if not already present
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean add(BlockVector3 vector) {
|
public boolean add(BlockVector3 vector) {
|
||||||
return add(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
return add(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||||
@ -252,6 +307,14 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return MathMan.tripleSearchCoords(x - offsetX, y - 128, z - offsetZ);
|
return MathMan.tripleSearchCoords(x - offsetX, y - 128, z - offsetZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a position from the set.
|
||||||
|
*
|
||||||
|
* @param x x positition
|
||||||
|
* @param y y positition
|
||||||
|
* @param z z positition
|
||||||
|
* @return true if value was present.
|
||||||
|
*/
|
||||||
public boolean remove(int x, int y, int z) {
|
public boolean remove(int x, int y, int z) {
|
||||||
int relX = x - offsetX;
|
int relX = x - offsetX;
|
||||||
int relZ = z - offsetZ;
|
int relZ = z - offsetZ;
|
||||||
@ -329,6 +392,11 @@ public class LocalBlockVectorSet implements Set<BlockVector3> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Visit each point contained in the set
|
||||||
|
*
|
||||||
|
* @param visitor visitor to use
|
||||||
|
*/
|
||||||
public void forEach(BlockVectorSetVisitor visitor) {
|
public void forEach(BlockVectorSetVisitor visitor) {
|
||||||
int size = size();
|
int size = size();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren