summaryrefslogtreecommitdiffstats
path: root/source/Items/ItemHandler.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-01-12 05:46:01 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2013-01-12 05:46:01 +0100
commit43e684071933adef93040e8d4b830d5c6b71cf9a (patch)
tree014e5300feb1cdbbb8f24e4e42594eeb841f0be2 /source/Items/ItemHandler.cpp
parentFixed rclk in doublechests (diff)
downloadcuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.gz
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.bz2
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.lz
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.xz
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.tar.zst
cuberite-43e684071933adef93040e8d4b830d5c6b71cf9a.zip
Diffstat (limited to 'source/Items/ItemHandler.cpp')
-rw-r--r--source/Items/ItemHandler.cpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp
index 6426ce212..1200fa27a 100644
--- a/source/Items/ItemHandler.cpp
+++ b/source/Items/ItemHandler.cpp
@@ -386,50 +386,38 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType)
-BLOCKTYPE cItemHandler::GetBlockType()
+bool cItemHandler::GetPlacementBlockTypeMeta(
+ cWorld * a_World, cPlayer * a_Player,
+ int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace,
+ int a_CursorX, int a_CursorY, int a_CursorZ,
+ BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
+)
{
ASSERT(m_ItemType < 256); // Items with IDs above 255 should all be handled by specific handlers
- #ifdef _DEBUG
if (m_ItemType > 256)
{
- LOGERROR("Item %d has no valid block!", m_ItemType);
+ LOGERROR("%s: Item %d has no valid block!", __FUNCTION__, m_ItemType);
+ return false;
}
- #endif // _DEBUG
- return (BLOCKTYPE) m_ItemType;
+ cBlockHandler * BlockH = BlockHandler(m_ItemType);
+ return BlockH->GetPlacementBlockTypeMeta(
+ a_World, a_Player,
+ a_BlockX, a_BlockY, a_BlockZ, a_BlockFace,
+ a_CursorX, a_CursorY, a_CursorZ,
+ a_BlockType, a_BlockMeta
+ );
+ a_BlockType = (BLOCKTYPE) m_ItemType;
+ a_BlockMeta = (NIBBLETYPE)(a_Player->GetEquippedItem().m_ItemDamage & 0x0f); // This keeps most textures. The few other items have to override this
+ return true;
}
-NIBBLETYPE cItemHandler::GetBlockMeta(short a_ItemDamage)
-{
- return (NIBBLETYPE)a_ItemDamage & 0x0f; // This keeps most textures. The few other items have to override this
-}
-
-
-
-
-
-void cItemHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
-{
- BLOCKTYPE Block = GetBlockType();
- cBlockHandler *Handler = cBlockHandler::GetBlockHandler(Block);
- Handler->PlaceBlock(a_World, a_Player, GetBlockMeta(a_Item->m_ItemHealth), a_BlockX, a_BlockY, a_BlockZ, a_Dir);
- if(a_Player->GetGameMode() == eGameMode_Survival)
- {
- cItem Item(a_Item->m_ItemType, 1);
- a_Player->GetInventory().RemoveItem(Item);
- }
-}
-
-
-
-
-
-bool cItemHandler::EatItem(cPlayer *a_Player, cItem *a_Item)
+bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
{
FoodInfo Info = GetFoodInfo();