<commit_before>package squeek.spiceoflife.foodtracker;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import squeek.spiceoflife.ModConfig;
import squeek.spiceoflife.proxy.ProxyAgriculture;
import squeek.spiceoflife.proxy.ProxyHungerOverhaul;
import squeek.spiceoflife.proxy.ProxyTiC;

public class FoodValues
{
	public int hunger;
	public float saturationModifier;

	public FoodValues(int hunger, float saturationModifier)
	{
		this.hunger = hunger;
		this.saturationModifier = saturationModifier;
	}

	public float getSaturationIncrement()
	{
		return Math.min(20, hunger * saturationModifier * 2f);
	}

	public FoodValues modify(float modifier)
	{
		hunger = (int) ModConfig.FOOD_HUNGER_ROUNDING_MODE.round((float) hunger * modifier);

		if (ModConfig.AFFECT_FOOD_SATURATION_MODIFIERS)
		{
			if (saturationModifier < 0 && ModConfig.AFFECT_NEGATIVE_FOOD_SATURATION_MODIFIERS)
				saturationModifier *= 2 - modifier;
			else if (saturationModifier > 0)
				saturationModifier *= modifier;
		}

		return this;
	}

	public FoodValues getModified(float modifier)
	{
		int modifiedHunger = (int) ModConfig.FOOD_HUNGER_ROUNDING_MODE.round((float) hunger * modifier);

		float modifiedSaturationModifier = saturationModifier;
		if (ModConfig.AFFECT_FOOD_SATURATION_MODIFIERS)
		{
			if (modifiedSaturationModifier < 0 && ModConfig.AFFECT_NEGATIVE_FOOD_SATURATION_MODIFIERS)
				modifiedSaturationModifier *= 2 - modifier;
			else if (modifiedSaturationModifier > 0)
				modifiedSaturationModifier *= modifier;
		}

		return new FoodValues(modifiedHunger, modifiedSaturationModifier);
	}

	public static FoodValues get(ItemStack food)
	{
		if (food.getItem() instanceof ItemFood)
		{
			ItemFood itemFood = (ItemFood) food.getItem();

			if (ProxyTiC.isSpecialFood(itemFood))
				return ProxyTiC.getSpecialFoodValues(food);
			else if (ProxyHungerOverhaul.foodValuesWillBeModified(food))
				return ProxyHungerOverhaul.getModifiedFoodValues(itemFood);
			else
				return new FoodValues(itemFood.getHealAmount(), itemFood.getSaturationModifier());
		}
		else if (ProxyAgriculture.isFood(food))
			return ProxyAgriculture.getFoodValues(food);

		return null;
	}

	public static FoodValues getModified(ItemStack food, float modifier)
	{<commit_msg>Remove unnecessarily duplicated code<commit_after>package squeek.spiceoflife.foodtracker;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import squeek.spiceoflife.ModConfig;
import squeek.spiceoflife.proxy.ProxyAgriculture;
import squeek.spiceoflife.proxy.ProxyHungerOverhaul;
import squeek.spiceoflife.proxy.ProxyTiC;

public class FoodValues
{
	public int hunger;
	public float saturationModifier;

	public FoodValues(int hunger, float saturationModifier)
	{
		this.hunger = hunger;
		this.saturationModifier = saturationModifier;
	}

	public float getSaturationIncrement()
	{
		return Math.min(20, hunger * saturationModifier * 2f);
	}

	public FoodValues modify(float modifier)
	{
		hunger = (int) ModConfig.FOOD_HUNGER_ROUNDING_MODE.round((float) hunger * modifier);

		if (ModConfig.AFFECT_FOOD_SATURATION_MODIFIERS)
		{
			if (saturationModifier < 0 && ModConfig.AFFECT_NEGATIVE_FOOD_SATURATION_MODIFIERS)
				saturationModifier *= 2 - modifier;
			else if (saturationModifier > 0)
				saturationModifier *= modifier;
		}

		return this;
	}

	public FoodValues getModified(float modifier)
	{
		return new FoodValues(hunger, saturationModifier).modify(modifier);
	}

	public static FoodValues get(ItemStack food)
	{
		if (food.getItem() instanceof ItemFood)
		{
			ItemFood itemFood = (ItemFood) food.getItem();

			if (ProxyTiC.isSpecialFood(itemFood))
				return ProxyTiC.getSpecialFoodValues(food);
			else if (ProxyHungerOverhaul.foodValuesWillBeModified(food))
				return ProxyHungerOverhaul.getModifiedFoodValues(itemFood);
			else
				return new FoodValues(itemFood.getHealAmount(), itemFood.getSaturationModifier());
		}
		else if (ProxyAgriculture.isFood(food))
			return ProxyAgriculture.getFoodValues(food);

		return null;
	}

	public static FoodValues getModified(ItemStack food, float modifier)
	{
{'fraction_non_alphanumeric': 0.08673954372623574, 'fraction_numerical': 0.003564638783269962, 'mean_word_length': 5.5458786936236395, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5390205', 'n_tokens_mistral': 1556, 'n_tokens_neox': 1368, 'n_words': 261}