summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-18 23:21:05 +0100
committerMattes D <github@xoft.cz>2014-02-18 23:21:05 +0100
commit1d9b02c95686d0fd90431b5c78999eaf96b5991c (patch)
tree112663e0d7be31401232bd6e3f4f10852776639e /src/Items
parentMerge pull request #696 from mc-server/paintings (diff)
parentMerge branch 'master' into itemframes (diff)
downloadcuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.tar
cuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.tar.gz
cuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.tar.bz2
cuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.tar.lz
cuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.tar.xz
cuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.tar.zst
cuberite-1d9b02c95686d0fd90431b5c78999eaf96b5991c.zip
Diffstat (limited to 'src/Items')
-rw-r--r--src/Items/ItemHandler.cpp3
-rw-r--r--src/Items/ItemItemFrame.h53
2 files changed, 56 insertions, 0 deletions
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 5ff74fc2c..945f84b9c 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -21,6 +21,7 @@
#include "ItemFishingRod.h"
#include "ItemFlowerPot.h"
#include "ItemFood.h"
+#include "ItemItemFrame.h"
#include "ItemHoe.h"
#include "ItemLeaves.h"
#include "ItemLighter.h"
@@ -106,6 +107,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_FISHING_ROD: return new cItemFishingRodHandler(a_ItemType);
case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType);
case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType);
+ case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType);
case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType);
case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType);
@@ -344,6 +346,7 @@ char cItemHandler::GetMaxStackSize(void)
case E_ITEM_GUNPOWDER: return 64;
case E_ITEM_HEAD: return 64;
case E_ITEM_IRON: return 64;
+ case E_ITEM_ITEM_FRAME: return 64;
case E_ITEM_LEATHER: return 64;
case E_ITEM_MAGMA_CREAM: return 64;
case E_ITEM_MAP: return 64;
diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h
new file mode 100644
index 000000000..74e987445
--- /dev/null
+++ b/src/Items/ItemItemFrame.h
@@ -0,0 +1,53 @@
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "Entities/ItemFrame.h"
+#include "../Entities/Player.h"
+
+
+
+
+
+class cItemItemFrameHandler :
+ public cItemHandler
+{
+public:
+ cItemItemFrameHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+
+ }
+
+ virtual bool OnItemUse(cWorld *a_World, cPlayer *a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_Dir) override
+ {
+ if ((a_Dir == BLOCK_FACE_NONE) || (a_Dir == BLOCK_FACE_YP) || (a_Dir == BLOCK_FACE_YM))
+ {
+ // Client sends this if clicked on top or bottom face
+ return false;
+ }
+
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir); // Make sure block that will be occupied is free
+ BLOCKTYPE Block = a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
+ AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_Dir, true); // We want the clicked block, so go back again
+
+ if (Block == E_BLOCK_AIR)
+ {
+ cItemFrame * ItemFrame = new cItemFrame(a_Dir, a_BlockX, a_BlockY, a_BlockZ);
+ ItemFrame->Initialize(a_World);
+
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+
+ return true;
+
+ }
+ return false;
+ }
+};
+
+
+
+