summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Items/CMakeLists.txt10
-rw-r--r--src/Items/ItemAxe.h1
-rw-r--r--src/Items/ItemCookedFish.h37
-rw-r--r--src/Items/ItemFood.h131
-rw-r--r--src/Items/ItemFoodSeeds.h54
-rw-r--r--src/Items/ItemGoldenApple.h17
-rw-r--r--src/Items/ItemHandler.cpp79
-rw-r--r--src/Items/ItemMilk.h3
-rw-r--r--src/Items/ItemPoisonousPotato.h36
-rw-r--r--src/Items/ItemRawChicken.h36
-rw-r--r--src/Items/ItemRawFish.h57
-rw-r--r--src/Items/ItemRottenFlesh.h36
-rw-r--r--src/Items/ItemSeeds.h21
-rw-r--r--src/Items/ItemSoup.h39
-rw-r--r--src/Items/ItemSpiderEye.h33
15 files changed, 398 insertions, 192 deletions
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 92d12b3b3..6620f9c6b 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -5,6 +5,7 @@ SET (SRCS
SET (HDRS
ItemArmor.h
+ ItemAxe.h
ItemBed.h
ItemBigFlower.h
ItemBoat.h
@@ -17,12 +18,14 @@ SET (HDRS
ItemChest.h
ItemCloth.h
ItemComparator.h
+ ItemCookedFish.h
ItemDoor.h
ItemDye.h
ItemEmptyMap.h
ItemFishingRod.h
ItemFlowerPot.h
ItemFood.h
+ ItemFoodSeeds.h
ItemGoldenApple.h
ItemHandler.h
ItemHoe.h
@@ -37,22 +40,27 @@ SET (HDRS
ItemNetherWart.h
ItemPainting.h
ItemPickaxe.h
+ ItemPoisonousPotato.h
ItemPotion.h
ItemPumpkin.h
+ ItemRawChicken.h
+ ItemRawFish.h
ItemRedstoneDust.h
ItemRedstoneRepeater.h
+ ItemRottenFlesh.h
ItemSapling.h
ItemSeeds.h
ItemShears.h
ItemShovel.h
ItemSign.h
ItemSlab.h
+ ItemSoup.h
ItemSpawnEgg.h
+ ItemSpiderEye.h
ItemString.h
ItemSugarcane.h
ItemSword.h
ItemThrowable.h
- ItemAxe.h
)
if(NOT MSVC)
diff --git a/src/Items/ItemAxe.h b/src/Items/ItemAxe.h
index 1dfd2aeca..3b981ef7c 100644
--- a/src/Items/ItemAxe.h
+++ b/src/Items/ItemAxe.h
@@ -2,6 +2,7 @@
#pragma once
#include "ItemHandler.h"
+#include "../BlockInfo.h"
diff --git a/src/Items/ItemCookedFish.h b/src/Items/ItemCookedFish.h
new file mode 100644
index 000000000..8a819c6f6
--- /dev/null
+++ b/src/Items/ItemCookedFish.h
@@ -0,0 +1,37 @@
+
+#pragma once
+
+#include "ItemFood.h"
+
+
+
+
+
+class cItemCookedFishHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemCookedFishHandler()
+ : super(E_ITEM_COOKED_FISH, FoodInfo(0, 0))
+ {
+ }
+
+ virtual FoodInfo GetFoodInfo(const cItem * a_Item) override
+ {
+ static const FoodInfo CookedFishInfos[] =
+ {
+ FoodInfo(5, 6.0), // Cooked fish
+ FoodInfo(6, 9.6), // Cooked salmon
+ };
+
+ if (a_Item->m_ItemDamage >= static_cast<short>(ARRAYCOUNT(CookedFishInfos)))
+ {
+ LOGWARNING("Unknown cooked fish type '%d'", a_Item->m_ItemDamage);
+ return FoodInfo(0, 0);
+ }
+ return CookedFishInfos[a_Item->m_ItemDamage];
+ }
+
+};
diff --git a/src/Items/ItemFood.h b/src/Items/ItemFood.h
index 3f1c40d36..f8137ab6f 100644
--- a/src/Items/ItemFood.h
+++ b/src/Items/ItemFood.h
@@ -13,8 +13,9 @@ class cItemFoodHandler :
typedef cItemHandler super;
public:
- cItemFoodHandler(int a_ItemType)
- : super(a_ItemType)
+ cItemFoodHandler(int a_ItemType, FoodInfo a_FoodInfo)
+ : super(a_ItemType),
+ m_FoodInfo(a_FoodInfo)
{
}
@@ -24,76 +25,10 @@ public:
return true;
}
-
virtual FoodInfo GetFoodInfo(const cItem * a_Item) override
{
- static const FoodInfo RawFishInfos[] =
- {
- FoodInfo(2, 0.4), // Raw fish
- FoodInfo(2, 0.2), // Raw salmon
- FoodInfo(1, 0.2), // Clownfish
- FoodInfo(1, 0.2), // Pufferfish
- };
- static const FoodInfo CookedFishInfos[] =
- {
- FoodInfo(5, 6.0), // Cooked fish
- FoodInfo(6, 9.6), // Cooked salmon
- };
- static const short NumRawFishInfos = sizeof(RawFishInfos) / sizeof(FoodInfo);
- static const short NumCookedFishInfos = sizeof(CookedFishInfos) / sizeof(FoodInfo);
-
- switch (m_ItemType)
- {
- // Please keep alpha-sorted.
- case E_ITEM_BAKED_POTATO: return FoodInfo(5, 6);
- case E_ITEM_BEETROOT: return FoodInfo(1, 1.2);
- case E_ITEM_BEETROOT_SOUP: return FoodInfo(6, 7.2);
- case E_ITEM_BREAD: return FoodInfo(5, 6);
- // Carrots handled in ItemSeeds
- case E_ITEM_CHORUS_FRUIT: return FoodInfo(4, 2.4);
- case E_ITEM_COOKED_CHICKEN: return FoodInfo(6, 7.2);
- case E_ITEM_COOKED_FISH:
- {
- if (a_Item->m_ItemDamage >= NumCookedFishInfos)
- {
- LOGWARNING("Unknown cooked fish type '%d'", a_Item->m_ItemDamage);
- return FoodInfo(0, 0);
- }
- return CookedFishInfos[a_Item->m_ItemDamage];
- }
- case E_ITEM_COOKED_MUTTON: return FoodInfo(6, 9.6);
- case E_ITEM_COOKED_PORKCHOP: return FoodInfo(8, 12.8);
- case E_ITEM_COOKED_RABBIT: return FoodInfo(5, 6);
- case E_ITEM_COOKIE: return FoodInfo(2, 0.5);
- // Golden apple handled in ItemGoldenApple
- case E_ITEM_GOLDEN_CARROT: return FoodInfo(6, 14.4);
- case E_ITEM_MELON_SLICE: return FoodInfo(2, 1.2);
- case E_ITEM_MUSHROOM_SOUP: return FoodInfo(6, 7.2);
- case E_ITEM_POISONOUS_POTATO: return FoodInfo(2, 1.2);
- // Potatoes handled in ItemSeeds
- case E_ITEM_PUMPKIN_PIE: return FoodInfo(8, 4.8);
- case E_ITEM_RABBIT_STEW: return FoodInfo(10, 12);
- case E_ITEM_RED_APPLE: return FoodInfo(4, 2.4);
- case E_ITEM_RAW_BEEF: return FoodInfo(3, 1.8);
- case E_ITEM_RAW_CHICKEN: return FoodInfo(2, 1.2);
- case E_ITEM_RAW_FISH:
- {
- if (a_Item->m_ItemDamage >= NumRawFishInfos)
- {
- LOGWARNING("Unknown raw fish type '%d'", a_Item->m_ItemDamage);
- return FoodInfo(0, 0);
- }
- return RawFishInfos[a_Item->m_ItemDamage];
- }
- case E_ITEM_RAW_MUTTON: return FoodInfo(2, 1.2);
- case E_ITEM_RAW_PORKCHOP: return FoodInfo(3, 1.8);
- case E_ITEM_RAW_RABBIT: return FoodInfo(3, 1.8);
- case E_ITEM_ROTTEN_FLESH: return FoodInfo(4, 0.8);
- case E_ITEM_SPIDER_EYE: return FoodInfo(2, 3.2);
- case E_ITEM_STEAK: return FoodInfo(8, 12.8);
- }
- LOGWARNING("%s: Unknown food item (%d), returning zero nutrition", __FUNCTION__, m_ItemType);
- return FoodInfo(0, 0.f);
+ UNUSED(a_Item);
+ return m_FoodInfo;
}
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
@@ -108,62 +43,12 @@ public:
a_Player->GetInventory().RemoveOneEquippedItem();
}
- switch (m_ItemType)
- {
- case E_ITEM_BEETROOT_SOUP:
- case E_ITEM_MUSHROOM_SOUP:
- case E_ITEM_RABBIT_STEW:
- {
- // Return a bowl to the inventory
- if (!a_Player->IsGameModeCreative())
- {
- a_Player->GetInventory().AddItem(cItem(E_ITEM_BOWL));
- }
- break;
- }
- case E_ITEM_RAW_FISH:
- {
- if (a_Item->m_ItemDamage == E_META_RAW_FISH_PUFFERFISH)
- {
- a_Player->AddEntityEffect(cEntityEffect::effHunger, 20 * 15, 2);
- a_Player->AddEntityEffect(cEntityEffect::effNausea, 20 * 15, 1);
- a_Player->AddEntityEffect(cEntityEffect::effPoison, 20 * 60, 3);
- }
- break;
- }
- case E_ITEM_RAW_CHICKEN:
- {
- if (GetRandomProvider().RandBool(0.3))
- {
- a_Player->AddEntityEffect(cEntityEffect::effHunger, 600, 0);
- }
- break;
- }
- case E_ITEM_ROTTEN_FLESH:
- {
- if (GetRandomProvider().RandBool(0.8))
- {
- a_Player->AddEntityEffect(cEntityEffect::effHunger, 600, 0);
- }
- break;
- }
- case E_ITEM_SPIDER_EYE:
- {
- a_Player->AddEntityEffect(cEntityEffect::effPoison, 100, 0);
- break;
- }
- case E_ITEM_POISONOUS_POTATO:
- {
- if (GetRandomProvider().RandBool(0.6))
- {
- a_Player->AddEntityEffect(cEntityEffect::effPoison, 100, 0);
- }
- break;
- }
- }
return true;
}
+protected:
+ FoodInfo m_FoodInfo;
+
};
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;
+
+};
diff --git a/src/Items/ItemGoldenApple.h b/src/Items/ItemGoldenApple.h
index 2303e0e7a..cece9a54a 100644
--- a/src/Items/ItemGoldenApple.h
+++ b/src/Items/ItemGoldenApple.h
@@ -14,14 +14,18 @@ class cItemGoldenAppleHandler :
public:
cItemGoldenAppleHandler()
- : super(E_ITEM_GOLDEN_APPLE)
+ : super(E_ITEM_GOLDEN_APPLE, FoodInfo(4, 9.6))
{
}
-
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
- super::EatItem(a_Player, a_Item);
+ cItemHandler::EatItem(a_Player, a_Item);
+
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->GetInventory().RemoveOneEquippedItem();
+ }
// Enchanted golden apples have stronger effects:
if (a_Item->m_ItemDamage >= E_META_GOLDEN_APPLE_ENCHANTED)
@@ -39,11 +43,4 @@ public:
return true;
}
-
- virtual FoodInfo GetFoodInfo(const cItem * a_Item) override
- {
- UNUSED(a_Item);
- return FoodInfo(4, 9.6);
- }
-
};
diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp
index ecc4a9ace..1c552265a 100644
--- a/src/Items/ItemHandler.cpp
+++ b/src/Items/ItemHandler.cpp
@@ -9,6 +9,7 @@
// Handlers:
#include "ItemArmor.h"
+#include "ItemAxe.h"
#include "ItemBed.h"
#include "ItemBigFlower.h"
#include "ItemBoat.h"
@@ -21,6 +22,7 @@
#include "ItemChest.h"
#include "ItemCloth.h"
#include "ItemComparator.h"
+#include "ItemCookedFish.h"
#include "ItemDoor.h"
#include "ItemDye.h"
#include "ItemEmptyMap.h"
@@ -28,6 +30,7 @@
#include "ItemFishingRod.h"
#include "ItemFlowerPot.h"
#include "ItemFood.h"
+#include "ItemFoodSeeds.h"
#include "ItemGoldenApple.h"
#include "ItemHoe.h"
#include "ItemItemFrame.h"
@@ -41,22 +44,27 @@
#include "ItemNetherWart.h"
#include "ItemPainting.h"
#include "ItemPickaxe.h"
+#include "ItemPoisonousPotato.h"
#include "ItemPotion.h"
#include "ItemPumpkin.h"
+#include "ItemRawChicken.h"
+#include "ItemRawFish.h"
#include "ItemRedstoneDust.h"
#include "ItemRedstoneRepeater.h"
+#include "ItemRottenFlesh.h"
#include "ItemSapling.h"
#include "ItemSeeds.h"
#include "ItemShears.h"
#include "ItemShovel.h"
#include "ItemSign.h"
#include "ItemSlab.h"
+#include "ItemSoup.h"
#include "ItemSpawnEgg.h"
+#include "ItemSpiderEye.h"
#include "ItemString.h"
#include "ItemSugarcane.h"
#include "ItemSword.h"
#include "ItemThrowable.h"
-#include "ItemAxe.h"
#include "../Blocks/BlockHandler.h"
@@ -139,7 +147,6 @@ cItemHandler * cItemHandler::CreateItemHandler(int 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_GLASS_BOTTLE: return new cItemBottleHandler();
- case E_ITEM_GOLDEN_APPLE: return new cItemGoldenAppleHandler();
case E_ITEM_MAP: return new cItemMapHandler();
case E_ITEM_MILK: return new cItemMilkHandler();
case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
@@ -209,15 +216,16 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType)
}
case E_ITEM_BEETROOT_SEEDS:
- case E_ITEM_CARROT:
case E_ITEM_MELON_SEEDS:
- case E_ITEM_POTATO:
case E_ITEM_PUMPKIN_SEEDS:
case E_ITEM_SEEDS:
{
return new cItemSeedsHandler(a_ItemType);
}
+ case E_ITEM_POTATO: return new cItemFoodSeedsHandler(a_ItemType, FoodInfo(1, 0.6));
+ case E_ITEM_CARROT: return new cItemFoodSeedsHandler(a_ItemType, FoodInfo(3, 6.6));
+
case E_ITEM_ACACIA_DOOR:
case E_ITEM_BIRCH_DOOR:
case E_ITEM_DARK_OAK_DOOR:
@@ -239,37 +247,38 @@ cItemHandler * cItemHandler::CreateItemHandler(int a_ItemType)
}
// Food (please keep alpha-sorted):
- // (carrots and potatoes handled separately in SeedHandler as they're both seed and food)
- case E_ITEM_BAKED_POTATO:
- case E_ITEM_BEETROOT:
- case E_ITEM_BEETROOT_SOUP:
- case E_ITEM_BREAD:
- case E_ITEM_CHORUS_FRUIT:
- case E_ITEM_COOKED_CHICKEN:
- case E_ITEM_COOKED_FISH:
- case E_ITEM_COOKED_MUTTON:
- case E_ITEM_COOKED_PORKCHOP:
- case E_ITEM_COOKED_RABBIT:
- case E_ITEM_COOKIE:
- case E_ITEM_GOLDEN_CARROT:
- case E_ITEM_MELON_SLICE:
- case E_ITEM_MUSHROOM_SOUP:
- case E_ITEM_POISONOUS_POTATO:
- case E_ITEM_PUMPKIN_PIE:
- case E_ITEM_RABBIT_STEW:
- case E_ITEM_RAW_BEEF:
- case E_ITEM_RAW_CHICKEN:
- case E_ITEM_RAW_FISH:
- case E_ITEM_RAW_MUTTON:
- case E_ITEM_RAW_PORKCHOP:
- case E_ITEM_RAW_RABBIT:
- case E_ITEM_RED_APPLE:
- case E_ITEM_ROTTEN_FLESH:
- case E_ITEM_SPIDER_EYE:
- case E_ITEM_STEAK:
- {
- return new cItemFoodHandler(a_ItemType);
- }
+ case E_ITEM_BAKED_POTATO: return new cItemFoodHandler(a_ItemType, FoodInfo(5, 6));
+ case E_ITEM_BEETROOT: return new cItemFoodHandler(a_ItemType, FoodInfo(1, 1.2));
+ case E_ITEM_BREAD: return new cItemFoodHandler(a_ItemType, FoodInfo(5, 6));
+ case E_ITEM_CHORUS_FRUIT: return new cItemFoodHandler(a_ItemType, FoodInfo(4, 2.4));
+ case E_ITEM_COOKED_CHICKEN: return new cItemFoodHandler(a_ItemType, FoodInfo(6, 7.2));
+ case E_ITEM_COOKED_MUTTON: return new cItemFoodHandler(a_ItemType, FoodInfo(6, 9.6));
+ case E_ITEM_COOKED_PORKCHOP: return new cItemFoodHandler(a_ItemType, FoodInfo(8, 12.8));
+ case E_ITEM_COOKED_RABBIT: return new cItemFoodHandler(a_ItemType, FoodInfo(5, 6));
+ case E_ITEM_COOKIE: return new cItemFoodHandler(a_ItemType, FoodInfo(2, 0.5));
+ case E_ITEM_GOLDEN_CARROT: return new cItemFoodHandler(a_ItemType, FoodInfo(6, 14.4));
+ case E_ITEM_MELON_SLICE: return new cItemFoodHandler(a_ItemType, FoodInfo(2, 1.2));
+ case E_ITEM_PUMPKIN_PIE: return new cItemFoodHandler(a_ItemType, FoodInfo(8, 4.8));
+ case E_ITEM_RED_APPLE: return new cItemFoodHandler(a_ItemType, FoodInfo(4, 2.4));
+ case E_ITEM_RAW_BEEF: return new cItemFoodHandler(a_ItemType, FoodInfo(3, 1.8));
+ case E_ITEM_RAW_MUTTON: return new cItemFoodHandler(a_ItemType, FoodInfo(2, 1.2));
+ case E_ITEM_RAW_PORKCHOP: return new cItemFoodHandler(a_ItemType, FoodInfo(3, 1.8));
+ case E_ITEM_RAW_RABBIT: return new cItemFoodHandler(a_ItemType, FoodInfo(3, 1.8));
+ case E_ITEM_STEAK: return new cItemFoodHandler(a_ItemType, FoodInfo(8, 12.8));
+
+ // Special-case food with their own handler
+ case E_ITEM_COOKED_FISH: return new cItemCookedFishHandler();
+ case E_ITEM_GOLDEN_APPLE: return new cItemGoldenAppleHandler();
+ case E_ITEM_POISONOUS_POTATO: return new cItemPoisonousPotatoHandler();
+ case E_ITEM_RAW_CHICKEN: return new cItemRawChickenHandler();
+ case E_ITEM_RAW_FISH: return new cItemRawFishHandler();
+ case E_ITEM_ROTTEN_FLESH: return new cItemRottenFleshHandler();
+ case E_ITEM_SPIDER_EYE: return new cItemSpiderEyeHandler();
+
+ // Soup:
+ case E_ITEM_BEETROOT_SOUP: return new cItemSoupHandler(a_ItemType, FoodInfo(6, 7.2));
+ case E_ITEM_MUSHROOM_SOUP: return new cItemSoupHandler(a_ItemType, FoodInfo(6, 7.2));
+ case E_ITEM_RABBIT_STEW: return new cItemSoupHandler(a_ItemType, FoodInfo(10, 12));
// Armor:
case E_ITEM_LEATHER_CAP:
diff --git a/src/Items/ItemMilk.h b/src/Items/ItemMilk.h
index 515c80493..94fa51d09 100644
--- a/src/Items/ItemMilk.h
+++ b/src/Items/ItemMilk.h
@@ -28,8 +28,7 @@ public:
if (!a_Player->IsGameModeCreative())
{
- a_Player->GetInventory().RemoveOneEquippedItem();
- a_Player->GetInventory().AddItem(cItem(E_ITEM_BUCKET));
+ a_Player->ReplaceOneEquippedItemTossRest(cItem(E_ITEM_BUCKET));
}
return true;
}
diff --git a/src/Items/ItemPoisonousPotato.h b/src/Items/ItemPoisonousPotato.h
new file mode 100644
index 000000000..8d2dd93e7
--- /dev/null
+++ b/src/Items/ItemPoisonousPotato.h
@@ -0,0 +1,36 @@
+
+#pragma once
+
+#include "ItemFood.h"
+
+
+
+
+
+class cItemPoisonousPotatoHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemPoisonousPotatoHandler()
+ : super(E_ITEM_POISONOUS_POTATO, FoodInfo(2, 1.2))
+ {
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ if (!super::EatItem(a_Player, a_Item))
+ {
+ return false;
+ }
+
+ if (GetRandomProvider().RandBool(0.6))
+ {
+ a_Player->AddEntityEffect(cEntityEffect::effPoison, 100, 0);
+ }
+
+ return true;
+ }
+
+};
diff --git a/src/Items/ItemRawChicken.h b/src/Items/ItemRawChicken.h
new file mode 100644
index 000000000..e1a6d4870
--- /dev/null
+++ b/src/Items/ItemRawChicken.h
@@ -0,0 +1,36 @@
+
+#pragma once
+
+#include "ItemFood.h"
+
+
+
+
+
+class cItemRawChickenHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemRawChickenHandler()
+ : super(E_ITEM_RAW_CHICKEN, FoodInfo(2, 1.2))
+ {
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ if (!super::EatItem(a_Player, a_Item))
+ {
+ return false;
+ }
+
+ if (GetRandomProvider().RandBool(0.3))
+ {
+ a_Player->AddEntityEffect(cEntityEffect::effHunger, 600, 0);
+ }
+
+ return true;
+ }
+
+};
diff --git a/src/Items/ItemRawFish.h b/src/Items/ItemRawFish.h
new file mode 100644
index 000000000..7f9f49e2a
--- /dev/null
+++ b/src/Items/ItemRawFish.h
@@ -0,0 +1,57 @@
+
+#pragma once
+
+#include "ItemFood.h"
+
+
+
+
+
+class cItemRawFishHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemRawFishHandler()
+ : super(E_ITEM_RAW_FISH, FoodInfo(0, 0))
+ {
+ }
+
+ virtual FoodInfo GetFoodInfo(const cItem * a_Item) override
+ {
+ static const FoodInfo RawFishInfos[] =
+ {
+ FoodInfo(2, 0.4), // Raw fish
+ FoodInfo(2, 0.2), // Raw salmon
+ FoodInfo(1, 0.2), // Clownfish
+ FoodInfo(1, 0.2), // Pufferfish
+ };
+
+ if (a_Item->m_ItemDamage >= static_cast<short>(ARRAYCOUNT(RawFishInfos)))
+ {
+ LOGWARNING("Unknown raw fish type '%d'", a_Item->m_ItemDamage);
+ return FoodInfo(0, 0);
+ }
+ return RawFishInfos[a_Item->m_ItemDamage];
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ if (!super::EatItem(a_Player, a_Item))
+ {
+ return false;
+ }
+
+ if (a_Item->m_ItemDamage == E_META_RAW_FISH_PUFFERFISH)
+ {
+ a_Player->AddEntityEffect(cEntityEffect::effHunger, 20 * 15, 2);
+ a_Player->AddEntityEffect(cEntityEffect::effNausea, 20 * 15, 1);
+ a_Player->AddEntityEffect(cEntityEffect::effPoison, 20 * 60, 3);
+ }
+
+
+ return true;
+ }
+
+};
diff --git a/src/Items/ItemRottenFlesh.h b/src/Items/ItemRottenFlesh.h
new file mode 100644
index 000000000..a4b34e8bc
--- /dev/null
+++ b/src/Items/ItemRottenFlesh.h
@@ -0,0 +1,36 @@
+
+#pragma once
+
+#include "ItemFood.h"
+
+
+
+
+
+class cItemRottenFleshHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemRottenFleshHandler()
+ : super(E_ITEM_ROTTEN_FLESH, FoodInfo(4, 0.8))
+ {
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ if (!super::EatItem(a_Player, a_Item))
+ {
+ return false;
+ }
+
+ if (GetRandomProvider().RandBool(0.8))
+ {
+ a_Player->AddEntityEffect(cEntityEffect::effHunger, 600, 0);
+ }
+
+ return true;
+ }
+
+};
diff --git a/src/Items/ItemSeeds.h b/src/Items/ItemSeeds.h
index a04ab3c05..8338d1060 100644
--- a/src/Items/ItemSeeds.h
+++ b/src/Items/ItemSeeds.h
@@ -23,27 +23,6 @@ public:
return true;
}
- virtual bool IsFood(void) override
- {
- switch (m_ItemType) // Special cases, both a seed and food
- {
- case E_ITEM_CARROT:
- case E_ITEM_POTATO: return true;
- default: return false;
- }
- }
-
- virtual FoodInfo GetFoodInfo(const cItem * a_Item) override
- {
- UNUSED(a_Item);
- switch (m_ItemType)
- {
- case E_ITEM_CARROT: return FoodInfo(3, 3.6);
- case E_ITEM_POTATO: return FoodInfo(1, 0.6);
- default: return FoodInfo(0, 0);
- }
- }
-
virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player,
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
diff --git a/src/Items/ItemSoup.h b/src/Items/ItemSoup.h
new file mode 100644
index 000000000..958c0e0ea
--- /dev/null
+++ b/src/Items/ItemSoup.h
@@ -0,0 +1,39 @@
+
+#pragma once
+
+#include "ItemFood.h"
+#include "../World.h"
+
+
+
+
+
+class cItemSoupHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemSoupHandler(int a_ItemType, FoodInfo a_FoodInfo) :
+ super(a_ItemType, a_FoodInfo)
+ {
+
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ // Skip over food handler, which does removal for us.
+ if (!cItemHandler::EatItem(a_Player, a_Item))
+ {
+ return false;
+ }
+
+ if (!a_Player->IsGameModeCreative())
+ {
+ a_Player->ReplaceOneEquippedItemTossRest(cItem(E_ITEM_BOWL));
+ }
+
+ return true;
+ }
+
+};
diff --git a/src/Items/ItemSpiderEye.h b/src/Items/ItemSpiderEye.h
new file mode 100644
index 000000000..901f5d3d0
--- /dev/null
+++ b/src/Items/ItemSpiderEye.h
@@ -0,0 +1,33 @@
+
+#pragma once
+
+#include "ItemFood.h"
+
+
+
+
+
+class cItemSpiderEyeHandler :
+ public cItemFoodHandler
+{
+ typedef cItemFoodHandler super;
+
+public:
+ cItemSpiderEyeHandler()
+ : super(E_ITEM_SPIDER_EYE, FoodInfo(2, 3.2))
+ {
+ }
+
+ virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
+ {
+ if (!super::EatItem(a_Player, a_Item))
+ {
+ return false;
+ }
+
+ a_Player->AddEntityEffect(cEntityEffect::effPoison, 100, 0);
+
+ return true;
+ }
+
+};