diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-11-16 21:58:17 +0100 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2013-11-16 21:58:17 +0100 |
commit | 6ff6929ca6c599418f98fe750c04a76774075c18 (patch) | |
tree | 8587e70a6f698240c4c2c3e693d4d77128b8477c /source/Items | |
parent | Switchified If, ElseIf statement (diff) | |
download | cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.tar cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.tar.gz cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.tar.bz2 cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.tar.lz cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.tar.xz cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.tar.zst cuberite-6ff6929ca6c599418f98fe750c04a76774075c18.zip |
Diffstat (limited to '')
-rw-r--r-- | source/Items/ItemHandler.cpp | 2 | ||||
-rw-r--r-- | source/Items/ItemThrowable.h | 44 |
2 files changed, 46 insertions, 0 deletions
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp index 13f5293b9..92ba94999 100644 --- a/source/Items/ItemHandler.cpp +++ b/source/Items/ItemHandler.cpp @@ -90,6 +90,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_BLOCK_WOOL: return new cItemClothHandler(a_ItemType); case E_ITEM_BED: return new cItemBedHandler(a_ItemType); case E_ITEM_BOAT: return new cItemBoatHandler(a_ItemType); + case E_ITEM_BOTTLE_O_ENCHANTING: return new cItemBottleOEnchantingHandler(); case E_ITEM_BOW: return new cItemBowHandler; case E_ITEM_BREWING_STAND: return new cItemBrewingStandHandler(a_ItemType); case E_ITEM_CAULDRON: return new cItemCauldronHandler(a_ItemType); @@ -97,6 +98,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType); case E_ITEM_EGG: return new cItemEggHandler(); case E_ITEM_ENDER_PEARL: return new cItemEnderPearlHandler(); + case E_ITEM_FIREWORK_ROCKET: return new cItemFireworkHandler(); case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType); case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType); case E_ITEM_REDSTONE_DUST: return new cItemRedstoneDustHandler(a_ItemType); diff --git a/source/Items/ItemThrowable.h b/source/Items/ItemThrowable.h index 85579daf2..fc24e775a 100644 --- a/source/Items/ItemThrowable.h +++ b/source/Items/ItemThrowable.h @@ -94,3 +94,47 @@ public: + +class cItemBottleOEnchantingHandler : + public cItemThrowableHandler +{ + typedef cItemThrowableHandler super; +public: + cItemBottleOEnchantingHandler(void) : + super(E_ITEM_BOTTLE_O_ENCHANTING, cProjectileEntity::pkExpBottle, 10) + { + } +}; + + + + + +class cItemFireworkHandler : + public cItemThrowableHandler +{ + typedef cItemThrowableHandler super; +public: + cItemFireworkHandler(void) : + super(E_ITEM_FIREWORK_ROCKET, cProjectileEntity::pkFirework, 0) + { + } + + virtual bool OnItemUse(cWorld * a_World, cPlayer * a_Player, const cItem & a_Item, int a_BlockX, int a_BlockY, int a_BlockZ, char a_Dir) override + { + if (a_World->GetBlock(a_BlockX, a_BlockY, a_BlockZ) == E_BLOCK_AIR) + { + return false; + } + + if (!a_Player->IsGameModeCreative()) + { + a_Player->GetInventory().RemoveOneEquippedItem(); + } + + a_World->CreateProjectile(a_BlockX + 0.5, a_BlockY + 1, a_BlockZ + 0.5, m_ProjectileKind, a_Player, 0); + + return true; + } + +};
\ No newline at end of file |