Package com.minecolonies.api.util
Class FoodUtils
java.lang.Object
com.minecolonies.api.util.FoodUtils
Food specific util functions.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanstatic booleancanEatLevel(net.minecraft.world.item.ItemStack stack, int buildingLevel) Check if that food can be eaten at a given building level.static ItemStoragecheckForFoodInBuilding(ICitizenData citizenData, Set<ItemStorage> menu, IBuilding building) Get the best food for a given citizen from a given inventory and return the index where it is.static doublecomputeSaturationConsumptionFactor(int buildingLevel) Compute the saturation consumption factor.static intgetBestFoodForCitizen(InventoryCitizen inventoryCitizen, ICitizenData citizenData, Set<ItemStorage> menu) Get the best food for a given citizen from a given inventory and return the index where it is.static intgetBuildingLevelForFood(net.minecraft.world.item.ItemStack resource) Calculate the given max building level for a given food.static intgetFoodTier(net.minecraft.world.item.ItemStack food) Calculate the food tier from the food item.static doublegetFoodValue(net.minecraft.world.item.ItemStack foodStack, AbstractEntityCitizen citizen) Calculate the actual food value for a citizen consuming a given food.static doublegetFoodValue(net.minecraft.world.item.ItemStack foodStack, net.minecraft.world.food.FoodProperties itemFood, double researchBonus) Calculate the actual food value for a citizen consuming a given food.static intgetMinFoodDiversityRequirement(int buildingLevel) Get the min food diversity requirement.static intgetMinFoodQualityRequirement(int buildingLevel) Get the min food quality requirement.static booleanhasBestOptionInInv(InventoryCitizen inventoryCitizen, ICitizenData citizenData, Set<ItemStorage> menu, IBuilding building) Get the best food for a given citizen from a given inventory and return the index where it is.
-
Field Details
-
EDIBLE
Predicate describing food which can be eaten (is not raw).
-
-
Constructor Details
-
FoodUtils
public FoodUtils()
-
-
Method Details
-
canEat
public static boolean canEat(net.minecraft.world.item.ItemStack stack, IBuilding homeBuilding, IBuilding workBuilding) - Parameters:
stack-workBuilding-- Returns:
-
canEatLevel
public static boolean canEatLevel(net.minecraft.world.item.ItemStack stack, int buildingLevel) Check if that food can be eaten at a given building level.- Parameters:
stack- the stack to check.buildingLevel- the respective building level.- Returns:
- true if so.
-
getBuildingLevelForFood
public static int getBuildingLevelForFood(net.minecraft.world.item.ItemStack resource) Calculate the given max building level for a given food.- Parameters:
resource- the stack to check.- Returns:
- the building level.
-
getFoodValue
public static double getFoodValue(net.minecraft.world.item.ItemStack foodStack, @Nullable net.minecraft.world.food.FoodProperties itemFood, double researchBonus) Calculate the actual food value for a citizen consuming a given food.- Parameters:
foodStack- the food to consume.itemFood- the food properties of that food.researchBonus- the bonus from research (0 for no bonus).- Returns:
- the saturation adjustment to apply when consuming this food.
-
getFoodValue
public static double getFoodValue(net.minecraft.world.item.ItemStack foodStack, AbstractEntityCitizen citizen) Calculate the actual food value for a citizen consuming a given food.- Parameters:
foodStack- the food to consume.citizen- the citizen consuming the food.- Returns:
- the saturation adjustment to apply when consuming this food.
-
getFoodTier
public static int getFoodTier(net.minecraft.world.item.ItemStack food) Calculate the food tier from the food item.- Parameters:
food- the food item.- Returns:
- the tier.
-
getBestFoodForCitizen
public static int getBestFoodForCitizen(InventoryCitizen inventoryCitizen, ICitizenData citizenData, @Nullable Set<ItemStorage> menu) Get the best food for a given citizen from a given inventory and return the index where it is.- Parameters:
inventoryCitizen- the inventory to check.citizenData- the citizen data the food is for.menu- the menu that has to be matched. or null- Returns:
- the matching inv slot, or -1.
-
checkForFoodInBuilding
public static ItemStorage checkForFoodInBuilding(ICitizenData citizenData, @Nullable Set<ItemStorage> menu, IBuilding building) Get the best food for a given citizen from a given inventory and return the index where it is.- Parameters:
citizenData- the citizen data the food is for.menu- the menu that has to be matched or null.- Returns:
- the matching inv slot, or -1.
-
hasBestOptionInInv
public static boolean hasBestOptionInInv(InventoryCitizen inventoryCitizen, ICitizenData citizenData, @Nullable Set<ItemStorage> menu, IBuilding building) Get the best food for a given citizen from a given inventory and return the index where it is.- Parameters:
citizenData- the citizen data the food is for.menu- the menu that has to be matched or null.- Returns:
- the matching inv slot, or -1.
-
getMinFoodQualityRequirement
public static int getMinFoodQualityRequirement(int buildingLevel) Get the min food quality requirement.- Parameters:
buildingLevel- the building level to take into account.- Returns:
- the food quality requirement in number of items.
-
getMinFoodDiversityRequirement
public static int getMinFoodDiversityRequirement(int buildingLevel) Get the min food diversity requirement.- Parameters:
buildingLevel- the building level to take into account.- Returns:
- the food diversity requirement in number of items.
-
computeSaturationConsumptionFactor
public static double computeSaturationConsumptionFactor(int buildingLevel) Compute the saturation consumption factor.- Parameters:
buildingLevel- the housing level it's based on.- Returns:
- the value.
-