fully update to latest neolegacy protocol

This commit is contained in:
DrPerkyLegit
2026-05-29 23:36:02 -04:00
parent 7bf73ad13e
commit c5baf16d8e
8 changed files with 58 additions and 61 deletions

View File

@@ -49,9 +49,9 @@ SetEntityMotionPacket::SetEntityMotionPacket(int id, double xd, double yd, doubl
void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
{
short idAndFlag = dis->readShort();
id = idAndFlag & 0x07ff;
if( idAndFlag & 0x0800 )
useBytes = dis->readBoolean();
id = dis->readInt();
if(useBytes)
{
xa = static_cast<int>(dis->readByte());
ya = static_cast<int>(dis->readByte());
@@ -62,29 +62,28 @@ void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
xa *= 16;
ya *= 16;
za *= 16;
useBytes = true;
}
else
{
xa = dis->readShort();
ya = dis->readShort();
za = dis->readShort();
useBytes = false;
}
}
void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeBoolean(useBytes);
if( useBytes )
{
dos->writeShort(id | 0x800);
dos->writeInt(id);
dos->writeByte(xa/16);
dos->writeByte(ya/16);
dos->writeByte(za/16);
}
else
{
dos->writeShort(id);
dos->writeInt(id);
dos->writeShort(xa);
dos->writeShort(ya);
dos->writeShort(za);
@@ -98,7 +97,7 @@ void SetEntityMotionPacket::handle(PacketListener *listener)
int SetEntityMotionPacket::getEstimatedSize()
{
return useBytes ? 5 : 8;
return useBytes ? 8 : 11;
}
bool SetEntityMotionPacket::canBeInvalidated()
@@ -110,4 +109,4 @@ bool SetEntityMotionPacket::isInvalidatedBy(shared_ptr<Packet> packet)
{
shared_ptr<SetEntityMotionPacket> target = dynamic_pointer_cast<SetEntityMotionPacket>(packet);
return target->id == id;
}
}