程序包 org.bukkit.inventory.meta.components

# 接口 FoodComponent

所有超级接口:
  `ConfigurationSerializable`

@Experimental public interface FoodComponent extends ConfigurationSerializable
Represents a component which can turn any item into food.

- ## 嵌套类概要

  嵌套类
  修饰符和类型
  接口
  说明
  `static interface`
  `FoodComponent.FoodEffect`
  An effect which may be applied by this item when eaten.

- ## 方法概要

  修饰符和类型
  方法
  说明
  `@NotNull FoodComponent.FoodEffect`
  `addEffect(@NotNull PotionEffect effect, float probability)`
  Adds an effect which may be applied by this item when eaten.
  `boolean`
  `canAlwaysEat()`
  Gets if this item can be eaten even when not hungry.
  `float`
  `getEatSeconds()`
  Gets the time in seconds it will take for this item to be eaten.
  `@NotNull List<FoodComponent.FoodEffect>`
  `getEffects()`
  Gets the effects which may be applied by this item when eaten.
  `int`
  `getNutrition()`
  Gets the food restored by this item when eaten.
  `float`
  `getSaturation()`
  Gets the saturation restored by this item when eaten.
  `@Nullable ItemStack`
  `getUsingConvertsTo()`
  Gets the item this food will convert to once eaten.
  `void`
  `setCanAlwaysEat(boolean canAlwaysEat)`
  Sets if this item can be eaten even when not hungry.
  `void`
  `setEatSeconds(float eatSeconds)`
  Sets the time in seconds it will take for this item to be eaten.
  `void`
  `setEffects(@NotNull List<FoodComponent.FoodEffect> effects)`
  Sets the effects which may be applied by this item when eaten.
  `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.
  `void`
  `setUsingConvertsTo(@Nullable ItemStack item)`
  Sets the item this food will convert to once eaten.

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

  `serialize`

- ## 方法详细资料

  - ### getNutrition

    int getNutrition()
    Gets the food restored by this item when eaten.
    返回:
      nutrition value

  - ### setNutrition

    void setNutrition(int nutrition)
    Sets the food restored by this item when eaten.
    参数:
      `nutrition` - new nutrition value, must be non-negative

  - ### getSaturation

    float getSaturation()
    Gets the saturation restored by this item when eaten.
    返回:
      saturation value

  - ### setSaturation

    void setSaturation(float saturation)
    Sets the saturation restored by this item when eaten.
    参数:
      `saturation` - new saturation value

  - ### canAlwaysEat

    boolean canAlwaysEat()
    Gets if this item can be eaten even when not hungry.
    返回:
      true if always edible

  - ### setCanAlwaysEat

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

  - ### getEatSeconds

    float getEatSeconds()
    Gets the time in seconds it will take for this item to be eaten.
    返回:
      eat time

  - ### setEatSeconds

    void setEatSeconds(float eatSeconds)
    Sets the time in seconds it will take for this item to be eaten.
    参数:
      `eatSeconds` - new eat time

  - ### getUsingConvertsTo

    @Nullable @Nullable ItemStack getUsingConvertsTo()
    Gets the item this food will convert to once eaten.
    返回:
      converted item

  - ### setUsingConvertsTo

    void setUsingConvertsTo(@Nullable @Nullable ItemStack item)
    Sets the item this food will convert to once eaten.
    参数:
      `item` - converted item

  - ### getEffects

    @NotNull @NotNull List<FoodComponent.FoodEffect> getEffects()
    Gets the effects which may be applied by this item when eaten.
    返回:
      food effects

  - ### setEffects

    void setEffects(@NotNull @NotNull List<FoodComponent.FoodEffect> effects)
    Sets the effects which may be applied by this item when eaten.
    参数:
      `effects` - new effects

  - ### addEffect

    @NotNull @NotNull FoodComponent.FoodEffect addEffect(@NotNull @NotNull PotionEffect effect, float probability)
    Adds an effect which may be applied by this item when eaten.
    参数:
      `effect` - the effect
      `probability` - the probability of the effect being applied
    返回:
      the added effect