1
0
Fork 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
1 changed files with 27 additions and 36 deletions

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(); else // Fire charge.
break; {
} a_Player->GetInventory().RemoveOneEquippedItem();
case E_ITEM_FIRE_CHARGE:
{
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: 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)
{ {
// Activate the TNT: a_World->BroadcastSoundEffect("item.firecharge.use", FirePos, 1.0f, 1.04f);
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:
{
// 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;
}
} }
} }