From 22a14ca82e4d11f0bd5a6df76ea88c921355e7d6 Mon Sep 17 00:00:00 2001 From: UserNugget Date: Sat, 14 Dec 2024 21:10:31 +0300 Subject: [PATCH] Fix protocol issues with PlaySound packet Fixes https://github.com/Elytrium/LimboReconnect/issues/35 Fixes https://github.com/Elytrium/LimboReconnect/issues/33 Fixes https://github.com/Elytrium/LimboReconnect/issues/27 --- .../limboreconnect/LimboReconnect.java | 3 ++- .../protocol/packets/PlaySound.java | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/elytrium/limboreconnect/LimboReconnect.java b/src/main/java/net/elytrium/limboreconnect/LimboReconnect.java index a48032f..bcfa628 100644 --- a/src/main/java/net/elytrium/limboreconnect/LimboReconnect.java +++ b/src/main/java/net/elytrium/limboreconnect/LimboReconnect.java @@ -165,8 +165,9 @@ public void reload() { new PacketMapping(0x5e, ProtocolVersion.MINECRAFT_1_19_3, true), new PacketMapping(0x62, ProtocolVersion.MINECRAFT_1_19_4, true), new PacketMapping(0x64, ProtocolVersion.MINECRAFT_1_20_2, true), + new PacketMapping(0x66, ProtocolVersion.MINECRAFT_1_20_3, true), new PacketMapping(0x68, ProtocolVersion.MINECRAFT_1_20_5, true), - new PacketMapping(0x6F, ProtocolVersion.MINECRAFT_1_21_2, true), + new PacketMapping(0x6f, ProtocolVersion.MINECRAFT_1_21_2, true), }); this.offlineTitles.clear(); diff --git a/src/main/java/net/elytrium/limboreconnect/protocol/packets/PlaySound.java b/src/main/java/net/elytrium/limboreconnect/protocol/packets/PlaySound.java index 5cb2b3b..216c906 100644 --- a/src/main/java/net/elytrium/limboreconnect/protocol/packets/PlaySound.java +++ b/src/main/java/net/elytrium/limboreconnect/protocol/packets/PlaySound.java @@ -50,20 +50,26 @@ public void decode(ByteBuf byteBuf, ProtocolUtils.Direction direction, ProtocolV @Override public void encode(ByteBuf byteBuf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) { - if (protocolVersion.greaterThan(ProtocolVersion.MINECRAFT_1_19_1) || protocolVersion.lessThan(ProtocolVersion.MINECRAFT_1_18_2)) { + if (protocolVersion.noLessThan(ProtocolVersion.MINECRAFT_1_19_3)) { ProtocolUtils.writeVarInt(byteBuf, 0); - } - ProtocolUtils.writeString(byteBuf, this.soundName); - if (protocolVersion.greaterThan(ProtocolVersion.MINECRAFT_1_19_1) || protocolVersion.lessThan(ProtocolVersion.MINECRAFT_1_18_2)) { + ProtocolUtils.writeString(byteBuf, this.soundName); byteBuf.writeBoolean(false); + } else { + ProtocolUtils.writeString(byteBuf, this.soundName); + } + if (protocolVersion.noLessThan(ProtocolVersion.MINECRAFT_1_9)) { + ProtocolUtils.writeVarInt(byteBuf, 0); } - ProtocolUtils.writeVarInt(byteBuf, 0); byteBuf.writeInt(this.playerX); byteBuf.writeInt(this.playerY); byteBuf.writeInt(this.playerZ); byteBuf.writeFloat(this.volume); - byteBuf.writeFloat(this.pitch); - if (protocolVersion.greaterThan(ProtocolVersion.MINECRAFT_1_18_2)) { + if (protocolVersion.noLessThan(ProtocolVersion.MINECRAFT_1_10)) { + byteBuf.writeFloat(this.pitch); + } else { + byteBuf.writeByte((int) (this.pitch * 63.5F)); + } + if (protocolVersion.noLessThan(ProtocolVersion.MINECRAFT_1_19)) { byteBuf.writeLong(0); } }