diff options
author | Alexander Harkness <me@bearbin.net> | 2020-04-04 17:13:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-04 17:13:41 +0200 |
commit | 2b9474f171a4c0e1863b52ea585f145ddaabe404 (patch) | |
tree | cadb7c58b7b6f7b10182740b3afe87c1ad7354f1 /src/Items/ItemFoodSeeds.h | |
parent | Potion changes (#4601) (diff) | |
download | cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.tar cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.tar.gz cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.tar.bz2 cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.tar.lz cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.tar.xz cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.tar.zst cuberite-2b9474f171a4c0e1863b52ea585f145ddaabe404.zip |
Diffstat (limited to 'src/Items/ItemFoodSeeds.h')
-rw-r--r-- | src/Items/ItemFoodSeeds.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/Items/ItemFoodSeeds.h b/src/Items/ItemFoodSeeds.h new file mode 100644 index 000000000..802397375 --- /dev/null +++ b/src/Items/ItemFoodSeeds.h @@ -0,0 +1,54 @@ + +#pragma once + +#include "ItemSeeds.h" +#include "../World.h" + + + + + +class cItemFoodSeedsHandler : + public cItemSeedsHandler +{ + typedef cItemSeedsHandler super; + +public: + cItemFoodSeedsHandler(int a_ItemType, FoodInfo a_FoodInfo) : + cItemSeedsHandler(a_ItemType), + m_FoodInfo(a_FoodInfo) + { + + } + + + virtual bool IsFood(void) override + { + return true; + } + + virtual FoodInfo GetFoodInfo(const cItem * a_Item) override + { + UNUSED(a_Item); + return m_FoodInfo; + } + + virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override + { + if (!super::EatItem(a_Player, a_Item)) + { + return false; + } + + if (!a_Player->IsGameModeCreative()) + { + a_Player->GetInventory().RemoveOneEquippedItem(); + } + + return true; + } + +protected: + FoodInfo m_FoodInfo; + +}; |