fix potential crash when updating chunk neighbours if chunk is initializing

This commit is contained in:
Bixilon committed 2022-12-16 22:56:12 +01:00
1 parent 7513f01871
commit 50790dc455
2 files changed
+13 -19

No files matched your search

@@ -55,9 +55,6 @@ class ChunkNeighbours(val chunk: Chunk) {
neighbours[index] = null
if (current != null) {
count--
if (count < COUNT) {
giveUp()
}
}
chunk.lock.unlock()
}
@@ -71,6 +68,9 @@ class ChunkNeighbours(val chunk: Chunk) {
}
private fun updateSectionNeighbours(neighbours: Array<Chunk>) {
if (chunk.sections == null) {
return
}
for ((index, section) in chunk.sections!!.withIndex()) {
if (section == null) {
continue
@@ -80,10 +80,6 @@ class ChunkNeighbours(val chunk: Chunk) {
}
}
private fun giveUp() {
}
operator fun get(index: Int): Chunk? {
return neighbours[index]
}
@@ -68,17 +68,15 @@ class ClientSettingsManager(
if (connection.network.state != ProtocolStates.PLAY) {
return
}
connection.sendPacket(
SettingsC2SP(
locale = language,
chatColors = connection.profiles.gui.chat.chatColors,
viewDistance = connection.profiles.block.viewDistance,
chatMode = connection.profiles.gui.chat.chatMode,
skinParts = profile.skin.parts.toTypedArray(),
mainArm = profile.mainArm,
disableTextFiltering = !connection.profiles.gui.chat.textFiltering,
allowListing = profile.playerListing,
)
)
connection.sendPacket(SettingsC2SP(
locale = language,
chatColors = connection.profiles.gui.chat.chatColors,
viewDistance = connection.profiles.block.viewDistance,
chatMode = connection.profiles.gui.chat.chatMode,
skinParts = profile.skin.parts.toTypedArray(),
mainArm = profile.mainArm,
disableTextFiltering = !connection.profiles.gui.chat.textFiltering,
allowListing = profile.playerListing,
))
}
}