diff options
author | Mattes D <github@xoft.cz> | 2013-11-19 10:13:49 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2013-11-19 10:13:49 +0100 |
commit | ced076c561058a31745e9d666ef4b5e5ca08af6e (patch) | |
tree | 503f09b57e176bb38ee08059b662aa454acede2a /source/Items | |
parent | Merge pull request #359 from mc-server/redstone (diff) | |
parent | General fixes [SEE DESC] (diff) | |
download | cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.tar cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.tar.gz cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.tar.bz2 cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.tar.lz cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.tar.xz cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.tar.zst cuberite-ced076c561058a31745e9d666ef4b5e5ca08af6e.zip |
Diffstat (limited to 'source/Items')
-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 |