3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-10-03 20:21:05 +02:00
Dieser Commit ist enthalten in:
dordsor21 2023-07-15 14:41:05 +01:00
Ursprung 6abf7f3e98
Commit 5969d99db1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
2 geänderte Dateien mit 27 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -20,7 +20,9 @@ import org.jetbrains.annotations.Nullable;
import java.util.function.Consumer; import java.util.function.Consumer;
/** /**
* Extent/processor that runs a t * Extent/processor that runs a task the first time a chunk GET is loaded
*
* @since TODO
*/ */
public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatchProcessor { public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatchProcessor {
@ -34,6 +36,9 @@ public class OncePerChunkExtent extends AbstractDelegateExtent implements IBatch
* Create a new instance. * Create a new instance.
* *
* @param extent the extent * @param extent the extent
* @param queue Queue to load chunk GET from if acting as extent not processor
* @param task Consumer task for the chunk GET
* @since TODO
*/ */
public OncePerChunkExtent(Extent extent, IQueueExtent<IQueueChunk> queue, Consumer<IChunkGet> task) { public OncePerChunkExtent(Extent extent, IQueueExtent<IQueueChunk> queue, Consumer<IChunkGet> task) {
super(extent); super(extent);

Datei anzeigen

@ -11,9 +11,11 @@ import java.util.Iterator;
import java.util.Set; import java.util.Set;
/** /**
* The LocalBlockVectorSet is a Memory and CPU optimized Set for storing BlockVectors which are all in a local region * The LocalBlockVector2Set is a Memory and CPU optimized Set for storing BlockVector2s which are all in a local region
* - All vectors must be in a 2048 * 512 * 2048 area centered around the first entry * - All vectors must be in a 65534 * 65534 area centered around the first entry
* - This will use 8 bytes for every 64 BlockVectors (about 800x less than a HashSet) * - This will use 8 bytes for every 64 BlockVector2s (about 600x less than a HashSet)
*
* @since TODO
*/ */
public class LocalBlockVector2Set implements Set<BlockVector2> { public class LocalBlockVector2Set implements Set<BlockVector2> {
@ -22,8 +24,9 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
private int offsetZ; private int offsetZ;
/** /**
* New LocalBlockVectorSet that will set the offset x and z to the first value given. The y offset will default to 128 to * New LocalBlockVectorSet that will set the offset x and z to the first value given.
* allow -64 -> 320 world height. *
* @since TODO
*/ */
public LocalBlockVector2Set() { public LocalBlockVector2Set() {
offsetX = offsetZ = Integer.MAX_VALUE; offsetX = offsetZ = Integer.MAX_VALUE;
@ -31,7 +34,7 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
} }
/** /**
* New LocalBlockVectorSet with a given offset. Defaults y offset to 128. * New LocalBlockVectorSet with a given offset.
* *
* @param x x offset * @param x x offset
* @param z z offset * @param z z offset
@ -71,10 +74,15 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
} }
short sx = (short) (x - offsetX); short sx = (short) (x - offsetX);
short sz = (short) (z - offsetZ); short sz = (short) (z - offsetZ);
if (sx > 32767 || sx < -32768 || sz > 32767 || sz < -32768) { if (sx > 32767 || sx < -32767 || sz > 32767 || sz < -32767) {
return false; return false;
} }
return set.get(MathMan.pairSearchCoords(sx, sz)); try {
return set.get(MathMan.pairSearchCoords(sx, sz));
} catch (IndexOutOfBoundsException e) {
System.out.println(x + " " + z + " " + sx + " " + sz);
throw e;
}
} }
@Override @Override
@ -125,8 +133,7 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
} }
/** /**
* Set the offset applied to values when storing and reading to keep the values within -1024 to 1023. Uses default y offset * Set the offset applied to values when storing and reading to keep the values within -32767 to 32767.
* of 128 to allow -64 -> 320 world height use.
* *
* @param x x offset * @param x x offset
* @param z z offset * @param z z offset
@ -226,7 +233,7 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
} }
int relX = x - offsetX; int relX = x - offsetX;
int relZ = z - offsetZ; int relZ = z - offsetZ;
return relX <= 32767 && relX >= -32768 && relZ <= 32727 && relZ >= -32768; return relX <= 32767 && relX >= -32767 && relZ <= 32727 && relZ >= -32767;
} }
/** /**
@ -243,9 +250,9 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
} }
int relX = x - offsetX; int relX = x - offsetX;
int relZ = z - offsetZ; int relZ = z - offsetZ;
if (relX > 32767 || relX < -32768 || relZ > 32767 || relZ < -32768) { if (relX > 32767 || relX < -32767 || relZ > 32767 || relZ < -32767) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"LocalBlockVector2Set can only contain vectors within 32768 blocks (cuboid) of the first entry. Attempted " + "to set block at " + x + ", " + z + ". With origin " + offsetX + " " + offsetZ); "LocalBlockVector2Set can only contain vectors within 32767 blocks (cuboid) of the first entry. Attempted " + "to set block at " + x + ", " + z + ". With origin " + offsetX + " " + offsetZ);
} }
int index = getIndex(x, z); int index = getIndex(x, z);
if (set.get(index)) { if (set.get(index)) {
@ -285,7 +292,7 @@ public class LocalBlockVector2Set implements Set<BlockVector2> {
public boolean remove(int x, int z) { public boolean remove(int x, int z) {
int relX = x - offsetX; int relX = x - offsetX;
int relZ = z - offsetZ; int relZ = z - offsetZ;
if (relX > 1023 || relX < -1024 || relZ > 1023 || relZ < -1024) { if (relX > 32767 || relX < -32767 || relZ > 32767 || relZ < -32767) {
return false; return false;
} }
int index = MathMan.pairSearchCoords((short) (x - offsetX), (short) (z - offsetZ)); int index = MathMan.pairSearchCoords((short) (x - offsetX), (short) (z - offsetZ));