Home Commands Examples Getting Started With Scripts Global Keywords 1.21 Migration Guide
BracketDumpers BracketHandlers BracketValidators ResourceLocationBracketHandler

FoodData

Importing the class

If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.

script.zs
import crafttweaker.api.food.FoodData;

Members

addExhaustion(exhaustion as float)
Adds exhaustion to the entity.
script.zs
// FoodData.addExhaustion(exhaustion as float);
myFoodData.addExhaustion(myFloat);

Parameters:

exhaustion Type: float - The amount of exhaustion to add.
eat(foodLevelModifier as int, saturationLevelModifier as float)
Replenishes the food level and saturation level.
script.zs
// FoodData.eat(foodLevelModifier as int, saturationLevelModifier as float);
myFoodData.eat(myInt, myFloat);

Parameters:

foodLevelModifier Type: int - The amount to modify the food level by.
saturationLevelModifier Type: float - The amount to modify the saturation level by.
eat(foodProperties as FoodProperties)
Replenishes the food level and saturation level.
script.zs
// FoodData.eat(foodProperties as FoodProperties);
myFoodData.eat(myFoodProperties);

Parameters:

foodProperties Type: FoodProperties - The food properties to eat.
getExhaustionLevel() as float
Gets the exhaustion level.

Returns: The exhaustion level.

script.zs
// FoodData.getExhaustionLevel() as float;
myFoodData.getExhaustionLevel();

Return Type: float

getFoodLevel() as int
Gets the food level.

Returns: The food level.

script.zs
// FoodData.getFoodLevel() as int;
myFoodData.getFoodLevel();

Return Type: int

getLastFoodLevel() as int
Gets the last food level.

Returns: The last food level.

script.zs
// FoodData.getLastFoodLevel() as int;
myFoodData.getLastFoodLevel();

Return Type: int

getSaturationLevel() as float
Gets the saturation level.

Returns: The saturation level.

script.zs
// FoodData.getSaturationLevel() as float;
myFoodData.getSaturationLevel();

Return Type: float

needsFood() as bool
Checks if the entity needs food.

Returns: True if the entity needs food, false otherwise.

script.zs
// FoodData.needsFood() as bool;
myFoodData.needsFood();

Return Type: bool

setExhaustion(exhaustionLevel as float)
Sets the exhaustion level.
script.zs
// FoodData.setExhaustion(exhaustionLevel as float);
myFoodData.setExhaustion(myFloat);

Parameters:

exhaustionLevel Type: float - The amount of exhaustion to set.
setFoodLevel(foodLevel as int)
Sets the food level.
script.zs
// FoodData.setFoodLevel(foodLevel as int);
myFoodData.setFoodLevel(myInt);

Parameters:

foodLevel Type: int - The amount of food to set.
setSaturation(saturationLevel as float)
Sets the saturation level.
script.zs
// FoodData.setSaturation(saturationLevel as float);
myFoodData.setSaturation(myFloat);

Parameters:

saturationLevel Type: float - The amount of saturation to set.