diff options
author | Franklin Kong <franklintigerkong@gmail.com> | 2020-06-26 22:34:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-26 22:34:22 +0200 |
commit | 868e28b44f1ad0b5bb2585e156407915803ab3e2 (patch) | |
tree | 00ab24eb4242072c8bada538b8904b6e3786d351 /src/Items | |
parent | Cactus cannot be placed on a forbidden blocks (#4767) (diff) | |
download | cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.tar cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.tar.gz cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.tar.bz2 cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.tar.lz cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.tar.xz cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.tar.zst cuberite-868e28b44f1ad0b5bb2585e156407915803ab3e2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Items/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/Items/ItemBrewingStand.h | 45 | ||||
-rw-r--r-- | src/Items/ItemCake.h | 45 | ||||
-rw-r--r-- | src/Items/ItemCauldron.h | 45 | ||||
-rw-r--r-- | src/Items/ItemFlowerPot.h | 51 | ||||
-rw-r--r-- | src/Items/ItemHandler.cpp | 19 | ||||
-rw-r--r-- | src/Items/ItemString.h | 51 | ||||
-rw-r--r-- | src/Items/ItemSugarcane.h | 51 | ||||
-rw-r--r-- | src/Items/SimplePlaceableItemHandler.h | 37 |
9 files changed, 45 insertions, 306 deletions
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt index e5f65fb3b..2ade4b9df 100644 --- a/src/Items/CMakeLists.txt +++ b/src/Items/CMakeLists.txt @@ -10,10 +10,7 @@ target_sources( ItemBoat.h ItemBottle.h ItemBow.h - ItemBrewingStand.h ItemBucket.h - ItemCake.h - ItemCauldron.h ItemChest.h ItemCloth.h ItemComparator.h @@ -22,7 +19,6 @@ target_sources( ItemDye.h ItemEmptyMap.h ItemFishingRod.h - ItemFlowerPot.h ItemFood.h ItemFoodSeeds.h ItemGoldenApple.h @@ -56,8 +52,7 @@ target_sources( ItemSoup.h ItemSpawnEgg.h ItemSpiderEye.h - ItemString.h - ItemSugarcane.h ItemSword.h ItemThrowable.h + SimplePlaceableItemHandler.h ) diff --git a/src/Items/ItemBrewingStand.h b/src/Items/ItemBrewingStand.h deleted file mode 100644 index fdf53ff8f..000000000 --- a/src/Items/ItemBrewingStand.h +++ /dev/null @@ -1,45 +0,0 @@ - -#pragma once - -#include "ItemHandler.h" - - - - - -class cItemBrewingStandHandler: - public cItemHandler -{ - using Super = cItemHandler; - -public: - - cItemBrewingStandHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - virtual bool IsPlaceable(void) override - { - return true; - } - - - virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = E_BLOCK_BREWING_STAND; - a_BlockMeta = 0; - return true; - } -} ; - - - - diff --git a/src/Items/ItemCake.h b/src/Items/ItemCake.h deleted file mode 100644 index 5751853f6..000000000 --- a/src/Items/ItemCake.h +++ /dev/null @@ -1,45 +0,0 @@ - -#pragma once - -#include "ItemHandler.h" - - - - - -class cItemCakeHandler: - public cItemHandler -{ - using Super = cItemHandler; - -public: - - cItemCakeHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - virtual bool IsPlaceable(void) override - { - return true; - } - - - virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = E_BLOCK_CAKE; - a_BlockMeta = 0; - return true; - } -} ; - - - - diff --git a/src/Items/ItemCauldron.h b/src/Items/ItemCauldron.h deleted file mode 100644 index 7f2ccdeac..000000000 --- a/src/Items/ItemCauldron.h +++ /dev/null @@ -1,45 +0,0 @@ - -#pragma once - -#include "ItemHandler.h" - - - - - -class cItemCauldronHandler: - public cItemHandler -{ - using Super = cItemHandler; - -public: - - cItemCauldronHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - virtual bool IsPlaceable(void) override - { - return true; - } - - - virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = E_BLOCK_CAULDRON; - a_BlockMeta = 0; - return true; - } -} ; - - - - diff --git a/src/Items/ItemFlowerPot.h b/src/Items/ItemFlowerPot.h deleted file mode 100644 index 655633785..000000000 --- a/src/Items/ItemFlowerPot.h +++ /dev/null @@ -1,51 +0,0 @@ - -#pragma once - -#include "ItemHandler.h" - - - - - -class cItemFlowerPotHandler: - public cItemHandler -{ - using Super = cItemHandler; - -public: - - cItemFlowerPotHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - - - - virtual bool IsPlaceable(void) override - { - return true; - } - - - - - - virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = E_BLOCK_FLOWER_POT; - a_BlockMeta = 0; - return true; - } -} ; - - - - diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index c014ba794..79a0dbcb9 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -15,10 +15,7 @@ #include "ItemBoat.h" #include "ItemBottle.h" #include "ItemBow.h" -#include "ItemBrewingStand.h" #include "ItemBucket.h" -#include "ItemCake.h" -#include "ItemCauldron.h" #include "ItemChest.h" #include "ItemCloth.h" #include "ItemComparator.h" @@ -28,7 +25,6 @@ #include "ItemEmptyMap.h" #include "ItemEyeOfEnder.h" #include "ItemFishingRod.h" -#include "ItemFlowerPot.h" #include "ItemFood.h" #include "ItemFoodSeeds.h" #include "ItemGoldenApple.h" @@ -61,12 +57,11 @@ #include "ItemSoup.h" #include "ItemSpawnEgg.h" #include "ItemSpiderEye.h" -#include "ItemString.h" -#include "ItemSugarcane.h" #include "ItemSword.h" #include "ItemThrowable.h" #include "../Blocks/BlockHandler.h" +#include "SimplePlaceableItemHandler.h" @@ -132,9 +127,9 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_BED: return new cItemBedHandler(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_CAKE: return new cItemCakeHandler(a_ItemType); - case E_ITEM_CAULDRON: return new cItemCauldronHandler(a_ItemType); + case E_ITEM_BREWING_STAND: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_BREWING_STAND); + case E_ITEM_CAKE: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_CAKE); + case E_ITEM_CAULDRON: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_CAULDRON); case E_ITEM_COMPARATOR: return new cItemComparatorHandler(a_ItemType); case E_ITEM_DYE: return new cItemDyeHandler(a_ItemType); case E_ITEM_EGG: return new cItemEggHandler(); @@ -145,7 +140,7 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_FIREWORK_ROCKET: return new cItemFireworkHandler(); case E_ITEM_FISHING_ROD: return new cItemFishingRodHandler(a_ItemType); case E_ITEM_FLINT_AND_STEEL: return new cItemLighterHandler(a_ItemType); - case E_ITEM_FLOWER_POT: return new cItemFlowerPotHandler(a_ItemType); + case E_ITEM_FLOWER_POT: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_FLOWER_POT); case E_ITEM_GLASS_BOTTLE: return new cItemBottleHandler(); case E_ITEM_MAP: return new cItemMapHandler(); case E_ITEM_MILK: return new cItemMilkHandler(); @@ -160,8 +155,8 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType) case E_ITEM_HEAD: return new cItemMobHeadHandler(a_ItemType); case E_ITEM_SNOWBALL: return new cItemSnowballHandler(); 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_STRING: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_TRIPWIRE); + case E_ITEM_SUGARCANE: return new cSimplePlaceableItemHandler(a_ItemType, E_BLOCK_SUGARCANE); case E_ITEM_WOODEN_HOE: case E_ITEM_STONE_HOE: diff --git a/src/Items/ItemString.h b/src/Items/ItemString.h deleted file mode 100644 index e7c9617d4..000000000 --- a/src/Items/ItemString.h +++ /dev/null @@ -1,51 +0,0 @@ - -#pragma once - -#include "ItemHandler.h" - - - - - -class cItemStringHandler: - public cItemHandler -{ - using Super = cItemHandler; - -public: - - cItemStringHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - - - - virtual bool IsPlaceable(void) override - { - return true; - } - - - - - - virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = E_BLOCK_TRIPWIRE; - a_BlockMeta = 0; - return true; - } -}; - - - - diff --git a/src/Items/ItemSugarcane.h b/src/Items/ItemSugarcane.h deleted file mode 100644 index b870f38f1..000000000 --- a/src/Items/ItemSugarcane.h +++ /dev/null @@ -1,51 +0,0 @@ - -#pragma once - -#include "ItemHandler.h" - - - - - -class cItemSugarcaneHandler: - public cItemHandler -{ - using Super = cItemHandler; - -public: - - cItemSugarcaneHandler(int a_ItemType): - Super(a_ItemType) - { - } - - - - - - virtual bool IsPlaceable(void) override - { - return true; - } - - - - - - virtual bool GetPlacementBlockTypeMeta( - cWorld * a_World, cPlayer * a_Player, - const Vector3i a_PlacedBlockPos, - eBlockFace a_ClickedBlockFace, - const Vector3i a_CursorPos, - BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta - ) override - { - a_BlockType = E_BLOCK_SUGARCANE; - a_BlockMeta = 0; - return true; - } -} ; - - - - diff --git a/src/Items/SimplePlaceableItemHandler.h b/src/Items/SimplePlaceableItemHandler.h new file mode 100644 index 000000000..3908bc1f3 --- /dev/null +++ b/src/Items/SimplePlaceableItemHandler.h @@ -0,0 +1,37 @@ +#pragma once + + +#include "ItemHandler.h" + +class cSimplePlaceableItemHandler : + public cItemHandler +{ + using Super = cItemHandler; + +public: + cSimplePlaceableItemHandler(int a_ItemType, BLOCKTYPE a_BlockType) : + Super(a_ItemType) + { + m_BlockType = a_BlockType; + } + + + virtual bool IsPlaceable(void) override + { + return true; + } + + + virtual bool GetPlacementBlockTypeMeta( + cWorld * a_World, cPlayer * a_Player, const Vector3i a_PlacedBlockPos, + eBlockFace a_ClickedBlockFace, const Vector3i a_CursorPos, + BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) override + { + a_BlockType = m_BlockType; + a_BlockMeta = 0; + return true; + } + +protected: + BLOCKTYPE m_BlockType; +}; |