summaryrefslogtreecommitdiffstats
path: root/src/Items
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Items/ItemEyeOfEnder.h59
-rw-r--r--src/Items/ItemHandler.cpp2
-rw-r--r--src/Items/ItemThrowable.h2
3 files changed, 62 insertions, 1 deletions
diff --git a/src/Items/ItemEyeOfEnder.h b/src/Items/ItemEyeOfEnder.h
new file mode 100644
index 000000000..f911955a1
--- /dev/null
+++ b/src/Items/ItemEyeOfEnder.h
@@ -0,0 +1,59 @@
+
+#pragma once
+
+#include "ItemHandler.h"
+#include "ItemThrowable.h"
+
+
+
+
+
+class cItemEyeOfEnderHandler :
+ public cItemThrowableHandler
+{
+ typedef cItemThrowableHandler super;
+public:
+ cItemEyeOfEnderHandler(void) :
+ super(E_ITEM_EYE_OF_ENDER, cProjectileEntity::pkSnowball, 30)
+ {
+ }
+
+ 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
+ {
+ BLOCKTYPE FacingBlock;
+ NIBBLETYPE FacingMeta;
+ a_World->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, FacingBlock, FacingMeta);
+ switch (FacingBlock)
+ {
+ case E_BLOCK_END_PORTAL_FRAME:
+ {
+ // Fill the portal frame. E_META_END_PORTAL_EYE is the bit for holding the eye of ender.
+ if ((FacingMeta & E_META_END_PORTAL_FRAME_EYE) != E_META_END_PORTAL_FRAME_EYE)
+ {
+ a_World->SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_END_PORTAL_FRAME, FacingMeta | E_META_END_PORTAL_FRAME_EYE);
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
+ }
+ break;
+ }
+ default:
+ {
+ // TODO: Create projectile for Eye Of Ender
+ // return cItemThrowableHandler::OnItemUse(a_World, a_Player, a_PluginInterface, a_Item, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
+ }
+ }
+
+ return false;
+ }
+
+} ;
+
+
+
+
+
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index 812003cbb..489ef4f28 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -24,6 +24,7 @@
#include "ItemDoor.h"
#include "ItemDye.h"
#include "ItemEmptyMap.h"
+#include "ItemEyeOfEnder.h"
#include "ItemFishingRod.h"
#include "ItemFlowerPot.h"
#include "ItemFood.h"
@@ -131,6 +132,7 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_EGG: return new cItemEggHandler();
case E_ITEM_EMPTY_MAP: return new cItemEmptyMapHandler();
case E_ITEM_ENDER_PEARL: return new cItemEnderPearlHandler();
+ case E_ITEM_EYE_OF_ENDER: return new cItemEyeOfEnderHandler();
case E_ITEM_FIRE_CHARGE: return new cItemLighterHandler(a_ItemType);
case E_ITEM_FIREWORK_ROCKET: return new cItemFireworkHandler();
case E_ITEM_FISHING_ROD: return new cItemFishingRodHandler(a_ItemType);
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index 85234088f..706143896 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -1,5 +1,5 @@
-// Declares the itemhandlers for throwable items: eggs, snowballs and ender pearls
+// Declares the itemhandlers for throwable items: eggs, snowballs, ender pearls, and eyes of ender.
#pragma once