network: fix explosion reading (1.20.3)

This commit is contained in:
Moritz Zwerger 2023-12-10 01:09:46 +01:00
parent f5cbd31a27
commit ba1affae6b
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 6 additions and 2 deletions

View File

@ -44,7 +44,7 @@ class ExplosionS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
val destruct = if (buffer.versionId >= V_23W45A) buffer.readEnum(DestructionTypes) else null
val particle = if (buffer.versionId >= V_23W45A) buffer.readParticleData() else null
val emitter = if (buffer.versionId >= V_23W45A) buffer.readParticleData() else null
val sound = if (buffer.versionId >= V_23W45A) buffer.readSound() else null
val sound = if (buffer.versionId >= V_23W45A) buffer.readNamedSound() else null
override fun check(connection: PlayConnection) {
require(power <= 100.0f) {

View File

@ -402,7 +402,11 @@ class PlayInByteBuffer : InByteBuffer {
if (id != 0) {
return PlayedSound(connection.registries.soundEvent[id - 1])
}
val name = readResourceLocation() // TODO: readRegistryItem?
return readNamedSound()
}
fun readNamedSound(): PlayedSound {
val name = readResourceLocation()
val attenuation = readOptional { readFloat() }
return PlayedSound(name, attenuation)
}