summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockOre.h
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-10-08 21:13:44 +0200
committerGitHub <noreply@github.com>2020-10-08 21:13:44 +0200
commit3381c0f6d6671a485283c889b036c0a431e2a2b9 (patch)
treebf32b4d9c8d8e6c4c8d232ca6ad16975ee6d17c6 /src/Blocks/BlockOre.h
parentFix cmake not adding Werror on clang, and _lots_ of warnings (#4963) (diff)
downloadcuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.tar
cuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.tar.gz
cuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.tar.bz2
cuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.tar.lz
cuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.tar.xz
cuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.tar.zst
cuberite-3381c0f6d6671a485283c889b036c0a431e2a2b9.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockOre.h33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/Blocks/BlockOre.h b/src/Blocks/BlockOre.h
index 023e149d9..6d6c2a097 100644
--- a/src/Blocks/BlockOre.h
+++ b/src/Blocks/BlockOre.h
@@ -64,26 +64,33 @@ private:
- virtual void OnPlayerBrokeBlock(
+ virtual void OnBroken(
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
- cPlayer & a_Player, Vector3i a_BlockPos,
- BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
+ Vector3i a_BlockPos,
+ BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta,
+ const cEntity * a_Digger
) const override
{
- if (!a_Player.IsGameModeSurvival())
+ if (!a_Digger->IsPlayer())
+ {
+ return;
+ }
+
+ const auto Player = static_cast<const cPlayer *>(a_Digger);
+ if (!Player->IsGameModeSurvival())
{
// Don't drop XP unless the player is in survival mode.
return;
}
- if (a_Player.GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) != 0)
+ if (Player->GetEquippedItem().m_Enchantments.GetLevel(cEnchantments::enchSilkTouch) != 0)
{
// Don't drop XP when the ore is mined with the Silk Touch enchantment
return;
}
- auto & random = GetRandomProvider();
- int reward = 0;
+ auto & Random = GetRandomProvider();
+ int Reward = 0;
switch (a_OldBlockType)
{
@@ -91,36 +98,36 @@ private:
case E_BLOCK_LAPIS_ORE:
{
// Lapis and nether quartz get 2 - 5 experience
- reward = random.RandInt(2, 5);
+ Reward = Random.RandInt(2, 5);
break;
}
case E_BLOCK_REDSTONE_ORE:
case E_BLOCK_REDSTONE_ORE_GLOWING:
{
// Redstone gets 1 - 5 experience
- reward = random.RandInt(1, 5);
+ Reward = Random.RandInt(1, 5);
break;
}
case E_BLOCK_DIAMOND_ORE:
case E_BLOCK_EMERALD_ORE:
{
// Diamond and emerald get 3 - 7 experience
- reward = random.RandInt(3, 7);
+ Reward = Random.RandInt(3, 7);
break;
}
case E_BLOCK_COAL_ORE:
{
// Coal gets 0 - 2 experience
- reward = random.RandInt(2);
+ Reward = Random.RandInt(2);
break;
}
default: break;
}
- if (reward > 0)
+ if (Reward > 0)
{
- a_WorldInterface.SpawnSplitExperienceOrbs(Vector3d(0.5, 0.5, 0.5) + a_BlockPos, reward);
+ a_WorldInterface.SpawnSplitExperienceOrbs(Vector3d(0.5, 0.5, 0.5) + a_BlockPos, Reward);
}
}
} ;