1
0

Consolidated food effects into EatItem, added all fish type FoodInfos. (#3875)

* Consolidated food effects into EatItem, added all fish types.

* Changed type of NumFishInfos to satisfy clang.

* Removed unused call for a_Item in EatItem
This commit is contained in:
Lane Kolbly
2017-07-30 12:53:21 -05:00
committed by worktycho
parent 8fbb9dbf53
commit 10d42a2452
6 changed files with 93 additions and 90 deletions

View File

@@ -826,41 +826,17 @@ bool cItemHandler::GetPlacementBlockTypeMeta(
bool cItemHandler::GetEatEffect(cEntityEffect::eType & a_EffectType, int & a_EffectDurationTicks, short & a_EffectIntensity, float & a_Chance)
{
return false;
}
bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
{
UNUSED(a_Item);
if (!a_Player->IsGameModeCreative())
{
a_Player->GetInventory().RemoveOneEquippedItem();
}
FoodInfo Info = GetFoodInfo();
FoodInfo Info = GetFoodInfo(a_Item);
if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f))
{
bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation);
// Give effects
cEntityEffect::eType EffectType;
int EffectDurationTicks;
short EffectIntensity;
float Chance;
if (Success && GetEatEffect(EffectType, EffectDurationTicks, EffectIntensity, Chance))
{
if (GetRandomProvider().RandBool(Chance))
{
a_Player->AddEntityEffect(EffectType, EffectDurationTicks, EffectIntensity, Chance);
}
}
return Success;
return a_Player->Feed(Info.FoodLevel, Info.Saturation);
}
return false;
}
@@ -869,8 +845,9 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
cItemHandler::FoodInfo cItemHandler::GetFoodInfo()
cItemHandler::FoodInfo cItemHandler::GetFoodInfo(const cItem * a_Item)
{
UNUSED(a_Item);
return FoodInfo(0, 0);
}