1
0

Basic elytra flight (#5124)

* Basic elytra flight

Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com>
Co-authored-by: Tiger Wang <ziwei.tiger@outlook.com>
This commit is contained in:
Damián Imrich
2021-04-03 19:45:20 +02:00
committed by GitHub
parent ce6f8b3557
commit 071b7be3d4
18 changed files with 490 additions and 287 deletions

View File

@@ -2462,14 +2462,20 @@ void cProtocol_1_8_0::HandlePacketEntityAction(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEUInt8, UInt8, Action);
HANDLE_READ(a_ByteBuffer, ReadVarInt, UInt32, JumpBoost);
if (PlayerID != m_Client->GetPlayer()->GetUniqueID())
{
m_Client->Kick("Mind your own business! Hacked client?");
return;
}
switch (Action)
{
case 0: m_Client->HandleEntityCrouch(PlayerID, true); break; // Crouch
case 1: m_Client->HandleEntityCrouch(PlayerID, false); break; // Uncrouch
case 2: m_Client->HandleEntityLeaveBed(PlayerID); break; // Leave Bed
case 3: m_Client->HandleEntitySprinting(PlayerID, true); break; // Start sprinting
case 4: m_Client->HandleEntitySprinting(PlayerID, false); break; // Stop sprinting
case 6: m_Client->HandleOpenHorseInventory(PlayerID); break; // Open horse inventory
case 0: return m_Client->HandleCrouch(true);
case 1: return m_Client->HandleCrouch(false);
case 2: return m_Client->HandleLeaveBed();
case 3: return m_Client->HandleSprint(true);
case 4: return m_Client->HandleSprint(false);
case 6: return m_Client->HandleOpenHorseInventory();
}
}
@@ -2535,7 +2541,7 @@ void cProtocol_1_8_0::HandlePacketPlayerPos(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEDouble, double, PosY);
HANDLE_READ(a_ByteBuffer, ReadBEDouble, double, PosZ);
HANDLE_READ(a_ByteBuffer, ReadBool, bool, IsOnGround);
m_Client->HandlePlayerPos(PosX, PosY, PosZ, PosY + (m_Client->GetPlayer()->IsCrouched() ? 1.54 : 1.62), IsOnGround);
m_Client->HandlePlayerPos(PosX, PosY, PosZ, IsOnGround);
}
@@ -2550,7 +2556,7 @@ void cProtocol_1_8_0::HandlePacketPlayerPosLook(cByteBuffer & a_ByteBuffer)
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Yaw);
HANDLE_READ(a_ByteBuffer, ReadBEFloat, float, Pitch);
HANDLE_READ(a_ByteBuffer, ReadBool, bool, IsOnGround);
m_Client->HandlePlayerMoveLook(PosX, PosY, PosZ, PosY + 1.62, Yaw, Pitch, IsOnGround);
m_Client->HandlePlayerMoveLook(PosX, PosY, PosZ, Yaw, Pitch, IsOnGround);
}
@@ -3355,6 +3361,10 @@ void cProtocol_1_8_0::WriteEntityMetadata(cPacketizer & a_Pkt, const cEntity & a
{
Flags |= 0x20;
}
if (a_Entity.IsElytraFlying())
{
Flags |= 0x80;
}
a_Pkt.WriteBEUInt8(0); // Byte(0) + index 0
a_Pkt.WriteBEUInt8(Flags);