diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/DataArraySetBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/DataArraySetBlocks.java index e6920ee487..4685f10975 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/DataArraySetBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/DataArraySetBlocks.java @@ -331,11 +331,10 @@ public boolean hasBiomes(int layer) { @Override public ThreadUnsafeCharBlocks createCopy() { - char[][] blocksCopy = new char[sectionCount][]; + DataArray[] blocksCopy = new DataArray[sectionCount]; for (int i = 0; i < sectionCount; i++) { if (blocks[i] != null) { - blocksCopy[i] = new char[FaweCache.INSTANCE.BLOCKS_PER_LAYER]; - System.arraycopy(blocks[i], 0, blocksCopy[i], 0, FaweCache.INSTANCE.BLOCKS_PER_LAYER); + blocksCopy[i] = DataArray.createCopy(blocks[i]); } } BiomeType[][] biomesCopy; diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java index a423b32862..c3c69eb0be 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/blocks/ThreadUnsafeCharBlocks.java @@ -26,8 +26,8 @@ import java.util.UUID; /** - * Equivalent to {@link CharSetBlocks} without any attempt to make thread-safe for improved performance. - * This is currently only used as a "copy" of {@link CharSetBlocks} to provide to + * Equivalent to {@link DataArraySetBlocks} without any attempt to make thread-safe for improved performance. + * This is currently only used as a "copy" of {@link DataArraySetBlocks} to provide to * {@link com.fastasyncworldedit.core.queue.IBatchProcessor} instances for processing without overlapping the continuing edit. * * @since TODO @@ -37,7 +37,7 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks { private static final Logger LOGGER = LogManagerCompat.getLogger(); private final char defaultOrdinal; - private char[][] blocks; + private DataArray[] blocks; private int minSectionPosition; private int maxSectionPosition; private int sectionCount; @@ -52,12 +52,12 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks { private int bitMask; /** - * New instance given the data stored in a {@link CharSetBlocks} instance. + * New instance given the data stored in a {@link DataArraySetBlocks} instance. * * @since TODO */ ThreadUnsafeCharBlocks( - char[][] blocks, + DataArray[] blocks, int minSectionPosition, int maxSectionPosition, BiomeType[][] biomes, @@ -91,11 +91,11 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks { @Override public boolean hasSection(int layer) { layer -= minSectionPosition; - return layer >= 0 && layer < blocks.length && blocks[layer] != null && blocks[layer].length == FaweCache.INSTANCE.BLOCKS_PER_LAYER; + return layer >= 0 && layer < blocks.length && blocks[layer] != null; } @Override - public char[] load(int layer) { + public DataArray load(int layer) { updateSectionIndexRange(layer); layer -= minSectionPosition; return blocks[layer]; @@ -103,7 +103,7 @@ public char[] load(int layer) { @Nullable @Override - public char[] loadIfPresent(int layer) { + public DataArray loadIfPresent(int layer) { layer -= minSectionPosition; return blocks[layer]; } @@ -176,7 +176,7 @@ public char get(int x, int y, int z) { return defaultOrdinal; } final int index = (y & 15) << 8 | z << 4 | x; - return blocks[layer - minSectionPosition][index]; + return (char) blocks[layer - minSectionPosition].getAt(index); } @Override @@ -218,7 +218,7 @@ public void set(int x, int y, int z, char value) { final int layer = y >> 4; final int index = (y & 15) << 8 | z << 4 | x; try { - blocks[layer][index] = value; + blocks[layer].setAt(index, value); } catch (ArrayIndexOutOfBoundsException exception) { LOGGER.error("Tried setting block at coordinates (" + x + "," + y + "," + z + ")"); assert Fawe.platform() != null; @@ -235,7 +235,7 @@ public > boolean setBlock(int x, int y, int z, T h } @Override - public void setBlocks(int layer, char[] data) { + public void setBlocks(int layer, DataArray data) { updateSectionIndexRange(layer); layer -= minSectionPosition; this.blocks[layer] = data; @@ -418,7 +418,7 @@ public boolean hasLight() { @Override public IChunkSet reset() { - blocks = new char[sectionCount][]; + blocks = new DataArray[sectionCount]; biomes = new BiomeType[sectionCount][]; light = new char[sectionCount][]; skyLight = new char[sectionCount][]; @@ -437,11 +437,10 @@ public boolean hasBiomes(int layer) { @Override public IChunkSet createCopy() { - char[][] blocksCopy = new char[sectionCount][]; + DataArray[] blocksCopy = new DataArray[sectionCount]; for (int i = 0; i < sectionCount; i++) { if (blocks[i] != null) { - blocksCopy[i] = new char[FaweCache.INSTANCE.BLOCKS_PER_LAYER]; - System.arraycopy(blocks[i], 0, blocksCopy[i], 0, FaweCache.INSTANCE.BLOCKS_PER_LAYER); + blocksCopy[i] = DataArray.createCopy(blocks[i]); } } BiomeType[][] biomesCopy; @@ -456,8 +455,8 @@ public IChunkSet createCopy() { } } } - char[][] lightCopy = CharSetBlocks.createLightCopy(light, sectionCount); - char[][] skyLightCopy = CharSetBlocks.createLightCopy(skyLight, sectionCount); + char[][] lightCopy = DataArraySetBlocks.createLightCopy(light, sectionCount); + char[][] skyLightCopy = DataArraySetBlocks.createLightCopy(skyLight, sectionCount); return new ThreadUnsafeCharBlocks( blocksCopy, minSectionPosition, @@ -489,7 +488,7 @@ private void updateSectionIndexRange(int layer) { if (layer < minSectionPosition) { int diff = minSectionPosition - layer; sectionCount += diff; - char[][] tmpBlocks = new char[sectionCount][]; + DataArray[] tmpBlocks = new DataArray[sectionCount]; System.arraycopy(blocks, 0, tmpBlocks, diff, blocks.length); blocks = tmpBlocks; minSectionPosition = layer; @@ -511,7 +510,7 @@ private void updateSectionIndexRange(int layer) { } else { int diff = layer - maxSectionPosition; sectionCount += diff; - char[][] tmpBlocks = new char[sectionCount][]; + DataArray[] tmpBlocks = new DataArray[sectionCount]; System.arraycopy(blocks, 0, tmpBlocks, 0, blocks.length); blocks = tmpBlocks; maxSectionPosition = layer;