summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemLighter.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Items/ItemLighter.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index 241e0511e..d4469a31b 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -9,23 +9,32 @@
-class cItemLighterHandler :
+class cItemLighterHandler:
public cItemHandler
{
+ using Super = cItemHandler;
+
public:
- cItemLighterHandler(int a_ItemType) :
- cItemHandler(a_ItemType)
+
+ cItemLighterHandler(int a_ItemType):
+ Super(a_ItemType)
{
}
+
+
virtual bool OnItemUse(
- cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item,
- int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace
+ cWorld * a_World,
+ cPlayer * a_Player,
+ cBlockPluginInterface & a_PluginInterface,
+ const cItem & a_HeldItem,
+ const Vector3i a_ClickedBlockPos,
+ eBlockFace a_ClickedBlockFace
) override
{
- if (a_BlockFace < 0)
+ if (a_ClickedBlockFace < 0)
{
return false;
}
@@ -51,27 +60,27 @@ public:
}
}
- switch (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ))
+ switch (a_World->GetBlock(a_ClickedBlockPos))
{
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
- a_World->SpawnPrimedTNT({a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5}); // 80 ticks to boom
+ a_World->SetBlock(a_ClickedBlockPos, E_BLOCK_AIR, 0);
+ 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:
- AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- if ((a_BlockY < 0) || (a_BlockY >= cChunkDef::Height))
+ auto FirePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace);
+ if (!cChunkDef::IsValidHeight(FirePos.y))
{
break;
}
- if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR)
+ if (a_World->GetBlock(FirePos) == E_BLOCK_AIR)
{
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0);
- a_World->BroadcastSoundEffect("item.flintandsteel.use", Vector3d(a_BlockX, a_BlockY, a_BlockZ), 1.0F, 1.04F);
+ a_World->SetBlock(FirePos, E_BLOCK_FIRE, 0);
+ a_World->BroadcastSoundEffect("item.flintandsteel.use", FirePos, 1.0f, 1.04f);
break;
}
}