mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
fix: minor changes to fix loading blocks outside stored range in ThreadUnsafeCharBlocks (#2260)
- Fixes #2258
This commit is contained in:
parent
97d4244126
commit
0e215e98d5
@ -98,12 +98,19 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks {
|
|||||||
public char[] load(int layer) {
|
public char[] load(int layer) {
|
||||||
updateSectionIndexRange(layer);
|
updateSectionIndexRange(layer);
|
||||||
layer -= minSectionPosition;
|
layer -= minSectionPosition;
|
||||||
return blocks[layer];
|
char[] arr = blocks[layer];
|
||||||
|
if (arr == null) {
|
||||||
|
arr = blocks[layer] = new char[FaweCache.INSTANCE.BLOCKS_PER_LAYER];
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public char[] loadIfPresent(int layer) {
|
public char[] loadIfPresent(int layer) {
|
||||||
|
if (layer < minSectionPosition || layer > maxSectionPosition) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
layer -= minSectionPosition;
|
layer -= minSectionPosition;
|
||||||
return blocks[layer];
|
return blocks[layer];
|
||||||
}
|
}
|
||||||
@ -439,8 +446,8 @@ public class ThreadUnsafeCharBlocks implements IChunkSet, IBlocks {
|
|||||||
public IChunkSet createCopy() {
|
public IChunkSet createCopy() {
|
||||||
char[][] blocksCopy = new char[sectionCount][];
|
char[][] blocksCopy = new char[sectionCount][];
|
||||||
for (int i = 0; i < sectionCount; i++) {
|
for (int i = 0; i < sectionCount; i++) {
|
||||||
|
blocksCopy[i] = new char[FaweCache.INSTANCE.BLOCKS_PER_LAYER];
|
||||||
if (blocks[i] != null) {
|
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);
|
System.arraycopy(blocks[i], 0, blocksCopy[i], 0, FaweCache.INSTANCE.BLOCKS_PER_LAYER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user