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

FoodProperties

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.FoodProperties;

Description

Represents the properties of a food item.

Members

Getter
Gets whether the food can always be eaten.
script.zs
// FoodProperties.canAlwaysEat as bool
FoodProperties.create(1, 1.0, true, 1.0).canAlwaysEat

Return Type: bool

static create(nutrition as int, saturation as float, canAlwaysEat as bool, eatSeconds as float) as FoodProperties
Creates a new food properties.

Returns: The new food properties.

script.zs
// FoodProperties.create(nutrition as int, saturation as float, canAlwaysEat as bool, eatSeconds as float) as FoodProperties;
FoodProperties.create(myInt, myFloat, myBool, myFloat);

Parameters:

nutrition Type: int - The nutrition value.
saturation Type: float - The saturation value.
canAlwaysEat Type: bool - Whether the food can always be eaten.
eatSeconds Type: float - The number of seconds it takes to eat the food.

Return Type: FoodProperties

static create(nutrition as int, saturation as float, canAlwaysEat as bool, eatSeconds as float, usingConvertsTo as IItemStack) as FoodProperties
Creates a new food properties.

Returns: The new food properties.

script.zs
// FoodProperties.create(nutrition as int, saturation as float, canAlwaysEat as bool, eatSeconds as float, usingConvertsTo as IItemStack) as FoodProperties;
FoodProperties.create(myInt, myFloat, myBool, myFloat, myIItemStack);

Parameters:

nutrition Type: int - The nutrition value.
saturation Type: float - The saturation value.
canAlwaysEat Type: bool - Whether the food can always be eaten.
eatSeconds Type: float - The number of seconds it takes to eat the food.
usingConvertsTo Type: IItemStack - The item that the food converts to when eaten.

Return Type: FoodProperties

static create(nutrition as int, saturation as float, canAlwaysEat as bool, eatSeconds as float, usingConvertsTo as IItemStack, effects as List<PossibleEffect>) as FoodProperties
Creates a new food properties.

Returns: The new food properties.

script.zs
// FoodProperties.create(nutrition as int, saturation as float, canAlwaysEat as bool, eatSeconds as float, usingConvertsTo as IItemStack, effects as List<FoodPropertiesPossibleEffect>) as FoodProperties;
FoodProperties.create(myInt, myFloat, myBool, myFloat, myIItemStack, myList);

Parameters:

nutrition Type: int - The nutrition value.
saturation Type: float - The saturation value.
canAlwaysEat Type: bool - Whether the food can always be eaten.
eatSeconds Type: float - The number of seconds it takes to eat the food.
usingConvertsTo Type: IItemStack - The item that the food converts to when eaten.
effects Type: List<FoodPropertiesPossibleEffect> - The effects that the food applies when eaten.

Return Type: FoodProperties

Getter
Gets the number of seconds it takes to eat the food.
script.zs
// FoodProperties.eatSeconds as float
FoodProperties.create(1, 1.0, true, 1.0).eatSeconds

Return Type: float

Getter
Gets the effects of the food properties.
script.zs
// FoodProperties.effects as List<FoodPropertiesPossibleEffect>
FoodProperties.create(1, 1.0, true, 1.0).effects

Return Type: List<FoodPropertiesPossibleEffect>

Getter
Gets the nutrition value of the food properties.
script.zs
// FoodProperties.nutrition as int
FoodProperties.create(1, 1.0, true, 1.0).nutrition

Return Type: int

Getter
Gets the saturation modifier of the food properties.
script.zs
// FoodProperties.saturationModifier as float
FoodProperties.create(1, 1.0, true, 1.0).saturationModifier

Return Type: float

Getter
Gets the item that the food converts to when eaten.
script.zs
// FoodProperties.usingConvertsTo as IItemStack
FoodProperties.create(1, 1.0, true, 1.0).usingConvertsTo

Return Type: IItemStack

withCanAlwaysEat(canAlwaysEat as bool) as FoodProperties
Creates a new food properties based on this instance, with the given can always eat value.

Returns: The new food properties.

script.zs
// FoodProperties.withCanAlwaysEat(canAlwaysEat as bool) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withCanAlwaysEat(myBool);

Parameters:

canAlwaysEat Type: bool - The new can always eat value.

Return Type: FoodProperties

withEatSeconds(eatSeconds as int) as FoodProperties
Creates a new food properties based on this instance, with the given eat seconds value.

Returns: The new food properties.

script.zs
// FoodProperties.withEatSeconds(eatSeconds as int) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withEatSeconds(myInt);

Parameters:

eatSeconds Type: int - The new eat seconds value.

Return Type: FoodProperties

withEffect(effect as MobEffectInstance, probability as float) as FoodProperties
Creates a new food properties based on this instance, with the given effect.

Returns: The new food properties.

script.zs
// FoodProperties.withEffect(effect as MobEffectInstance, probability as float) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withEffect(myMobEffectInstance, myFloat);

Parameters:

effect Type: MobEffectInstance - The effect to add.
probability Type: float - The probability of the effect.

Return Type: FoodProperties

withEffect(effect as PossibleEffect) as FoodProperties
Creates a new food properties based on this instance, with the given effect.

Returns: The new food properties.

script.zs
// FoodProperties.withEffect(effect as FoodPropertiesPossibleEffect) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withEffect(myPossibleEffect);

Parameters:

effect Type: FoodPropertiesPossibleEffect - The effect to add.

Return Type: FoodProperties

withEffects(effects as List<PossibleEffect>) as FoodProperties
Creates a new food properties based on this instance, with the given effects.

Returns: The new food properties.

script.zs
// FoodProperties.withEffects(effects as List<FoodPropertiesPossibleEffect>) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withEffects(myList);

Parameters:

effects Type: List<FoodPropertiesPossibleEffect> - The new effects.

Return Type: FoodProperties

withNutrition(nutrition as int) as FoodProperties
Creates a new food properties based on this instance, with the given nutrition value.

Returns: The new food properties.

script.zs
// FoodProperties.withNutrition(nutrition as int) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withNutrition(myInt);

Parameters:

nutrition Type: int - The new nutrition value.

Return Type: FoodProperties

withoutEffect(effect as MobEffect) as FoodProperties
Creates a new food properties based on this instance, without the given effect.

Returns: The new food properties.

script.zs
// FoodProperties.withoutEffect(effect as MobEffect) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withoutEffect(myMobEffect);

Parameters:

effect Type: MobEffect - The effect to remove.

Return Type: FoodProperties

withoutEffect(effect as PossibleEffect) as FoodProperties
Creates a new food properties based on this instance, without the given effect.

Returns: The new food properties.

script.zs
// FoodProperties.withoutEffect(effect as FoodPropertiesPossibleEffect) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withoutEffect(myPossibleEffect);

Parameters:

effect Type: FoodPropertiesPossibleEffect - The effect to remove.

Return Type: FoodProperties

withSaturation(saturation as float) as FoodProperties
Creates a new food properties based on this instance, with the given saturation modifier.

Returns: The new food properties.

script.zs
// FoodProperties.withSaturation(saturation as float) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withSaturation(myFloat);

Parameters:

saturation Type: float - The new saturation modifier.

Return Type: FoodProperties

withUsingConvertsTo(usingConvertsTo as IItemStack) as FoodProperties
Creates a new food properties based on this instance, with the given using converts to value.

Returns: The new food properties.

script.zs
// FoodProperties.withUsingConvertsTo(usingConvertsTo as IItemStack) as FoodProperties;
FoodProperties.create(1, 1.0, true, 1.0).withUsingConvertsTo(myIItemStack);

Parameters:

usingConvertsTo Type: IItemStack - The new using converts to value.

Return Type: FoodProperties