From d49ce751ba6f8f2eb171633cea30a1119935f8c7 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 11 Nov 2021 21:02:29 +0000 Subject: Miscellaneous fixes (#5320) * Protocol: update Abilities flags + Add Spectator handling * BioGen: move include * ClientHandle: rename Respawn packet dimension check flag * Make it clearer what it's doing. * ClientHandle: move ProcessProtocolIn calls to World * Player: remove some redundant initialisation * Player: UpdateCapabilities enables flight for spectators * Produce growth: improve comments * ClientHandle: run unload checks using delta time * Fix forgotten initialisation of time member --- src/Protocol/Protocol_1_14.cpp | 3 --- src/Protocol/Protocol_1_8.cpp | 15 ++++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/Protocol') diff --git a/src/Protocol/Protocol_1_14.cpp b/src/Protocol/Protocol_1_14.cpp index 0d0bc49a0..f38227edd 100644 --- a/src/Protocol/Protocol_1_14.cpp +++ b/src/Protocol/Protocol_1_14.cpp @@ -90,9 +90,6 @@ void cProtocol_1_14::SendLogin(const cPlayer & a_Player, const cWorld & a_World) // cPacketizer Pkt(*this, pktDifficulty); // Pkt.WriteBEInt8(1); } - - // Send player abilities: - SendPlayerAbilities(); } diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index d29126e4e..e2e8ca499 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -934,13 +934,12 @@ void cProtocol_1_8_0::SendPlayerAbilities(void) { ASSERT(m_State == 3); // In game mode? - cPacketizer Pkt(*this, pktPlayerAbilities); Byte Flags = 0; - cPlayer * Player = m_Client->GetPlayer(); - if (Player->IsGameModeCreative()) + const cPlayer * Player = m_Client->GetPlayer(); + + if (Player->IsGameModeCreative() || Player->IsGameModeSpectator()) { - Flags |= 0x01; - Flags |= 0x08; // Godmode, used for creative + Flags |= 0x01; // Invulnerability. } if (Player->IsFlying()) { @@ -950,6 +949,12 @@ void cProtocol_1_8_0::SendPlayerAbilities(void) { Flags |= 0x04; } + if (Player->IsGameModeCreative()) + { + Flags |= 0x08; // Godmode: creative instant break. + } + + cPacketizer Pkt(*this, pktPlayerAbilities); Pkt.WriteBEUInt8(Flags); Pkt.WriteBEFloat(static_cast(0.05 * Player->GetFlyingMaxSpeed())); Pkt.WriteBEFloat(static_cast(0.1 * Player->GetNormalMaxSpeed())); -- cgit v1.2.3