Skip to content

FoodComponentHelper ​

com.jsmacrosce.jsmacros.client.api.helper.inventory.FoodComponentHelper

Since1.8.4

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 ​

getHunger(): intSince1.8.4#
Returns this food's nutrition value in hunger points (two points per bar segment).
Returns: the amount of hunger this food restores.

getSaturation ​

getSaturation(): floatSince1.8.4#
Returns the saturation value stored for this food.
Returns: the amount of saturation this food restores.

isAlwaysEdible ​

isAlwaysEdible(): booleanSince1.8.4#
Returns whether this food's always-edible flag is set.
Returns: true if the always-edible flag is set; false otherwise.

toString ​

toString(): String#
Returns a diagnostic representation of this food's nutrition, saturation, and always-edible flag.
Returns: diagnostic representation of the food properties