2023-09-21 18:40:00 +02:00
|
|
|
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
|
|
|
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
|
|
|
@@ -3,6 +3,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) {
|
2024-04-23 17:15:00 +02:00
|
|
|
@@ -12,7 +17,15 @@
|
|
|
|
@Override
|
|
|
|
public boolean applyEffectTick(EntityLiving entityliving, int i) {
|
|
|
|
if (!entityliving.level().isClientSide && entityliving instanceof EntityHuman entityhuman) {
|
2023-09-21 18:40:00 +02:00
|
|
|
- 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
|
|
|
|
}
|
|
|
|
|
2024-04-23 17:15:00 +02:00
|
|
|
return true;
|