Fixed crash on 1.8 when receiving entity data

Fixed crash on 1.8 when receiving entity data
This commit is contained in:
Anon 2023-04-07 13:30:02 +00:00 committed by GitHub
commit 0ff64910f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -504,6 +504,7 @@ namespace MinecraftClient.Protocol.Handlers
int metadata = -1;
bool hasData = false;
byte entityPitch, entityYaw;
if (living)
@ -523,12 +524,25 @@ namespace MinecraftClient.Protocol.Handlers
// Data
if (protocolversion >= Protocol18Handler.MC_1_19_Version)
ReadNextVarInt(cache);
else ReadNextInt(cache);
else hasData = ReadNextInt(cache) == 1;
}
short velocityX = ReadNextShort(cache);
short velocityY = ReadNextShort(cache);
short velocityZ = ReadNextShort(cache);
// In 1.8 those 3 fields for Velocity are optional
if (protocolversion < Protocol18Handler.MC_1_9_Version)
{
if (hasData)
{
ReadNextShort(cache);
ReadNextShort(cache);
ReadNextShort(cache);
}
}
else
{
ReadNextShort(cache);
ReadNextShort(cache);
ReadNextShort(cache);
}
return new Entity(entityID, entityType, new Location(entityX, entityY, entityZ), entityYaw, entityPitch, metadata);
}