FoodComponentHelper
com.jsmacrosce.jsmacros.client.api.helper.inventory.FoodComponentHelper
Exposes an item's nutrition, saturation, and always-edible flag.
js
const apple = Client.getRegistryManager().getItem("minecraft:golden_apple");
const food = apple.getFood();
if (food !== null) {
Chat.log(`${food.getHunger()} hunger points, ${food.getSaturation()} saturation`);
}Constructors
new FoodComponentHelper
new FoodComponentHelper(FoodProperties base)#Wraps the supplied food properties for access through this helper.
Parameters:
base: raw food properties to wrap
Methods
getHunger
Returns this food's nutrition value in hunger points (two points per bar segment).
Returns: the amount of hunger this food restores.
getSaturation
Returns the saturation value stored for this food.
Returns: the amount of saturation this food restores.
isAlwaysEdible
Returns whether this food's always-edible flag is set.
Returns:
true if the always-edible flag is set; false otherwise.