Interface FoodComponent

All Superinterfaces:
ConfigurationSerializable

@Experimental public interface FoodComponent extends ConfigurationSerializable
Represents a component which can handle food stats in any item.
Note: Items with food stats has no effect unless the item can be consumed, see ConsumableComponent.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    boolean
    Gets if this item can be eaten even when not hungry.
    int
    Gets the food restored by this item when eaten.
    float
    Gets the saturation restored by this item when eaten.
    void
    setCanAlwaysEat(boolean canAlwaysEat)
    Sets if this item can be eaten even when not hungry.
    void
    setNutrition(int nutrition)
    Sets the food restored by this item when eaten.
    void
    setSaturation(float saturation)
    Sets the saturation restored by this item when eaten.

    Methods inherited from interface org.bukkit.configuration.serialization.ConfigurationSerializable Link icon

    serialize
  • Method Details Link icon

    • getNutrition Link icon

      int getNutrition()
      Gets the food restored by this item when eaten.
      Returns:
      nutrition value
    • setNutrition Link icon

      void setNutrition(int nutrition)
      Sets the food restored by this item when eaten.
      Parameters:
      nutrition - new nutrition value, must be non-negative
    • getSaturation Link icon

      float getSaturation()
      Gets the saturation restored by this item when eaten.
      Returns:
      saturation value
    • setSaturation Link icon

      void setSaturation(float saturation)
      Sets the saturation restored by this item when eaten.
      Parameters:
      saturation - new saturation value
    • canAlwaysEat Link icon

      boolean canAlwaysEat()
      Gets if this item can be eaten even when not hungry.
      Returns:
      true if always edible
    • setCanAlwaysEat Link icon

      void setCanAlwaysEat(boolean canAlwaysEat)
      Sets if this item can be eaten even when not hungry.
      Parameters:
      canAlwaysEat - whether always edible