1
0
Fork 0

Added extra mushroom handler.

This commit is contained in:
Howaner 2014-09-12 19:34:19 +02:00
parent 1223a24d3c
commit 96e03fc3ea
4 changed files with 60 additions and 10 deletions

View File

@ -627,13 +627,6 @@ void cPlayer::FinishEating(void)
return;
}
ItemHandler->OnFoodEaten(m_World, this, &Item);
// if the food is mushroom soup, return a bowl to the inventory
if (Item.m_ItemType == E_ITEM_MUSHROOM_SOUP)
{
GetInventory().RemoveOneEquippedItem();
GetInventory().AddItem(cItem(E_ITEM_BOWL), true, true);
}
}

View File

@ -1,3 +1,4 @@
#pragma once
#include "ItemHandler.h"
@ -39,7 +40,6 @@ public:
// 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);

View File

@ -33,6 +33,7 @@
#include "ItemLilypad.h"
#include "ItemMap.h"
#include "ItemMinecart.h"
#include "ItemMushroomSoup.h"
#include "ItemNetherWart.h"
#include "ItemPainting.h"
#include "ItemPickaxe.h"
@ -125,6 +126,7 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_BLOCK_LILY_PAD: return new cItemLilypadHandler(a_ItemType);
case E_ITEM_MAP: return new cItemMapHandler();
case E_ITEM_MILK: return new cItemMilkHandler();
case E_ITEM_MUSHROOM_SOUP: return new cItemMushroomSoupHandler(a_ItemType);
case E_ITEM_ITEM_FRAME: return new cItemItemFrameHandler(a_ItemType);
case E_ITEM_NETHER_WART: return new cItemNetherWartHandler(a_ItemType);
case E_ITEM_PAINTING: return new cItemPaintingHandler(a_ItemType);
@ -216,7 +218,6 @@ cItemHandler *cItemHandler::CreateItemHandler(int a_ItemType)
case E_ITEM_COOKIE:
case E_ITEM_GOLDEN_CARROT:
case E_ITEM_MELON_SLICE:
case E_ITEM_MUSHROOM_SOUP:
case E_ITEM_MUTTON:
case E_ITEM_POISONOUS_POTATO:
case E_ITEM_PUMPKIN_PIE:
@ -634,7 +635,10 @@ bool cItemHandler::GetEatEffect(cEntityEffect::eType & a_EffectType, int & a_Eff
bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
{
UNUSED(a_Item);
a_Player->GetInventory().RemoveOneEquippedItem();
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().RemoveOneEquippedItem();
}
FoodInfo Info = GetFoodInfo();
if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f))

View File

@ -0,0 +1,53 @@
#pragma once
#include "ItemHandler.h"
class cItemMushroomSoupHandler :
public cItemHandler
{
typedef cItemHandler super;
public:
cItemMushroomSoupHandler(int a_ItemType)
: super(a_ItemType)
{
}
virtual bool IsFood(void) override
{
return true;
}
virtual FoodInfo GetFoodInfo(void) override
{
return FoodInfo(6, 7.2);
}
virtual bool EatItem(cPlayer * a_Player, cItem * a_Item) override
{
if (!super::EatItem(a_Player, a_Item))
{
return false;
}
// Return a bowl to the inventory
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().AddItem(cItem(E_ITEM_BOWL), true, true);
}
return true;
}
};