summaryrefslogtreecommitdiffstats
path: root/source/items
diff options
context:
space:
mode:
authorlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-17 16:33:51 +0200
committerlapayo94@gmail.com <lapayo94@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-17 16:33:51 +0200
commitaaf772f68a11d1deb7897a0cd09c25cda2fd149d (patch)
treec929cccc33810cf1d953c0ba75d7e31202e03f1e /source/items
parentSimple health regeneration system (diff)
downloadcuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.tar
cuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.tar.gz
cuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.tar.bz2
cuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.tar.lz
cuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.tar.xz
cuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.tar.zst
cuberite-aaf772f68a11d1deb7897a0cd09c25cda2fd149d.zip
Diffstat (limited to 'source/items')
-rw-r--r--source/items/Item.cpp5
-rw-r--r--source/items/ItemBucket.h13
-rw-r--r--source/items/ItemDye.h3
-rw-r--r--source/items/ItemSlab.h3
4 files changed, 16 insertions, 8 deletions
diff --git a/source/items/Item.cpp b/source/items/Item.cpp
index ce72cf8b3..2596548d6 100644
--- a/source/items/Item.cpp
+++ b/source/items/Item.cpp
@@ -237,7 +237,10 @@ void cItemHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item,
cBlockHandler *Handler = cBlockHandler::GetBlockHandler(Block);
Handler->PlaceBlock(a_World, a_Player, GetBlockMeta(a_Item->m_ItemHealth), a_X, a_Y, a_Z, a_Dir);
if(a_Player->GetGameMode() == eGameMode_Survival)
- a_Player->GetInventory().RemoveItem(cItem(a_Item->m_ItemID, 1));
+ {
+ cItem Item(a_Item->m_ItemID, 1);
+ a_Player->GetInventory().RemoveItem(Item);
+ }
}
bool cItemHandler::EatItem(cPlayer *a_Player, cItem *a_Item)
diff --git a/source/items/ItemBucket.h b/source/items/ItemBucket.h
index c74fc68ee..60718b2fb 100644
--- a/source/items/ItemBucket.h
+++ b/source/items/ItemBucket.h
@@ -33,11 +33,13 @@ public:
NewItem = E_ITEM_LAVA_BUCKET;
break;
}
+ cItem Item(a_Item->m_ItemID, 1);
if (NewItem != E_ITEM_EMPTY
- && (a_Player->GetGameMode() == 1 || (a_Player->GetInventory().RemoveItem(cItem(a_Item->m_ItemID, 1)))))
+ && (a_Player->GetGameMode() == 1 || (a_Player->GetInventory().RemoveItem(Item))))
{
//Give New Bucket
- a_Player->GetInventory().AddItem(cItem(NewItem, 1));
+ cItem Item(NewItem, 1);
+ a_Player->GetInventory().AddItem(Item);
//remove water block
a_Player->GetWorld()->SetBlock(a_X, a_Y, a_Z, E_BLOCK_AIR, 0);
return true;
@@ -52,7 +54,8 @@ public:
AddDirection(a_X, a_Y, a_Z, a_Dir);
if(a_World->GetBlock(a_X, a_Y, a_Z) == E_BLOCK_AIR)
{
- if ((a_Player->GetGameMode() == 1) || (a_Player->GetInventory().RemoveItem(cItem(a_Item->m_ItemID, 1))))
+ cItem Item(a_Item->m_ItemID, 1);
+ if ((a_Player->GetGameMode() == 1) || (a_Player->GetInventory().RemoveItem(Item)))
{
a_World->SetBlock(a_X, a_Y, a_Z, NewBlock, 0);
@@ -60,8 +63,8 @@ public:
{
break; //No new Bucket for creative players
}
-
- a_Player->GetInventory().AddItem(cItem(E_ITEM_BUCKET, 1));
+ cItem Item(E_ITEM_BUCKET, 1);
+ a_Player->GetInventory().AddItem(Item);
return true;
}
}
diff --git a/source/items/ItemDye.h b/source/items/ItemDye.h
index 5cf470e04..2203f410b 100644
--- a/source/items/ItemDye.h
+++ b/source/items/ItemDye.h
@@ -22,7 +22,8 @@ public:
{
if (a_Player->GetGameMode() == eGameMode_Survival)
{
- a_Player->GetInventory().RemoveItem(cItem(a_Item->m_ItemID, 1, a_Item->m_ItemHealth));
+ cItem Item(a_Item->m_ItemID, 1, a_Item->m_ItemHealth);
+ a_Player->GetInventory().RemoveItem(Item);
return true;
}
}
diff --git a/source/items/ItemSlab.h b/source/items/ItemSlab.h
index 38b0aa213..9b91530c9 100644
--- a/source/items/ItemSlab.h
+++ b/source/items/ItemSlab.h
@@ -23,7 +23,8 @@ public:
&& (Block == a_Item->m_ItemID) //Same slab
&& ((Meta & 0x7) == (a_Item->m_ItemHealth & 0x7))) //Same Texture
{
- if(a_Player->GetInventory().RemoveItem(cItem(a_Item->m_ItemID, 1)))
+ cItem Item(a_Item->m_ItemID, 1);
+ if(a_Player->GetInventory().RemoveItem(Item))
{
a_World->SetBlock(a_X, a_Y, a_Z, Block - 1, Meta); //Block - 1 simple hack to save one if statement
return true;