summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-11-06 15:58:47 +0100
committerGitHub <noreply@github.com>2020-11-06 15:58:47 +0100
commit645fea423764e9d91e46b84a63aba5a47b954c6a (patch)
treefee34fff873294c2f16ba92a6477143d45e83b7d /src/Entities
parentRein in light spread by correcting falloff value (diff)
downloadcuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.tar
cuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.tar.gz
cuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.tar.bz2
cuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.tar.lz
cuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.tar.xz
cuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.tar.zst
cuberite-645fea423764e9d91e46b84a63aba5a47b954c6a.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Player.cpp26
-rw-r--r--src/Entities/Player.h1
2 files changed, 9 insertions, 18 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 888792773..a8afb2b95 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -3228,21 +3228,15 @@ float cPlayer::GetMiningProgressPerTick(BLOCKTYPE a_Block)
{
return 1;
}
- float BlockHardness = cBlockInfo::GetHardness(a_Block);
+
+ const bool CanHarvest = GetEquippedItem().GetHandler()->CanHarvestBlock(a_Block);
+ const float BlockHardness = cBlockInfo::GetHardness(a_Block) * (CanHarvest ? 1.5f : 5.0f);
ASSERT(BlockHardness > 0); // Can't divide by 0 or less, IsOneHitDig should have returned true
- if (GetEquippedItem().GetHandler()->CanHarvestBlock(a_Block))
- {
- BlockHardness *= 1.5f;
- }
- else
- {
- BlockHardness *= 5.0f;
- }
- float DigSpeed = GetDigSpeed(a_Block);
+
// LOGD("Time to mine block = %f", BlockHardness/DigSpeed);
// Number of ticks to mine = (20 * BlockHardness)/DigSpeed;
// Therefore take inverse to get fraction mined per tick:
- return DigSpeed / (20.0f * BlockHardness);
+ return GetDigSpeed(a_Block) / (20.0f * BlockHardness);
}
@@ -3252,13 +3246,9 @@ float cPlayer::GetMiningProgressPerTick(BLOCKTYPE a_Block)
bool cPlayer::CanInstantlyMine(BLOCKTYPE a_Block)
{
// Based on: https://minecraft.gamepedia.com/Breaking#Calculation
- // Check it has non-zero hardness
- if (cBlockInfo::IsOneHitDig(a_Block))
- {
- return true;
- }
- // If the dig speed is greater than 30 times the hardness, then the wiki says we can instantly mine
- return GetDigSpeed(a_Block) > 30 * cBlockInfo::GetHardness(a_Block);
+
+ // If the dig speed is greater than 30 times the hardness, then the wiki says we can instantly mine:
+ return GetDigSpeed(a_Block) > (30 * cBlockInfo::GetHardness(a_Block));
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index a16a8d0d6..bdcacd608 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -798,6 +798,7 @@ protected:
/** Returns the filename for the player data based on the UUID given.
This can be used both for online and offline UUIDs. */
AString GetUUIDFileName(const cUUID & a_UUID);
+
private:
/** Pins the player to a_Location until Unfreeze() is called.