Skip to content

Commit e4cf132

Browse files
committed
Extra one size for avoiding ArrayIndexOutOfBoundsException
1 parent 86184a4 commit e4cf132

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

bukkit/version/v1_18/src/main/kotlin/io/github/rothes/esu/bukkit/module/networkthrottle/chunkdatathrottle/v1_18/ChunkDataThrottleHandlerImpl.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,12 @@ class ChunkDataThrottleHandlerImpl: ChunkDataThrottleHandler,
537537
val storage = containerReader.getStorage(states)
538538
val blockingArr = when (palette) {
539539
is LinearPalette<BlockState>, is HashMapPalette<BlockState> ->
540-
BooleanArray(palette.size) { id -> palette.valueFor(id).blocksView }
540+
BooleanArray(palette.size + 1).apply {
541+
// We add one size for safe, cuz this is not thread-safe,
542+
// Players might place extra blocks to the chunk during the process below (storage.get())
543+
for (i in 0 until palette.size)
544+
this[i] = palette.valueFor(i).blocksView
545+
}
541546
is net.minecraft.world.level.chunk.GlobalPalette<BlockState> ->
542547
BLOCKS_VIEW
543548
else ->

0 commit comments

Comments
 (0)