mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 11:24:56 -04:00
chunk: clear blocks section data if only null elements
This commit is contained in:
parent
39d952a6d5
commit
1d134f3bb2
@ -307,6 +307,7 @@ object KUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Kutil 1.16")
|
||||
inline fun <T> Array<T>.trySet(index: Int, value: T): Boolean {
|
||||
if (index < 0 || index >= size) {
|
||||
return false
|
||||
@ -315,6 +316,7 @@ object KUtil {
|
||||
return true
|
||||
}
|
||||
|
||||
@Deprecated("Kutil 1.16")
|
||||
inline fun BooleanArray.trySet(index: Int, value: Boolean): Boolean {
|
||||
if (index < 0 || index >= size) {
|
||||
return false
|
||||
@ -323,10 +325,21 @@ object KUtil {
|
||||
return true
|
||||
}
|
||||
|
||||
@Deprecated("Kutil 1.16")
|
||||
inline fun IntArray.getOrElse(index: Int, `else`: Int): Int {
|
||||
if (index < 0 || index >= this.size) {
|
||||
return `else`
|
||||
}
|
||||
return this[index]
|
||||
}
|
||||
|
||||
@Deprecated("Kutil 1.16")
|
||||
fun <T> Array<T?>.isEmptyOrOnlyNull(): Boolean {
|
||||
for (entry in this) {
|
||||
if (entry != null) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_18W43A
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_19W36A
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_13_2
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_21W37A
|
||||
import de.bixilon.minosoft.util.KUtil.isEmptyOrOnlyNull
|
||||
import java.lang.StrictMath.abs
|
||||
import java.util.*
|
||||
|
||||
@ -203,7 +204,9 @@ object ChunkUtil {
|
||||
}
|
||||
}
|
||||
|
||||
chunkData.blocks = sectionBlocks
|
||||
if (!sectionBlocks.isEmptyOrOnlyNull()) {
|
||||
chunkData.blocks = sectionBlocks
|
||||
}
|
||||
if (lightReceived > 0) {
|
||||
chunkData.light = light
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user