接口 FoodComponent

所有超级接口:
ConfigurationSerializable

@Experimental public interface FoodComponent extends ConfigurationSerializable
表示一个可以处理任何物品食物属性的组件。
注意:除非物品可以被消耗,否则具有食物属性的物品无效,参见 ConsumableComponent。
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
    获取此物品是否可以在不饥饿时食用。
    int
    获取食用此物品时恢复的食物值。
    float
    获取食用此物品时恢复的饱和度。
    void
    setCanAlwaysEat(boolean canAlwaysEat)
    设置此物品是否可以在不饥饿时食用。
    void
    setNutrition(int nutrition)
    设置食用此物品时恢复的食物值。
    void
    setSaturation(float saturation)
    设置食用此物品时恢复的饱和度。

    从接口继承的方法 org.bukkit.configuration.serialization.ConfigurationSerializable

    serialize
  • 方法详细资料

    • getNutrition

      int getNutrition()
      获取食用此物品时恢复的食物值。

      原文:Gets the food restored by this item when eaten.

      返回:
      营养值
    • setNutrition

      void setNutrition(int nutrition)
      设置食用此物品时恢复的食物值。

      原文:Sets the food restored by this item when eaten.

      参数:
      nutrition - 新的营养值,必须为非负数
    • getSaturation

      float getSaturation()
      获取食用此物品时恢复的饱和度。

      原文:Gets the saturation restored by this item when eaten.

      返回:
      饱和度值
    • setSaturation

      void setSaturation(float saturation)
      设置食用此物品时恢复的饱和度。

      原文:Sets the saturation restored by this item when eaten.

      参数:
      saturation - 新的饱和度值
    • canAlwaysEat

      boolean canAlwaysEat()
      获取此物品是否可以在不饥饿时食用。

      原文:Gets if this item can be eaten even when not hungry.

      返回:
      如果总是可食用则返回true
    • setCanAlwaysEat

      void setCanAlwaysEat(boolean canAlwaysEat)
      设置此物品是否可以在不饥饿时食用。

      原文:Sets if this item can be eaten even when not hungry.

      参数:
      canAlwaysEat - 是否总是可食用