mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-24 10:25:32 +00:00
Revert "Rewrote the entity movement packets to use full 16-bit signed short increasing the entity ID limit from 2048 (artifical lce limit) to 32768 ids (0 to 32767)"
This reverts commit dac0e883b6.
This commit is contained in:
@@ -20,11 +20,19 @@ void SetEntityMotionPacket::_init(int id, double xd, double yd, double zd)
|
||||
xa = (int) (xd * 8000.0);
|
||||
ya = (int) (yd * 8000.0);
|
||||
za = (int) (zd * 8000.0);
|
||||
|
||||
useBytes = false;
|
||||
// 4J - if we could transmit this as bytes (in 1/16 accuracy) then flag to do so
|
||||
if( ( xa >= (-128 * 16 ) ) && ( ya >= (-128 * 16 ) ) && ( za >= (-128 * 16 ) ) &&
|
||||
( xa < (128 * 16 ) ) && ( ya < (128 * 16 ) ) && ( za < (128 * 16 ) ) )
|
||||
{
|
||||
useBytes = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
useBytes = false;
|
||||
}
|
||||
}
|
||||
|
||||
SetEntityMotionPacket::SetEntityMotionPacket()
|
||||
SetEntityMotionPacket::SetEntityMotionPacket()
|
||||
{
|
||||
_init(0, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
@@ -36,27 +44,53 @@ SetEntityMotionPacket::SetEntityMotionPacket(std::shared_ptr<Entity> e)
|
||||
|
||||
SetEntityMotionPacket::SetEntityMotionPacket(int id, double xd, double yd, double zd)
|
||||
{
|
||||
_init(id, xd, yd, zd);
|
||||
_init(id, xd, yd, zd);
|
||||
}
|
||||
|
||||
void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
|
||||
void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException
|
||||
{
|
||||
id = dis->readShort();
|
||||
|
||||
xa = dis->readShort();
|
||||
ya = dis->readShort();
|
||||
za = dis->readShort();
|
||||
|
||||
useBytes = false;
|
||||
short idAndFlag = dis->readShort();
|
||||
id = idAndFlag & 0x07ff;
|
||||
if( idAndFlag & 0x0800 )
|
||||
{
|
||||
xa = (int)dis->readByte();
|
||||
ya = (int)dis->readByte();
|
||||
za = (int)dis->readByte();
|
||||
xa = ( xa << 24 ) >> 24;
|
||||
ya = ( ya << 24 ) >> 24;
|
||||
za = ( za << 24 ) >> 24;
|
||||
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->writeShort(id);
|
||||
|
||||
dos->writeShort(xa);
|
||||
dos->writeShort(ya);
|
||||
dos->writeShort(za);
|
||||
if( useBytes )
|
||||
{
|
||||
// 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
|
||||
{
|
||||
// same thing as line 80 here
|
||||
dos->writeShort((id & 0x07FF));
|
||||
dos->writeShort(xa);
|
||||
dos->writeShort(ya);
|
||||
dos->writeShort(za);
|
||||
}
|
||||
}
|
||||
|
||||
void SetEntityMotionPacket::handle(PacketListener *listener)
|
||||
@@ -66,7 +100,7 @@ void SetEntityMotionPacket::handle(PacketListener *listener)
|
||||
|
||||
int SetEntityMotionPacket::getEstimatedSize()
|
||||
{
|
||||
return 8;
|
||||
return useBytes ? 5 : 8;
|
||||
}
|
||||
|
||||
bool SetEntityMotionPacket::canBeInvalidated()
|
||||
|
||||
Reference in New Issue
Block a user