summaryrefslogtreecommitdiffstats
path: root/source/Items
diff options
context:
space:
mode:
Diffstat (limited to 'source/Items')
-rw-r--r--source/Items/ItemBucket.h14
-rw-r--r--source/Items/ItemDye.h6
-rw-r--r--source/Items/ItemHandler.cpp8
-rw-r--r--source/Items/ItemHandler.h6
-rw-r--r--source/Items/ItemHoe.h2
-rw-r--r--source/Items/ItemLighter.h4
-rw-r--r--source/Items/ItemMinecart.h2
-rw-r--r--source/Items/ItemShears.h2
-rw-r--r--source/Items/ItemShovel.h2
-rw-r--r--source/Items/ItemSlab.h8
-rw-r--r--source/Items/ItemSpawnEgg.h7
11 files changed, 31 insertions, 30 deletions
diff --git a/source/Items/ItemBucket.h b/source/Items/ItemBucket.h
index 35cc1bd2b..098742724 100644
--- a/source/Items/ItemBucket.h
+++ b/source/Items/ItemBucket.h
@@ -20,7 +20,7 @@ public:
}
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
switch (m_ItemType)
{
@@ -37,7 +37,7 @@ public:
- bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
+ bool ScoopUpFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace)
{
if (a_BlockFace < 0)
{
@@ -54,7 +54,7 @@ public:
return false;
}
- if (a_Player->GetGameMode() == eGameMode_Creative)
+ if (a_Player->GetGameMode() == gmCreative)
{
// In creative mode don't modify the inventory, just remove the fluid:
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
@@ -81,7 +81,7 @@ public:
}
// Remove the bucket from the inventory
- cItem Item(a_Item->m_ItemType, 1);
+ cItem Item(a_Item.m_ItemType, 1);
if (!a_Player->GetInventory().RemoveItem(Item))
{
LOG("Clicked with an empty bucket, but cannot remove one from the inventory? WTF?");
@@ -100,7 +100,7 @@ public:
}
- bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_FluidBlock)
+ bool PlaceFluid(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, BLOCKTYPE a_FluidBlock)
{
if (a_BlockFace < 0)
{
@@ -128,10 +128,10 @@ public:
return false;
}
- if (a_Player->GetGameMode() != eGameMode_Creative)
+ if (a_Player->GetGameMode() != gmCreative)
{
// Remove fluid bucket, add empty bucket:
- cItem Item(a_Item->m_ItemType, 1);
+ cItem Item(a_Item.m_ItemType, 1);
if (!a_Player->GetInventory().RemoveItem(Item))
{
LOG("Clicked with a full bucket, but cannot remove one from the inventory? WTF?");
diff --git a/source/Items/ItemDye.h b/source/Items/ItemDye.h
index 020117c97..ab9ff3f60 100644
--- a/source/Items/ItemDye.h
+++ b/source/Items/ItemDye.h
@@ -19,17 +19,17 @@ public:
}
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
// TODO: Handle coloring the sheep, too (OnItemUseOnEntity maybe)
// Handle growing the plants:
- if (a_Item->m_ItemDamage == E_META_DYE_WHITE)
+ if (a_Item.m_ItemDamage == E_META_DYE_WHITE)
{
if (a_World->GrowRipePlant(a_BlockX, a_BlockY, a_BlockZ, true))
{
if (a_Player->GetGameMode() != eGameMode_Creative)
{
- cItem Item(a_Item->m_ItemType, 1, a_Item->m_ItemDamage);
+ cItem Item(a_Item.m_ItemType, 1, a_Item.m_ItemDamage);
a_Player->GetInventory().RemoveItem(Item);
return true;
}
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp
index df3257263..3f5d460b3 100644
--- a/source/Items/ItemHandler.cpp
+++ b/source/Items/ItemHandler.cpp
@@ -214,7 +214,7 @@ cItemHandler::cItemHandler(int a_ItemType)
-bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
+bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
{
return false;
}
@@ -223,7 +223,7 @@ bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Ite
-bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
+bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
{
return false;
}
@@ -232,12 +232,12 @@ bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem *
-void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ)
+void cItemHandler::OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ)
{
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
cBlockHandler * Handler = cBlockHandler::GetBlockHandler(Block);
- if (a_Player->GetGameMode() == eGameMode_Survival)
+ if (a_Player->GetGameMode() == gmSurvival)
{
if (!BlockRequiresSpecialTool(Block) || CanHarvestBlock(Block))
{
diff --git a/source/Items/ItemHandler.h b/source/Items/ItemHandler.h
index 58e7324d8..0c141dea0 100644
--- a/source/Items/ItemHandler.h
+++ b/source/Items/ItemHandler.h
@@ -22,13 +22,13 @@ public:
cItemHandler(int a_ItemType);
/// Called when the player tries to use the item. Return false to make the item unusable. DEFAULT: False
- virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); //eg for fishing or hoes
+ virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir); //eg for fishing or hoes
/// Called while the player diggs a block using this item
- virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem * a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace);
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_HeldItem, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace);
/// Called when the player destroys a block using this item. This also calls the drop function for the destroyed block
- virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z);
+ virtual void OnBlockDestroyed(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_X, int a_Y, int a_Z);
/// Called after the player has eaten this item.
virtual void OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item);
diff --git a/source/Items/ItemHoe.h b/source/Items/ItemHoe.h
index bd39b7287..58f989341 100644
--- a/source/Items/ItemHoe.h
+++ b/source/Items/ItemHoe.h
@@ -14,7 +14,7 @@ public:
}
- virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
diff --git a/source/Items/ItemLighter.h b/source/Items/ItemLighter.h
index 8c4d068a9..fe8cd1370 100644
--- a/source/Items/ItemLighter.h
+++ b/source/Items/ItemLighter.h
@@ -18,7 +18,7 @@ public:
{
}
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
{
if (a_BlockFace < 0)
{
@@ -29,7 +29,7 @@ public:
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
- a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0); //0 -> new fire TODO: Make Firesimulator use this
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_FIRE, 0); //0 -> new fire
return false;
}
diff --git a/source/Items/ItemMinecart.h b/source/Items/ItemMinecart.h
index 41e0e9ed7..ca8cc16aa 100644
--- a/source/Items/ItemMinecart.h
+++ b/source/Items/ItemMinecart.h
@@ -29,7 +29,7 @@ public:
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
if (a_Dir < 0)
{
diff --git a/source/Items/ItemShears.h b/source/Items/ItemShears.h
index dbdfeff5d..d6cf48b3f 100644
--- a/source/Items/ItemShears.h
+++ b/source/Items/ItemShears.h
@@ -25,7 +25,7 @@ public:
}
- virtual bool OnDiggingBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if (Block == E_BLOCK_LEAVES)
diff --git a/source/Items/ItemShovel.h b/source/Items/ItemShovel.h
index 7914a1703..f26e393c8 100644
--- a/source/Items/ItemShovel.h
+++ b/source/Items/ItemShovel.h
@@ -20,7 +20,7 @@ public:
}
- virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
if (Block == E_BLOCK_SNOW)
diff --git a/source/Items/ItemSlab.h b/source/Items/ItemSlab.h
index 42311d54d..9f4760053 100644
--- a/source/Items/ItemSlab.h
+++ b/source/Items/ItemSlab.h
@@ -17,7 +17,7 @@ public:
}
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override
{
BLOCKTYPE Block;
NIBBLETYPE Meta;
@@ -26,8 +26,8 @@ public:
if (
((a_Dir == 0) || (a_Dir == 1)) // Only when clicking on top or on bottom of the block
&& ((Block == E_BLOCK_WOODEN_SLAB) || (Block == E_BLOCK_STONE_SLAB)) // It is a slab
- && (Block == a_Item->m_ItemType) // Same slab
- && ((Meta & 0x7) == (a_Item->m_ItemDamage & 0x7))) // Same Texture
+ && (Block == a_Item.m_ItemType) // Same slab
+ && ((Meta & 0x7) == (a_Item.m_ItemDamage & 0x7))) // Same Texture
{
if (a_Player->GetGameMode() == eGameMode_Creative)
{
@@ -36,7 +36,7 @@ public:
}
else
{
- cItem Item(a_Item->m_ItemType, 1);
+ cItem Item(a_Item.m_ItemType, 1);
if (a_Player->GetInventory().RemoveItem(Item))
{
a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, Block - 1, Meta); // Block - 1 simple hack to save one if statement
diff --git a/source/Items/ItemSpawnEgg.h b/source/Items/ItemSpawnEgg.h
index 1557fb59c..c6fa363bb 100644
--- a/source/Items/ItemSpawnEgg.h
+++ b/source/Items/ItemSpawnEgg.h
@@ -19,7 +19,7 @@ public:
}
- virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace) override
{
if (a_BlockFace < 0)
{
@@ -33,12 +33,13 @@ public:
a_BlockY--;
}
- if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item->m_ItemDamage) >= 0)
+ if (a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, a_Item.m_ItemDamage) >= 0)
{
if (a_Player->GetGameMode() != 1)
{
// The mob was spawned, "use" the item:
- a_Player->GetInventory().RemoveItem(a_Player->GetInventory().GetEquippedItem());
+ cItem Equipped(a_Player->GetEquippedItem());
+ a_Player->GetInventory().RemoveItem(Equipped);
}
return true;
}