mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
network: fix 1.17 explosion packet reading
This commit is contained in:
parent
0b79bd19c3
commit
28c78707ae
@ -16,6 +16,8 @@ import de.bixilon.minosoft.modding.event.events.ExplosionEvent
|
||||
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
|
||||
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions.V_1_17
|
||||
import de.bixilon.minosoft.util.KUtil.decide
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import de.bixilon.minosoft.util.logging.LogLevels
|
||||
import de.bixilon.minosoft.util.logging.LogMessageType
|
||||
@ -25,7 +27,7 @@ import glm_.vec3.Vec3i
|
||||
class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
|
||||
val position = buffer.readVec3f()
|
||||
val power = buffer.readFloat()
|
||||
val explodedBlocks: List<Vec3> = buffer.readArray(buffer.readInt()) { Vec3(buffer.readByte(), buffer.readByte(), buffer.readByte()) }.toList()
|
||||
val explodedBlocks: List<Vec3> = buffer.readArray((buffer.versionId < V_1_17).decide({ buffer.readInt() }, { buffer.readVarInt() })) { Vec3(buffer.readByte(), buffer.readByte(), buffer.readByte()) }.toList() // ToDo: Find out version
|
||||
val velocity = buffer.readVec3f()
|
||||
|
||||
override fun check(connection: PlayConnection) {
|
||||
|
@ -144,6 +144,14 @@ object KUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> Boolean.decide(`true`: () -> T, `false`: () -> T): T {
|
||||
return if (this) {
|
||||
`true`()
|
||||
} else {
|
||||
`false`()
|
||||
}
|
||||
}
|
||||
|
||||
fun String.asUUID(): UUID {
|
||||
return Util.getUUIDFromString(this)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user