1
0

Lighters: don't activate TNT when crouched

* Fixes #5247
This commit is contained in:
Tiger Wang 2021-06-23 16:00:28 +01:00
parent 17048fc1e3
commit 3e8c945a09

View File

@ -41,48 +41,39 @@ public:
if (!a_Player->IsGameModeCreative()) if (!a_Player->IsGameModeCreative())
{ {
switch (m_ItemType) if (m_ItemType == E_ITEM_FLINT_AND_STEEL)
{
case E_ITEM_FLINT_AND_STEEL:
{ {
a_Player->UseEquippedItem(); a_Player->UseEquippedItem();
break;
} }
case E_ITEM_FIRE_CHARGE: else // Fire charge.
{ {
a_Player->GetInventory().RemoveOneEquippedItem(); a_Player->GetInventory().RemoveOneEquippedItem();
break;
}
default:
{
ASSERT(!"Unknown Lighter Item!");
}
} }
} }
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->DigBlock(a_ClickedBlockPos, a_Player);
a_World->SpawnPrimedTNT(Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 0.5, 0.5)); // 80 ticks to boom a_World->SpawnPrimedTNT(Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 0.5, 0.5)); // 80 ticks to boom
break; return false;
} }
default:
{ const auto FirePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
// Light a fire next to / on top of the block if air:
auto FirePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
if (!cChunkDef::IsValidHeight(FirePos.y)) if (!cChunkDef::IsValidHeight(FirePos.y))
{ {
break; return false;
} }
// Light a fire next to / on top of the block if air:
if (a_World->GetBlock(FirePos) == E_BLOCK_AIR) if (a_World->GetBlock(FirePos) == E_BLOCK_AIR)
{ {
a_World->PlaceBlock(FirePos, E_BLOCK_FIRE, 0); a_World->PlaceBlock(FirePos, E_BLOCK_FIRE, 0);
a_World->BroadcastSoundEffect("item.flintandsteel.use", FirePos, 1.0f, 1.04f);
break; // The client plays flint and steel sounds, only need to handle fire charges:
} if (m_ItemType == E_ITEM_FIRE_CHARGE)
{
a_World->BroadcastSoundEffect("item.firecharge.use", FirePos, 1.0f, 1.04f);
} }
} }