Fixed entity rotations (#2596)

* Fixed entity rotations

Fixed entity yaw and pitch not changing when entity moves head.

* Update ChatBot.cs

* Update McClient.cs

* Update Protocol18.cs

* Update McClient.cs

* Finalize code style

* Fix incorrect variable type

---------

Co-authored-by: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com>
This commit is contained in:
Domracz 2023-10-11 02:44:46 -04:00 committed by GitHub
parent c3fa413b4e
commit 1aea8d3a4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 3 deletions

View file

@ -2117,14 +2117,28 @@ namespace MinecraftClient.Protocol.Handlers
}
byte _yaw = dataTypes.ReadNextByte(packetData);
byte _pitch = dataTypes.ReadNextByte(packetData);
float _yaw = dataTypes.ReadNextByte(packetData) * (1F / 256) * 360;
float _pitch = dataTypes.ReadNextByte(packetData) * (1F / 256) * 360;
bool OnGround = dataTypes.ReadNextBool(packetData);
DeltaX = DeltaX / (128 * 32);
DeltaY = DeltaY / (128 * 32);
DeltaZ = DeltaZ / (128 * 32);
handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, _yaw, _pitch, OnGround);
}
break;
case PacketTypesIn.EntityRotation:
if (handler.GetEntityHandlingEnabled())
{
int EntityID = dataTypes.ReadNextVarInt(packetData);
float _yaw = dataTypes.ReadNextByte(packetData) * (1F / 256) * 360;
float _pitch = dataTypes.ReadNextByte(packetData)* (1F / 256) * 360;
bool OnGround = dataTypes.ReadNextBool(packetData);
handler.OnEntityRotation(EntityID, _yaw, _pitch, OnGround);
}
break;