diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-18 21:41:29 +0200 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-10-18 21:41:29 +0200 |
commit | c68aa68c699a618d0172bceacf553ab96fc32cdd (patch) | |
tree | a2eb1d2e76ea183f2c0aee66accd98beeba48e0d /source/Items/ItemHandler.cpp | |
parent | Fixed item damage value not being read from the 1.3.2 protocol (wtf, why was it disabled?) (diff) | |
download | cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.tar cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.tar.gz cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.tar.bz2 cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.tar.lz cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.tar.xz cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.tar.zst cuberite-c68aa68c699a618d0172bceacf553ab96fc32cdd.zip |
Diffstat (limited to 'source/Items/ItemHandler.cpp')
-rw-r--r-- | source/Items/ItemHandler.cpp | 124 |
1 files changed, 62 insertions, 62 deletions
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index af050eabd..021794f84 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -42,44 +42,44 @@ cItemHandler * cItemHandler::m_ItemHandler[2266]; -cItemHandler *cItemHandler::GetItemHandler(int a_ItemID)
+cItemHandler *cItemHandler::GetItemHandler(int a_ItemType)
{
- if(a_ItemID < 0) a_ItemID = 0;
+ if(a_ItemType < 0) a_ItemType = 0;
if(!m_HandlerInitialized)
{ //We have to initialize
memset(m_ItemHandler, 0, sizeof(m_ItemHandler));
m_HandlerInitialized = true;
}
- if(m_ItemHandler[a_ItemID])
- return m_ItemHandler[a_ItemID];
- m_ItemHandler[a_ItemID] = CreateItemHandler(a_ItemID);
- return m_ItemHandler[a_ItemID];
+ if(m_ItemHandler[a_ItemType])
+ return m_ItemHandler[a_ItemType];
+ m_ItemHandler[a_ItemType] = CreateItemHandler(a_ItemType);
+ return m_ItemHandler[a_ItemType];
}
-cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID)
+cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
{
- switch(a_ItemID)
+ switch(a_ItemType)
{
- default: return new cItemHandler(a_ItemID);
+ default: return new cItemHandler(a_ItemType);
// Single item per handler, alphabetically sorted:
- case E_ITEM_BED: return new cItemBedHandler(a_ItemID);
- case E_ITEM_DYE: return new cItemDyeHandler(a_ItemID);
- case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemID);
- case E_ITEM_LEAVES: return new cItemLeavesHandler(a_ItemID);
- case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemID);
- case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemID);
- case E_ITEM_SAPLING: return new cItemSaplingHandler(a_ItemID);
- case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemID);
- case E_ITEM_SIGN: return new cItemSignHandler(a_ItemID);
- case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemID);
- case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemID);
- case E_ITEM_WOOL: return new cItemClothHandler(a_ItemID);
+ case E_ITEM_BED: return new cItemBedHandler(a_ItemType);
+ case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType);
+ case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType);
+ case E_ITEM_LEAVES: return new cItemLeavesHandler(a_ItemType);
+ case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType);
+ case E_ITEM_REDSTONE_REPEATER: return new cItemRedstoneRepeaterHandler(a_ItemType);
+ case E_ITEM_SAPLING: return new cItemSaplingHandler(a_ItemType);
+ case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemType);
+ case E_ITEM_SIGN: return new cItemSignHandler(a_ItemType);
+ case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType);
+ case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType);
+ case E_ITEM_WOOL: return new cItemClothHandler(a_ItemType);
case E_ITEM_WOODEN_HOE:
case E_ITEM_STONE_HOE:
@@ -87,7 +87,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID) case E_ITEM_GOLD_HOE:
case E_ITEM_DIAMOND_HOE:
{
- return new cItemHoeHandler(a_ItemID);
+ return new cItemHoeHandler(a_ItemType);
}
case E_ITEM_WOODEN_PICKAXE:
@@ -96,7 +96,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID) case E_ITEM_GOLD_PICKAXE:
case E_ITEM_DIAMOND_PICKAXE:
{
- return new cItemPickaxeHandler(a_ItemID);
+ return new cItemPickaxeHandler(a_ItemType);
}
case E_ITEM_WOODEN_SHOVEL:
@@ -105,7 +105,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID) case E_ITEM_GOLD_SHOVEL:
case E_ITEM_DIAMOND_SHOVEL:
{
- return new cItemShovelHandler(a_ItemID);
+ return new cItemShovelHandler(a_ItemType);
}
case E_ITEM_WOODEN_SWORD:
@@ -114,39 +114,39 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID) case E_ITEM_GOLD_SWORD:
case E_ITEM_DIAMOND_SWORD:
{
- return new cItemSwordHandler(a_ItemID);
+ return new cItemSwordHandler(a_ItemType);
}
case E_ITEM_STONE_SLAB:
case E_ITEM_WOODEN_SLAB:
{
- return new cItemSlabHandler(a_ItemID);
+ return new cItemSlabHandler(a_ItemType);
}
case E_ITEM_LOG:
case E_ITEM_PLANKS:
{
- return new cItemWoodHandler(a_ItemID);
+ return new cItemWoodHandler(a_ItemType);
}
case E_ITEM_BUCKET:
case E_ITEM_WATER_BUCKET:
case E_ITEM_LAVA_BUCKET:
{
- return new cItemBucketHandler(a_ItemID);
+ return new cItemBucketHandler(a_ItemType);
}
case E_ITEM_PUMPKIN_SEEDS:
case E_ITEM_MELON_SEEDS:
case E_ITEM_SEEDS:
{
- return new cItemSeedsHandler(a_ItemID);
+ return new cItemSeedsHandler(a_ItemType);
}
case E_ITEM_IRON_DOOR:
case E_ITEM_WOODEN_DOOR:
{
- return new cItemDoorHandler(a_ItemID);
+ return new cItemDoorHandler(a_ItemType);
}
// Food:
@@ -166,7 +166,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID) case E_ITEM_ROTTEN_FLESH:
case E_ITEM_SPIDER_EYE:
{
- return new cItemFoodHandler(a_ItemID);
+ return new cItemFoodHandler(a_ItemType);
}
}
}
@@ -188,16 +188,16 @@ void cItemHandler::Deinit() -cItemHandler::cItemHandler(int a_ItemID)
+cItemHandler::cItemHandler(int a_ItemType)
{
- m_ItemID = a_ItemID;
+ m_ItemType = a_ItemType;
}
-bool cItemHandler::OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir)
+bool cItemHandler::OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
{
return false;
}
@@ -206,7 +206,7 @@ bool cItemHandler::OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, -bool cItemHandler::OnDiggingBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir)
+bool cItemHandler::OnDiggingBlock(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir)
{
return false;
}
@@ -246,13 +246,13 @@ void cItemHandler::OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item char cItemHandler::GetMaxStackSize(void)
{
- if (m_ItemID < 256)
+ if (m_ItemType < 256)
{
// All blocks can stack up to 64
return 64;
}
- switch (m_ItemID)
+ switch (m_ItemType)
{
case E_ITEM_APPLE: return 64;
case E_ITEM_ARROW: return 64;
@@ -291,14 +291,14 @@ char cItemHandler::GetMaxStackSize(void) bool cItemHandler::IsTool()
{
return
- (m_ItemID >= 256 && m_ItemID <= 259)
- || (m_ItemID == 261)
- || (m_ItemID >= 267 && m_ItemID <= 279)
- || (m_ItemID >= 283 && m_ItemID <= 286)
- || (m_ItemID >= 290 && m_ItemID <= 294)
- || (m_ItemID >= 256 && m_ItemID <= 259)
- || (m_ItemID == 325)
- || (m_ItemID == 346);
+ (m_ItemType >= 256 && m_ItemType <= 259)
+ || (m_ItemType == 261)
+ || (m_ItemType >= 267 && m_ItemType <= 279)
+ || (m_ItemType >= 283 && m_ItemType <= 286)
+ || (m_ItemType >= 290 && m_ItemType <= 294)
+ || (m_ItemType >= 256 && m_ItemType <= 259)
+ || (m_ItemType == 325)
+ || (m_ItemType == 346);
}
@@ -308,15 +308,15 @@ bool cItemHandler::IsTool() bool cItemHandler::IsFood()
{
return
- (m_ItemID == 260)
- || (m_ItemID == 282)
- || (m_ItemID == 297)
- || (m_ItemID >= 319 && m_ItemID <= 320)
- || (m_ItemID == 335)
- || (m_ItemID >= 349 && m_ItemID <= 350)
- || (m_ItemID == 357)
- || (m_ItemID == 360)
- || (m_ItemID >= 363 && m_ItemID <= 366);
+ (m_ItemType == 260)
+ || (m_ItemType == 282)
+ || (m_ItemType == 297)
+ || (m_ItemType >= 319 && m_ItemType <= 320)
+ || (m_ItemType == 335)
+ || (m_ItemType >= 349 && m_ItemType <= 350)
+ || (m_ItemType == 357)
+ || (m_ItemType == 360)
+ || (m_ItemType >= 363 && m_ItemType <= 366);
}
@@ -325,7 +325,7 @@ bool cItemHandler::IsFood() bool cItemHandler::IsPlaceable()
{
- return m_ItemID >= 1 && m_ItemID <= 136;
+ return m_ItemType >= 1 && m_ItemType <= 136;
}
@@ -343,16 +343,16 @@ bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockType) BLOCKTYPE cItemHandler::GetBlockType()
{
- ASSERT(m_ItemID < 256); // Items with IDs above 255 should all be handled by specific handlers
+ ASSERT(m_ItemType < 256); // Items with IDs above 255 should all be handled by specific handlers
#ifdef _DEBUG
- if (m_ItemID > 256)
+ if (m_ItemType > 256)
{
- LOGERROR("Item %d has no valid block!", m_ItemID);
+ LOGERROR("Item %d has no valid block!", m_ItemType);
}
#endif // _DEBUG
- return (BLOCKTYPE) m_ItemID;
+ return (BLOCKTYPE) m_ItemType;
}
@@ -368,14 +368,14 @@ NIBBLETYPE cItemHandler::GetBlockMeta(short a_ItemDamage) -void cItemHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir)
+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_X, a_Y, a_Z, a_Dir);
+ 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_ItemID, 1);
+ cItem Item(a_Item->m_ItemType, 1);
a_Player->GetInventory().RemoveItem(Item);
}
}
|