summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Items/CMakeLists.txt1
-rw-r--r--src/Items/ItemHandler.cpp2
-rw-r--r--src/Items/ItemWrittenBook.h30
3 files changed, 33 insertions, 0 deletions
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 72858591a..5ab12feb2 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -56,6 +56,7 @@ SET (HDRS
ItemSword.h
ItemThrowable.h
ItemAxe.h
+ ItemWrittenBook.h
)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index e0c5bb56c..234c0dbf6 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -56,6 +56,7 @@
#include "ItemSword.h"
#include "ItemThrowable.h"
#include "ItemAxe.h"
+#include "ItemWrittenBook.h"
#include "../Blocks/BlockHandler.h"
@@ -153,6 +154,7 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_SPAWN_EGG: return new cItemSpawnEggHandler(a_ItemType);
case E_ITEM_STRING: return new cItemStringHandler(a_ItemType);
case E_ITEM_SUGARCANE: return new cItemSugarcaneHandler(a_ItemType);
+ case E_ITEM_WRITTEN_BOOK: return new cItemWrittenBookHandler(a_ItemType);
case E_ITEM_WOODEN_HOE:
case E_ITEM_STONE_HOE:
diff --git a/src/Items/ItemWrittenBook.h b/src/Items/ItemWrittenBook.h
new file mode 100644
index 000000000..37f1254c5
--- /dev/null
+++ b/src/Items/ItemWrittenBook.h
@@ -0,0 +1,30 @@
+
+// ItemWrittenBook.h
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "../Entities/Player.h"
+#include "../Inventory.h"
+
+
+
+class cItemWrittenBookHandler :
+ public cItemHandler
+{
+public:
+ cItemWrittenBookHandler(int a_ItemType)
+ : cItemHandler(a_ItemType)
+ {
+ }
+
+ virtual bool OnItemUse(
+ cWorld * a_World, cPlayer * a_Player, cBlockPluginInterface & a_PluginInterface, const cItem & a_Item,
+ int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace
+ ) override
+ {
+ // TODO: Currently only main haind. If second hand is implemented, fix this
+ a_Player->GetClientHandle()->SendOpenBook(0);
+ return true;
+ }
+} ;