Skip to content

Commit

Permalink
fix compile issues after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
SirYwell committed Jun 1, 2023
1 parent 19b9644 commit f84b635
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -91,19 +91,19 @@ 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];
}

@Nullable
@Override
public char[] loadIfPresent(int layer) {
public DataArray loadIfPresent(int layer) {
layer -= minSectionPosition;
return blocks[layer];
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -235,7 +235,7 @@ public <T extends BlockStateHolder<T>> 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;
Expand Down Expand Up @@ -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][];
Expand All @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit f84b635

Please sign in to comment.