summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-29 14:07:22 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-07-29 14:07:22 +0200
commit9dc0e3c2335fa6aacd0974b161bd96772639bf52 (patch)
tree28381c0f45393be618e31c8475a049520128cb71
parentFixed warnings in md5 (diff)
downloadcuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.tar
cuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.tar.gz
cuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.tar.bz2
cuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.tar.lz
cuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.tar.xz
cuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.tar.zst
cuberite-9dc0e3c2335fa6aacd0974b161bd96772639bf52.zip
-rw-r--r--source/Bindings.cpp5
-rw-r--r--source/Bindings.h2
-rw-r--r--source/BlockID.h3
-rw-r--r--source/items/Item.cpp274
-rw-r--r--source/items/Item.h2
-rw-r--r--source/items/ItemCloth.h17
-rw-r--r--source/items/ItemLeaves.h18
-rw-r--r--source/items/ItemRedstoneDust.h12
-rw-r--r--source/items/ItemRedstoneRepeater.h12
-rw-r--r--source/items/ItemSapling.h16
-rw-r--r--source/items/ItemSeeds.h28
-rw-r--r--source/items/ItemSlab.h27
-rw-r--r--source/items/ItemSugarcane.h16
-rw-r--r--source/items/ItemWood.h17
14 files changed, 307 insertions, 142 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index 9f780d6aa..d31298c56 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/15/12 22:27:57.
+** Generated automatically by tolua++-1.0.92 on 07/29/12 13:49:55.
*/
#ifndef __cplusplus
@@ -2572,7 +2572,7 @@ static int tolua_AllToLua_BlockStringToType00(lua_State* tolua_S)
{
const AString a_BlockTypeString = ((const AString) tolua_tocppstring(tolua_S,1,0));
{
- int tolua_ret = (int) BlockStringToType(a_BlockTypeString);
+ char tolua_ret = ( char) BlockStringToType(a_BlockTypeString);
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
tolua_pushcppstring(tolua_S,(const char*)a_BlockTypeString);
}
@@ -21384,6 +21384,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"E_ITEM_DEAD_BRUSH",E_ITEM_DEAD_BRUSH);
tolua_constant(tolua_S,"E_ITEM_PISTON",E_ITEM_PISTON);
tolua_constant(tolua_S,"E_ITEM_PISTON_EXTENSION",E_ITEM_PISTON_EXTENSION);
+ tolua_constant(tolua_S,"E_ITEM_WOOL",E_ITEM_WOOL);
tolua_constant(tolua_S,"E_ITEM_WHITE_CLOTH",E_ITEM_WHITE_CLOTH);
tolua_constant(tolua_S,"E_ITEM_PISTON_MOVED_BLOCK",E_ITEM_PISTON_MOVED_BLOCK);
tolua_constant(tolua_S,"E_ITEM_YELLOW_FLOWER",E_ITEM_YELLOW_FLOWER);
diff --git a/source/Bindings.h b/source/Bindings.h
index 781e10357..fceb9d948 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 07/15/12 22:27:58.
+** Generated automatically by tolua++-1.0.92 on 07/29/12 13:49:56.
*/
/* Exported function */
diff --git a/source/BlockID.h b/source/BlockID.h
index 4f3a3d3ed..fafbfb69c 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -193,7 +193,8 @@ enum ENUM_ITEM_ID
E_ITEM_DEAD_BRUSH = 32,
E_ITEM_PISTON = 33,
E_ITEM_PISTON_EXTENSION = 34,
- E_ITEM_WHITE_CLOTH = 35,
+ E_ITEM_WOOL = 35,
+ E_ITEM_WHITE_CLOTH = 35, /// OBSOLETE, use E_ITEM_WOOL
E_ITEM_PISTON_MOVED_BLOCK = 36,
E_ITEM_YELLOW_FLOWER = 37,
E_ITEM_RED_ROSE = 38,
diff --git a/source/items/Item.cpp b/source/items/Item.cpp
index 2596548d6..35a612434 100644
--- a/source/items/Item.cpp
+++ b/source/items/Item.cpp
@@ -1,3 +1,4 @@
+
#include "Globals.h"
#include "Item.h"
#include "../cItem.h"
@@ -27,8 +28,16 @@
#include "../blocks/Block.h"
+
+
+
+
bool cItemHandler::m_HandlerInitialized = false;
-cItemHandler *cItemHandler::m_ItemHandler[2266];
+cItemHandler * cItemHandler::m_ItemHandler[2266];
+
+
+
+
cItemHandler *cItemHandler::GetItemHandler(int a_ItemID)
{
@@ -45,94 +54,121 @@ cItemHandler *cItemHandler::GetItemHandler(int a_ItemID)
return m_ItemHandler[a_ItemID];
}
+
+
+
+
cItemHandler *cItemHandler::CreateItemHandler(int a_ItemID)
{
switch(a_ItemID)
{
- case E_ITEM_WOODEN_HOE:
- case E_ITEM_STONE_HOE:
- case E_ITEM_IRON_HOE:
- case E_ITEM_GOLD_HOE:
- case E_ITEM_DIAMOND_HOE:
- return new cItemHoeHandler(a_ItemID);
- case E_ITEM_WHITE_CLOTH:
- return new cItemClothHandler(a_ItemID);
- case E_ITEM_STONE_SLAB:
- case E_ITEM_WOODEN_SLAB:
- return new cItemSlabHandler(a_ItemID);
- case E_ITEM_LOG:
- case E_ITEM_WOOD:
- return new cItemWoodHandler(a_ItemID);
- case E_ITEM_SHEARS:
- return new cItemShearsHandler(a_ItemID);
- case E_ITEM_LEAVES:
- return new cItemLeavesHandler(a_ItemID);
- case E_ITEM_SAPLING:
- return new cItemSaplingHandler(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_BUCKET:
- case E_ITEM_WATER_BUCKET:
- case E_ITEM_LAVA_BUCKET:
- return new cItemBucketHandler(a_ItemID);
- case E_ITEM_FLINT_AND_STEEL:
- return new cItemLighterHandler(a_ItemID);
- case E_ITEM_PUMPKIN_SEEDS:
- case E_ITEM_MELON_SEEDS:
- case E_ITEM_SEEDS:
- return new cItemSeedsHandler(a_ItemID);
- case E_ITEM_DYE:
- return new cItemDyeHandler(a_ItemID);
- case E_ITEM_SUGARCANE:
- return new cItemSugarcaneHandler(a_ItemID);
- case E_ITEM_WOODEN_PICKAXE:
- case E_ITEM_STONE_PICKAXE:
- case E_ITEM_IRON_PICKAXE:
- case E_ITEM_GOLD_PICKAXE:
- case E_ITEM_DIAMOND_PICKAXE:
- return new cItemPickaxeHandler(a_ItemID);
- case E_ITEM_WOODEN_SHOVEL:
- case E_ITEM_STONE_SHOVEL:
- case E_ITEM_IRON_SHOVEL:
- case E_ITEM_GOLD_SHOVEL:
- case E_ITEM_DIAMOND_SHOVEL:
- return new cItemShovelHandler(a_ItemID);
- case E_ITEM_WOODEN_SWORD:
- case E_ITEM_STONE_SWORD:
- case E_ITEM_IRON_SWORD:
- case E_ITEM_GOLD_SWORD:
- case E_ITEM_DIAMOND_SWORD:
- return new cItemSwordHandler(a_ItemID);
-
- case E_ITEM_IRON_DOOR:
- case E_ITEM_WOODEN_DOOR:
- return new cItemDoorHandler(a_ItemID);
-
- //FOOD:
- case E_ITEM_BREAD:
- case E_ITEM_COOKIE:
- case E_ITEM_MELON_SLICE:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_RAW_BEEF:
- case E_ITEM_RAW_MEAT:
- case E_ITEM_STEAK:
- case E_ITEM_COOKED_MEAT:
- case E_ITEM_RAW_FISH:
- case E_ITEM_COOKED_FISH:
- case E_ITEM_RED_APPLE:
- case E_ITEM_GOLDEN_APPLE:
- case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_SPIDER_EYE:
- return new cItemFoodHandler(a_ItemID);
- default:
- return new cItemHandler(a_ItemID);
- break;
+ default: return new cItemHandler(a_ItemID);
+
+ // Single item per handler:
+ case E_ITEM_SHEARS: return new cItemShearsHandler(a_ItemID);
+ case E_ITEM_LEAVES: return new cItemLeavesHandler(a_ItemID);
+ case E_ITEM_SAPLING: return new cItemSaplingHandler(a_ItemID);
+ case E_ITEM_DYE: return new cItemDyeHandler(a_ItemID);
+ case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemID);
+ case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(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_WOOL: return new cItemClothHandler(a_ItemID);
+
+ case E_ITEM_WOODEN_HOE:
+ case E_ITEM_STONE_HOE:
+ case E_ITEM_IRON_HOE:
+ case E_ITEM_GOLD_HOE:
+ case E_ITEM_DIAMOND_HOE:
+ {
+ return new cItemHoeHandler(a_ItemID);
+ }
+
+ case E_ITEM_WOODEN_PICKAXE:
+ case E_ITEM_STONE_PICKAXE:
+ case E_ITEM_IRON_PICKAXE:
+ case E_ITEM_GOLD_PICKAXE:
+ case E_ITEM_DIAMOND_PICKAXE:
+ {
+ return new cItemPickaxeHandler(a_ItemID);
+ }
+
+ case E_ITEM_WOODEN_SHOVEL:
+ case E_ITEM_STONE_SHOVEL:
+ case E_ITEM_IRON_SHOVEL:
+ case E_ITEM_GOLD_SHOVEL:
+ case E_ITEM_DIAMOND_SHOVEL:
+ {
+ return new cItemShovelHandler(a_ItemID);
+ }
+
+ case E_ITEM_WOODEN_SWORD:
+ case E_ITEM_STONE_SWORD:
+ case E_ITEM_IRON_SWORD:
+ case E_ITEM_GOLD_SWORD:
+ case E_ITEM_DIAMOND_SWORD:
+ {
+ return new cItemSwordHandler(a_ItemID);
+ }
+
+ case E_ITEM_STONE_SLAB:
+ case E_ITEM_WOODEN_SLAB:
+ {
+ return new cItemSlabHandler(a_ItemID);
+ }
+
+ case E_ITEM_LOG:
+ case E_ITEM_PLANKS:
+ {
+ return new cItemWoodHandler(a_ItemID);
+ }
+
+ case E_ITEM_BUCKET:
+ case E_ITEM_WATER_BUCKET:
+ case E_ITEM_LAVA_BUCKET:
+ {
+ return new cItemBucketHandler(a_ItemID);
+ }
+
+ case E_ITEM_PUMPKIN_SEEDS:
+ case E_ITEM_MELON_SEEDS:
+ case E_ITEM_SEEDS:
+ {
+ return new cItemSeedsHandler(a_ItemID);
+ }
+
+ case E_ITEM_IRON_DOOR:
+ case E_ITEM_WOODEN_DOOR:
+ {
+ return new cItemDoorHandler(a_ItemID);
+ }
+
+ // Food:
+ case E_ITEM_BREAD:
+ case E_ITEM_COOKIE:
+ case E_ITEM_MELON_SLICE:
+ case E_ITEM_RAW_CHICKEN:
+ case E_ITEM_COOKED_CHICKEN:
+ case E_ITEM_RAW_BEEF:
+ case E_ITEM_RAW_MEAT:
+ case E_ITEM_STEAK:
+ case E_ITEM_COOKED_MEAT:
+ case E_ITEM_RAW_FISH:
+ case E_ITEM_COOKED_FISH:
+ case E_ITEM_RED_APPLE:
+ case E_ITEM_GOLDEN_APPLE:
+ case E_ITEM_ROTTEN_FLESH:
+ case E_ITEM_SPIDER_EYE:
+ {
+ return new cItemFoodHandler(a_ItemID);
+ }
}
}
+
+
+
+
void cItemHandler::Deinit()
{
for(int i = 0; i < 2266; i++)
@@ -141,21 +177,37 @@ void cItemHandler::Deinit()
}
}
+
+
+
+
cItemHandler::cItemHandler(int a_ItemID)
{
m_ItemID = a_ItemID;
}
+
+
+
+
bool cItemHandler::OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir)
{
return false;
}
+
+
+
+
bool cItemHandler::OnDiggingBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir)
{
return false;
}
+
+
+
+
void cItemHandler::OnBlockDestroyed(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z)
{
char Block = a_World->GetBlock(a_X, a_Y, a_Z);
@@ -172,11 +224,19 @@ void cItemHandler::OnBlockDestroyed(cWorld *a_World, cPlayer *a_Player, cItem *a
a_Player->UseEquippedItem();
}
+
+
+
+
void cItemHandler::OnFoodEaten(cWorld *a_World, cPlayer *a_Player, cItem *a_Item)
{
}
+
+
+
+
bool cItemHandler::IsTool()
{
return
@@ -190,6 +250,10 @@ bool cItemHandler::IsTool()
|| (m_ItemID == 346);
}
+
+
+
+
bool cItemHandler::IsFood()
{
return
@@ -204,33 +268,55 @@ bool cItemHandler::IsFood()
|| (m_ItemID >= 363 && m_ItemID <= 366);
}
+
+
+
+
bool cItemHandler::IsPlaceable()
{
return m_ItemID >= 1 && m_ItemID <= 136;
}
+
+
+
bool cItemHandler::CanHarvestBlock(BLOCKTYPE a_BlockID)
{
return false;
}
+
+
+
+
BLOCKTYPE cItemHandler::GetBlockType()
{
-#ifdef _DEBUG
- if(m_ItemID > 256)
+ ASSERT(m_ItemID < 256); // Items with IDs above 255 should all be handled by specific handlers
+
+ #ifdef _DEBUG
+ if (m_ItemID > 256)
{
LOGERROR("Item %d has no valid block!", m_ItemID);
}
-#endif
+ #endif // _DEBUG
+
return (BLOCKTYPE) m_ItemID;
}
-NIBBLETYPE cItemHandler::GetBlockMeta(NIBBLETYPE a_ItemMeta)
+
+
+
+
+NIBBLETYPE cItemHandler::GetBlockMeta(short a_ItemDamage)
{
- return a_ItemMeta; //This keeps most textures. The few other items have to override this
+ 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_X, int a_Y, int a_Z, char a_Dir)
{
BLOCKTYPE Block = GetBlockType();
@@ -243,6 +329,10 @@ void cItemHandler::PlaceBlock(cWorld *a_World, cPlayer *a_Player, cItem *a_Item,
}
}
+
+
+
+
bool cItemHandler::EatItem(cPlayer *a_Player, cItem *a_Item)
{
FoodInfo Info = GetFoodInfo();
@@ -265,7 +355,15 @@ bool cItemHandler::EatItem(cPlayer *a_Player, cItem *a_Item)
return false;
}
+
+
+
+
cItemHandler::FoodInfo cItemHandler::GetFoodInfo()
{
return FoodInfo(0, 0.f);
-} \ No newline at end of file
+}
+
+
+
+
diff --git a/source/items/Item.h b/source/items/Item.h
index 0a38ce3c0..a465ae80a 100644
--- a/source/items/Item.h
+++ b/source/items/Item.h
@@ -39,7 +39,7 @@ public:
virtual bool IsPlaceable();
virtual BLOCKTYPE GetBlockType();
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta);
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage);
virtual bool CanHarvestBlock(BLOCKTYPE a_BlockID);
diff --git a/source/items/ItemCloth.h b/source/items/ItemCloth.h
index ead4ee84a..d67e14864 100644
--- a/source/items/ItemCloth.h
+++ b/source/items/ItemCloth.h
@@ -1,9 +1,14 @@
+
#pragma once
#include "Item.h"
-class cItemClothHandler : public cItemHandler
+
+
+
+class cItemClothHandler :
+ public cItemHandler
{
public:
cItemClothHandler(int a_ItemID)
@@ -11,8 +16,8 @@ public:
{
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
- {
- return a_ItemMeta;
- }
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemLeaves.h b/source/items/ItemLeaves.h
index bc1519806..01b090a2f 100644
--- a/source/items/ItemLeaves.h
+++ b/source/items/ItemLeaves.h
@@ -1,17 +1,27 @@
+
#pragma once
#include "Item.h"
-class cItemLeavesHandler : public cItemHandler
+
+
+
+class cItemLeavesHandler :
+ public cItemHandler
{
public:
cItemLeavesHandler(int a_ItemID)
: cItemHandler(a_ItemID)
{
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
+
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage) override
{
- return a_ItemMeta | 0x4; //0x4 bit set means this is a player places leave
+ return (NIBBLETYPE)(a_ItemDamage & 0x0f) | 0x4; //0x4 bit set means this is a player-placed leaves block, not to be decayed
}
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemRedstoneDust.h b/source/items/ItemRedstoneDust.h
index a0aee1e5e..4d1459bc6 100644
--- a/source/items/ItemRedstoneDust.h
+++ b/source/items/ItemRedstoneDust.h
@@ -1,7 +1,11 @@
+
#pragma once
#include "Item.h"
+
+
+
class cItemRedstoneDustHandler : public cItemHandler
{
public:
@@ -20,8 +24,12 @@ public:
return E_BLOCK_REDSTONE_WIRE;
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage) override
{
return 0;
}
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemRedstoneRepeater.h b/source/items/ItemRedstoneRepeater.h
index 8dd309a91..85500c9f4 100644
--- a/source/items/ItemRedstoneRepeater.h
+++ b/source/items/ItemRedstoneRepeater.h
@@ -1,7 +1,11 @@
+
#pragma once
#include "Item.h"
+
+
+
class cItemRedstoneRepeaterHandler : public cItemHandler
{
public:
@@ -20,8 +24,12 @@ public:
return ::E_BLOCK_REDSTONE_REPEATER_OFF;
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemMeta) override
{
return 0;
}
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemSapling.h b/source/items/ItemSapling.h
index 23894b812..7edbc76c9 100644
--- a/source/items/ItemSapling.h
+++ b/source/items/ItemSapling.h
@@ -1,8 +1,12 @@
+
#pragma once
#include "Item.h"
+
+
+
class cItemSaplingHandler : public cItemHandler
{
public:
@@ -12,9 +16,13 @@ public:
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage) override
{
- //Only the first 2 bits are important
- return a_ItemMeta & 3;
+ // Only the lowest 3 bits are important
+ return (NIBBLETYPE)(a_ItemDamage & 0x07);
}
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemSeeds.h b/source/items/ItemSeeds.h
index 1d7f93613..07cf0e5de 100644
--- a/source/items/ItemSeeds.h
+++ b/source/items/ItemSeeds.h
@@ -1,9 +1,15 @@
+
#pragma once
#include "Item.h"
#include "../cWorld.h"
-class cItemSeedsHandler : public cItemHandler
+
+
+
+
+class cItemSeedsHandler :
+ public cItemHandler
{
public:
cItemSeedsHandler(int a_ItemID)
@@ -21,18 +27,14 @@ public:
{
switch(m_ItemID)
{
- case E_ITEM_SEEDS:
- return E_BLOCK_CROPS;
- case E_ITEM_MELON_SEEDS:
- E_BLOCK_MELON_STEM;
- case E_ITEM_PUMPKIN_SEEDS:
- E_BLOCK_PUMPKIN_STEM;
- default:
- return E_BLOCK_AIR;
+ case E_ITEM_SEEDS: return E_BLOCK_CROPS;
+ case E_ITEM_MELON_SEEDS: return E_BLOCK_MELON_STEM;
+ case E_ITEM_PUMPKIN_SEEDS: return E_BLOCK_PUMPKIN_STEM;
+ default: return E_BLOCK_AIR;
}
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage) override
{
return 0; //Not grown yet
}
@@ -50,4 +52,8 @@ public:
return cItemHandler::PlaceBlock(a_World, a_Player, a_Item, a_X, a_Y, a_Z, a_Dir);
}
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemSlab.h b/source/items/ItemSlab.h
index 9b91530c9..955d3acfc 100644
--- a/source/items/ItemSlab.h
+++ b/source/items/ItemSlab.h
@@ -1,8 +1,13 @@
+
#pragma once
#include "Item.h"
#include "../cWorld.h"
+
+
+
+
class cItemSlabHandler : public cItemHandler
{
public:
@@ -12,19 +17,20 @@ public:
}
- virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, cItem *a_Item, int a_X, int a_Y, int a_Z, char a_Dir) override
+ virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, cItem * a_Item, int a_X, int a_Y, int a_Z, char a_Dir) override
{
BLOCKTYPE Block;
NIBBLETYPE Meta;
a_World->GetBlockTypeMeta(a_X, a_Y, a_Z, Block, Meta);
- 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_ItemID) //Same slab
- && ((Meta & 0x7) == (a_Item->m_ItemHealth & 0x7))) //Same Texture
+ 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_ItemID) // Same slab
+ && ((Meta & 0x7) == (a_Item->m_ItemHealth & 0x7))) // Same Texture
{
cItem Item(a_Item->m_ItemID, 1);
- if(a_Player->GetInventory().RemoveItem(Item))
+ 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;
@@ -32,9 +38,8 @@ public:
}
return false;
}
+} ;
+
+
+
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
- {
- return a_ItemMeta;
- }
-}; \ No newline at end of file
diff --git a/source/items/ItemSugarcane.h b/source/items/ItemSugarcane.h
index 778a20dbf..74557479e 100644
--- a/source/items/ItemSugarcane.h
+++ b/source/items/ItemSugarcane.h
@@ -1,9 +1,15 @@
+
#pragma once
#include "Item.h"
#include "../cWorld.h"
-class cItemSugarcaneHandler : public cItemHandler
+
+
+
+
+class cItemSugarcaneHandler :
+ public cItemHandler
{
public:
cItemSugarcaneHandler(int a_ItemID)
@@ -22,8 +28,12 @@ public:
return E_BLOCK_SUGARCANE;
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
+ virtual NIBBLETYPE GetBlockMeta(short a_ItemDamage) override
{
return 0; //Not grown yet
}
-}; \ No newline at end of file
+} ;
+
+
+
+
diff --git a/source/items/ItemWood.h b/source/items/ItemWood.h
index 13aba198d..7e874efc2 100644
--- a/source/items/ItemWood.h
+++ b/source/items/ItemWood.h
@@ -1,17 +1,22 @@
+
#pragma once
#include "Item.h"
-class cItemWoodHandler : public cItemHandler
+
+
+
+class cItemWoodHandler :
+ public cItemHandler
{
public:
cItemWoodHandler(int a_ItemID)
: cItemHandler(a_ItemID)
{
}
- virtual NIBBLETYPE GetBlockMeta(NIBBLETYPE a_ItemMeta) override
- {
- return a_ItemMeta;
- }
-}; \ No newline at end of file
+} ;
+
+
+
+