一,这里同样需要一个物品,以EXAMPLE_ITEM_02为例
二.创建一个FoodProperties对象
public static final FoodProperties FOOD_PROPERTIES = new FoodProperties.Builder()
.saturationMod(10) //饱食度恢复速度
.nutrition(2) //进食恢复饱食度
.alwaysEat() //满饥饿使用
.effect(()-> new MobEffectInstance(MobEffects.JUMP,10*20,10),1.0f) //四个参数分别为效果,时间,等级,发生概率
.build();
三.将属性传递给Item
将之前创建的FoodProperties对象传递给properties
public static final DeferredHolder<Item, Item> EXAMPLE_ITEM_02 = ITEMS.register("example_item_02",
() -> new Item(new Item.Properties().food(FOOD_PROPERTIES)));