summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
Diffstat (limited to 'src/Items')
-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);
}
}