mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-23 08:46:44 +01:00
a265d64138
By: Initial <noreply+automated@papermc.io>
31 lines
1.3 KiB
Diff
31 lines
1.3 KiB
Diff
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
|
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
|
@@ -4,6 +4,11 @@
|
|
import net.minecraft.world.entity.EntityLiving;
|
|
import net.minecraft.world.entity.player.EntityHuman;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
+// CraftBukkit end
|
|
+
|
|
class SaturationMobEffect extends InstantMobEffect {
|
|
|
|
protected SaturationMobEffect(MobEffectInfo mobeffectinfo, int i) {
|
|
@@ -13,7 +18,15 @@
|
|
@Override
|
|
public boolean applyEffectTick(WorldServer worldserver, EntityLiving entityliving, int i) {
|
|
if (entityliving instanceof EntityHuman entityhuman) {
|
|
- entityhuman.getFoodData().eat(i + 1, 1.0F);
|
|
+ // CraftBukkit start
|
|
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
|
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, i + 1 + oldFoodLevel);
|
|
+ if (!event.isCancelled()) {
|
|
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 1.0F);
|
|
+ }
|
|
+
|
|
+ ((CraftPlayer) entityhuman.getBukkitEntity()).sendHealthUpdate();
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
return true;
|