-
Notifications
You must be signed in to change notification settings - Fork 0
/
LivingEatEvent.java
46 lines (36 loc) · 1.36 KB
/
LivingEatEvent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.auioc.mcmod.arnicalib.common.event.impl;
import org.auioc.mcmod.arnicalib.api.game.event.FoodDataEvent;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.Cancelable;
@Cancelable
public class LivingEatEvent extends FoodDataEvent {
private final ItemStack foodItemStack;
private int nutrition = 0;
private float saturationModifier = 0.0F;
public LivingEatEvent(LivingEntity living, FoodData foodData, ItemStack foodItemStack) {
super(living, foodData);
this.foodItemStack = foodItemStack;
if (foodItemStack.isEdible()) {
var foodProperties = foodItemStack.getFoodProperties(living);
this.nutrition = foodProperties.getNutrition();
this.saturationModifier = foodProperties.getSaturationModifier();
}
}
public ItemStack getFoodItemStack() {
return this.foodItemStack;
}
public int getNutrition() {
return this.nutrition;
}
public float getSaturationModifier() {
return this.saturationModifier;
}
public void setNutrition(int nutrition) {
this.nutrition = nutrition;
}
public void setSaturationModifier(float saturationModifier) {
this.saturationModifier = saturationModifier;
}
}