From 9c254bbf4d7c9d62d3d6689bfad81e6cadf92432 Mon Sep 17 00:00:00 2001 From: MathiewMay Date: Mon, 9 Mar 2026 15:34:08 -0400 Subject: [PATCH] SetEntityMotionPacket::write() was sending raw entity ID without masking, changing it to mask the ID to 11 bits first since large entity IDs were accidentally setting the compression flag bit and causing wrong number of bytes to be read by receiver. --- Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp b/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp index bff87c5bd..cb6d2a42c 100644 --- a/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp +++ b/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp @@ -73,18 +73,20 @@ void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException } } -void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException +void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException { if( useBytes ) { - dos->writeShort(id | 0x800); + // Masking the id to 11 bits before writing to account for large entitty ids. + dos->writeShort((id & 0x07FF) | 0x800); dos->writeByte(xa/16); dos->writeByte(ya/16); dos->writeByte(za/16); } else { - dos->writeShort(id); + // same thing as line 80 here + dos->writeShort((id & 0x07FF)); dos->writeShort(xa); dos->writeShort(ya); dos->writeShort(za);