1
0
* Fixed consumption of carrots and potatoes
This commit is contained in:
Tiger Wang 2014-02-03 21:16:26 +00:00
parent 6bbba2644d
commit 3fc848c95a
3 changed files with 40 additions and 15 deletions

View File

@ -31,7 +31,7 @@ public:
// Please keep alpha-sorted. // Please keep alpha-sorted.
case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2); case E_ITEM_BAKED_POTATO: return FoodInfo(6, 7.2);
case E_ITEM_BREAD: return FoodInfo(5, 6); case E_ITEM_BREAD: return FoodInfo(5, 6);
case E_ITEM_CARROT: return FoodInfo(4, 4.8); // Carrots handled in ItemSeeds
case E_ITEM_COOKED_CHICKEN: return FoodInfo(6, 7.2); case E_ITEM_COOKED_CHICKEN: return FoodInfo(6, 7.2);
case E_ITEM_COOKED_FISH: return FoodInfo(5, 6); case E_ITEM_COOKED_FISH: return FoodInfo(5, 6);
case E_ITEM_COOKED_PORKCHOP: return FoodInfo(8, 12.8); case E_ITEM_COOKED_PORKCHOP: return FoodInfo(8, 12.8);
@ -39,8 +39,9 @@ public:
case E_ITEM_GOLDEN_APPLE: return FoodInfo(4, 9.6); case E_ITEM_GOLDEN_APPLE: return FoodInfo(4, 9.6);
case E_ITEM_GOLDEN_CARROT: return FoodInfo(6, 14.4); case E_ITEM_GOLDEN_CARROT: return FoodInfo(6, 14.4);
case E_ITEM_MELON_SLICE: return FoodInfo(2, 1.2); 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, 60); case E_ITEM_POISONOUS_POTATO: return FoodInfo(2, 1.2, 60);
case E_ITEM_POTATO: return FoodInfo(1, 0.6); // Potatoes handled in ItemSeeds
case E_ITEM_PUMPKIN_PIE: return FoodInfo(8, 4.8); case E_ITEM_PUMPKIN_PIE: return FoodInfo(8, 4.8);
case E_ITEM_RAW_BEEF: return FoodInfo(3, 1.8); case E_ITEM_RAW_BEEF: return FoodInfo(3, 1.8);
case E_ITEM_RAW_CHICKEN: return FoodInfo(2, 1.2, 30); case E_ITEM_RAW_CHICKEN: return FoodInfo(2, 1.2, 30);
@ -50,7 +51,6 @@ public:
case E_ITEM_ROTTEN_FLESH: return FoodInfo(4, 0.8, 80); case E_ITEM_ROTTEN_FLESH: return FoodInfo(4, 0.8, 80);
case E_ITEM_SPIDER_EYE: return FoodInfo(2, 3.2, 100); case E_ITEM_SPIDER_EYE: return FoodInfo(2, 3.2, 100);
case E_ITEM_STEAK: return FoodInfo(8, 12.8); case E_ITEM_STEAK: return FoodInfo(8, 12.8);
case E_ITEM_MUSHROOM_SOUP: return FoodInfo(6, 7.2);
} }
LOGWARNING("%s: Unknown food item (%d), returning zero nutrition", __FUNCTION__, m_ItemType); LOGWARNING("%s: Unknown food item (%d), returning zero nutrition", __FUNCTION__, m_ItemType);
return FoodInfo(0, 0.f); return FoodInfo(0, 0.f);

View File

@ -181,23 +181,28 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
return new cItemMinecartHandler(a_ItemType); return new cItemMinecartHandler(a_ItemType);
} }
// Food: // Food (please keep alpha-sorted):
// (carrots and potatoes handled in SeedHandler as both seed and food
case E_ITEM_BAKED_POTATO:
case E_ITEM_BREAD: case E_ITEM_BREAD:
case E_ITEM_COOKIE:
case E_ITEM_MELON_SLICE:
case E_ITEM_RAW_CHICKEN:
case E_ITEM_COOKED_CHICKEN: case E_ITEM_COOKED_CHICKEN:
case E_ITEM_RAW_BEEF:
case E_ITEM_RAW_PORKCHOP:
case E_ITEM_STEAK:
case E_ITEM_COOKED_PORKCHOP:
case E_ITEM_RAW_FISH:
case E_ITEM_COOKED_FISH: case E_ITEM_COOKED_FISH:
case E_ITEM_RED_APPLE: case E_ITEM_COOKED_PORKCHOP:
case E_ITEM_COOKIE:
case E_ITEM_GOLDEN_APPLE: case E_ITEM_GOLDEN_APPLE:
case E_ITEM_ROTTEN_FLESH: case E_ITEM_GOLDEN_CARROT:
case E_ITEM_MELON_SLICE:
case E_ITEM_MUSHROOM_SOUP: case E_ITEM_MUSHROOM_SOUP:
case E_ITEM_POISONOUS_POTATO:
case E_ITEM_PUMPKIN_PIE:
case E_ITEM_RAW_BEEF:
case E_ITEM_RAW_CHICKEN:
case E_ITEM_RAW_FISH:
case E_ITEM_RAW_PORKCHOP:
case E_ITEM_RED_APPLE:
case E_ITEM_ROTTEN_FLESH:
case E_ITEM_SPIDER_EYE: case E_ITEM_SPIDER_EYE:
case E_ITEM_STEAK:
{ {
return new cItemFoodHandler(a_ItemType); return new cItemFoodHandler(a_ItemType);
} }
@ -511,7 +516,7 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
cItemHandler::FoodInfo cItemHandler::GetFoodInfo() cItemHandler::FoodInfo cItemHandler::GetFoodInfo()
{ {
return FoodInfo(0, 0.f); return FoodInfo(0, 0);
} }

View File

@ -22,6 +22,26 @@ public:
{ {
return true; 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(void) override
{
switch (m_ItemType)
{
case E_ITEM_CARROT: return FoodInfo(4, 4.8);
case E_ITEM_POTATO: return FoodInfo(1, 0.6);
default: return FoodInfo(0, 0);
}
}
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(
cWorld * a_World, cPlayer * a_Player, cWorld * a_World, cPlayer * a_Player,