summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-06-23 17:00:28 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2021-06-28 22:54:21 +0200
commit3e8c945a09d92d5699b26f72d2624fb9f2f85ad5 (patch)
tree7f47bc3532d7a2dcab7d96e0d442e448a0cdd76a /src
parentDocumentation: add statistics descriptions (diff)
downloadcuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.tar
cuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.tar.gz
cuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.tar.bz2
cuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.tar.lz
cuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.tar.xz
cuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.tar.zst
cuberite-3e8c945a09d92d5699b26f72d2624fb9f2f85ad5.zip
Diffstat (limited to 'src')
-rw-r--r--src/Items/ItemLighter.h63
1 files changed, 27 insertions, 36 deletions
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 064671c2e..3fd8f3846 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -41,48 +41,39 @@ public:
if (!a_Player->IsGameModeCreative())
{
- switch (m_ItemType)
+ if (m_ItemType == E_ITEM_FLINT_AND_STEEL)
{
- case E_ITEM_FLINT_AND_STEEL:
- {
- a_Player->UseEquippedItem();
- break;
- }
- case E_ITEM_FIRE_CHARGE:
- {
- a_Player->GetInventory().RemoveOneEquippedItem();
- break;
- }
- default:
- {
- ASSERT(!"Unknown Lighter Item!");
- }
+ a_Player->UseEquippedItem();
+ }
+ else // Fire charge.
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
}
}
- switch (a_World->GetBlock(a_ClickedBlockPos))
+ // Activate TNT if we clicked on it while not crouched:
+ if ((a_World->GetBlock(a_ClickedBlockPos) == E_BLOCK_TNT) && !a_Player->IsCrouched())
{
- case E_BLOCK_TNT:
- {
- // Activate the TNT:
- a_World->DigBlock(a_ClickedBlockPos, a_Player);
- a_World->SpawnPrimedTNT(Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 0.5, 0.5)); // 80 ticks to boom
- break;
- }
- default:
+ a_World->DigBlock(a_ClickedBlockPos, a_Player);
+ a_World->SpawnPrimedTNT(Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 0.5, 0.5)); // 80 ticks to boom
+ return false;
+ }
+
+ const auto FirePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
+ if (!cChunkDef::IsValidHeight(FirePos.y))
+ {
+ return false;
+ }
+
+ // Light a fire next to / on top of the block if air:
+ if (a_World->GetBlock(FirePos) == E_BLOCK_AIR)
+ {
+ a_World->PlaceBlock(FirePos, E_BLOCK_FIRE, 0);
+
+ // The client plays flint and steel sounds, only need to handle fire charges:
+ if (m_ItemType == E_ITEM_FIRE_CHARGE)
{
- // Light a fire next to / on top of the block if air:
- auto FirePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
- if (!cChunkDef::IsValidHeight(FirePos.y))
- {
- break;
- }
- if (a_World->GetBlock(FirePos) == E_BLOCK_AIR)
- {
- a_World->PlaceBlock(FirePos, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("item.flintandsteel.use", FirePos, 1.0f, 1.04f);
- break;
- }
+ a_World->BroadcastSoundEffect("item.firecharge.use", FirePos, 1.0f, 1.04f);
}
}