From cd1b50774512e09736b78df025163ab9b26bd528 Mon Sep 17 00:00:00 2001 From: KingCol13 <48412633+KingCol13@users.noreply.github.com> Date: Fri, 2 Oct 2020 23:57:17 +0300 Subject: Fix instant mining of blocks not being recognised, tweak anti-cheat (#4938) * Tried to fix a small issue... Ended up rewriting a bunch of god awful, opaque code with no source and no sense. Who names a function GetPlayerRelativeBlockHardness??? It's gone now. We're safe again. * Testing anti-cheat. * Tidy up debug logging. * Remove empty member declaration. * Rewrite GetDigSpeed slightly for better readability. * GetMiningProgressPerTick now returns 1 when instantly mined. Fixed hasily written typo. * Comment style and typo fixes. --- src/Entities/Player.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/Entities/Player.h') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 568929f44..791b583bd 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -597,11 +597,17 @@ public: The player removes its m_ClientHandle ownership so that the ClientHandle gets deleted. */ void RemoveClientHandle(void); - /** Returns the relative block hardness for the block a_Block. - The bigger it is the faster the player can break the block. - Returns zero if the block is instant breakable. - Otherwise it returns the dig speed (float GetDigSpeed(BLOCKTYPE a_Block)) divided by the block hardness (cBlockInfo::GetHardness(BLOCKTYPE a_Block)) divided by 30 if the player can harvest the block and divided by 100 if he can't. */ - float GetPlayerRelativeBlockHardness(BLOCKTYPE a_Block); + /** Returns the progress mined per tick for the block a_Block as a fraction + (1 would be completely mined) + Depends on hardness values so check those are correct. + Source: https://minecraft.gamepedia.com/Breaking#Calculation */ + float GetMiningProgressPerTick(BLOCKTYPE a_Block); + + /** Given tool, enchantments, status effects, and world position + returns whether a_Block would be instantly mined. + Depends on hardness values so check those are correct. + Source: https://minecraft.gamepedia.com/Breaking#Instant_breaking */ + bool CanInstantlyMine(BLOCKTYPE a_Block); /** get player explosion exposure rate */ virtual float GetExplosionExposureRate(Vector3d a_ExplosionPosition, float a_ExlosionPower) override; @@ -805,8 +811,9 @@ private: Returns one if using hand. If the player is using a tool that is good to break the block the value is higher. If he has an enchanted tool with efficiency or he has a haste or mining fatique effect it gets multiplied by a specific factor depending on the strength of the effect or enchantment. - In he is in water it gets divided by 5 except his tool is enchanted with aqa affinity. - If he is not on ground it also gets divided by 5. */ + In he is in water it gets divided by 5 except if his tool is enchanted with aqua affinity. + If he is not on ground it also gets divided by 5. + Source: https://minecraft.gamepedia.com/Breaking#Calculation */ float GetDigSpeed(BLOCKTYPE a_Block); /** Add the recipe Id to the known recipes. -- cgit v1.2.3