From c171b272d96453f1a9d13d4623ac4bd3aa7d19e8 Mon Sep 17 00:00:00 2001 From: Lukas Pioch Date: Fri, 28 Jul 2017 12:11:07 +0200 Subject: Started on adding books --- src/Items/CMakeLists.txt | 1 + src/Items/ItemHandler.cpp | 2 ++ src/Items/ItemWrittenBook.h | 30 ++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/Items/ItemWrittenBook.h (limited to 'src/Items') 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; + } +} ; -- cgit v1.2.3