Skip to content

Commit

Permalink
Fix protocol issues with PlaySound packet
Browse files Browse the repository at this point in the history
Fixes #35
Fixes #33
Fixes #27
  • Loading branch information
UserNugget committed Dec 14, 2024
1 parent b235eb3 commit 22a14ca
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 22a14ca

Please sign in to comment.