From 071b7be3d4d08c337c01de7abca034e6c3746194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Imrich?= Date: Sat, 3 Apr 2021 19:45:20 +0200 Subject: Basic elytra flight (#5124) * Basic elytra flight Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com> Co-authored-by: Tiger Wang --- src/ClientHandle.cpp | 87 ++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 51 deletions(-) (limited to 'src/ClientHandle.cpp') diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 61370ca4f..cd45068ee 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -574,12 +574,9 @@ void cClientHandle::HandleNPCTrade(int a_SlotNum) -void cClientHandle::HandleOpenHorseInventory(UInt32 a_EntityID) +void cClientHandle::HandleOpenHorseInventory() { - if (m_Player->GetUniqueID() == a_EntityID) - { - m_Player->OpenHorseInventory(); - } + m_Player->OpenHorseInventory(); } @@ -665,6 +662,15 @@ void cClientHandle::HandleCreativeInventory(Int16 a_SlotNum, const cItem & a_Hel +void cClientHandle::HandleCrouch(const bool a_IsCrouching) +{ + m_Player->SetCrouch(a_IsCrouching); +} + + + + + void cClientHandle::HandleEnchantItem(UInt8 a_WindowID, UInt8 a_Enchantment) { if (a_Enchantment > 2) @@ -749,7 +755,7 @@ void cClientHandle::HandlePlayerAbilities(bool a_IsFlying, float FlyingSpeed, fl -void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, bool a_IsOnGround) +void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, bool a_IsOnGround) { if (m_Player->IsFrozen()) { @@ -759,7 +765,6 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, Vector3d NewPosition(a_PosX, a_PosY, a_PosZ); Vector3d OldPosition = GetPlayer()->GetPosition(); - double OldStance = GetPlayer()->GetStance(); auto PreviousIsOnGround = GetPlayer()->IsOnGround(); #ifdef __clang__ @@ -769,7 +774,6 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, if ( (OldPosition == NewPosition) && - (OldStance == a_Stance) && (PreviousIsOnGround == a_IsOnGround) ) { @@ -799,7 +803,6 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ, // TODO: Official server refuses position packets too far away from each other, kicking "hacked" clients; we should, too m_Player->SetPosition(NewPosition); - m_Player->SetStance(a_Stance); m_Player->SetTouchGround(a_IsOnGround); m_Player->UpdateMovementStats(NewPosition - OldPosition, PreviousIsOnGround); } @@ -1513,9 +1516,9 @@ void cClientHandle::HandlePlayerLook(float a_Rotation, float a_Pitch, bool a_IsO -void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, double a_Stance, float a_Rotation, float a_Pitch, bool a_IsOnGround) +void cClientHandle::HandlePlayerMoveLook(double a_PosX, double a_PosY, double a_PosZ, float a_Rotation, float a_Pitch, bool a_IsOnGround) { - HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_Stance, a_IsOnGround); + HandlePlayerPos(a_PosX, a_PosY, a_PosZ, a_IsOnGround); HandlePlayerLook(a_Rotation, a_Pitch, a_IsOnGround); } @@ -1567,6 +1570,24 @@ void cClientHandle::HandleSpectate(const cUUID & a_PlayerUUID) +void cClientHandle::HandleSprint(const bool a_IsSprinting) +{ + m_Player->SetSprint(a_IsSprinting); +} + + + + + +void cClientHandle::HandleStartElytraFlight() +{ + m_Player->SetElytraFlight(true); +} + + + + + void cClientHandle::HandleSteerVehicle(float a_Forward, float a_Sideways) { m_Player->SteerVehicle(a_Forward, a_Sideways); @@ -1831,47 +1852,11 @@ bool cClientHandle::HandleHandshake(const AString & a_Username) -void cClientHandle::HandleEntityCrouch(UInt32 a_EntityID, bool a_IsCrouching) +void cClientHandle::HandleLeaveBed() { - if (a_EntityID != m_Player->GetUniqueID()) - { - // We should only receive entity actions from the entity that is performing the action - return; - } - - m_Player->SetCrouch(a_IsCrouching); -} - - - - - -void cClientHandle::HandleEntityLeaveBed(UInt32 a_EntityID) -{ - if (a_EntityID != m_Player->GetUniqueID()) - { - // We should only receive entity actions from the entity that is performing the action - return; - } - - cChunkInterface Interface(GetPlayer()->GetWorld()->GetChunkMap()); - cBlockBedHandler::SetBedOccupationState(Interface, GetPlayer()->GetLastBedPos(), false); - GetPlayer()->SetIsInBed(false); -} - - - - - -void cClientHandle::HandleEntitySprinting(UInt32 a_EntityID, bool a_IsSprinting) -{ - if (a_EntityID != m_Player->GetUniqueID()) - { - // We should only receive entity actions from the entity that is performing the action - return; - } - - m_Player->SetSprint(a_IsSprinting); + cChunkInterface Interface(m_Player->GetWorld()->GetChunkMap()); + cBlockBedHandler::SetBedOccupationState(Interface, m_Player->GetLastBedPos(), false); + m_Player->SetIsInBed(false); } -- cgit v1.2.3