Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9ed000
commit 34d46fe
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/org/auioc/mcmod/arnicalib/common/event/impl/LivingEatEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
|
||
} |