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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user