2023-09-21 18:40:00 +02:00
|
|
|
--- a/net/minecraft/world/effect/SaturationMobEffect.java
|
|
|
|
+++ b/net/minecraft/world/effect/SaturationMobEffect.java
|
2024-12-11 22:26:55 +01:00
|
|
|
@@ -3,6 +3,10 @@
|
|
|
|
import net.minecraft.server.level.ServerLevel;
|
|
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
2023-09-21 18:40:00 +02:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+// CraftBukkit end
|
|
|
|
|
2024-12-11 22:26:55 +01:00
|
|
|
class SaturationMobEffect extends InstantenousMobEffect {
|
|
|
|
|
|
|
|
@@ -13,7 +17,15 @@
|
2024-04-23 17:15:00 +02:00
|
|
|
@Override
|
2024-12-11 22:26:55 +01:00
|
|
|
public boolean applyEffectTick(ServerLevel world, LivingEntity entity, int amplifier) {
|
|
|
|
if (entity instanceof Player entityhuman) {
|
|
|
|
- entityhuman.getFoodData().eat(amplifier + 1, 1.0F);
|
2023-09-21 18:40:00 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
2024-12-11 22:26:55 +01:00
|
|
|
+ org.bukkit.event.entity.FoodLevelChangeEvent event = CraftEventFactory.callFoodLevelChangeEvent(entityhuman, amplifier + 1 + oldFoodLevel);
|
2023-09-21 18:40:00 +02:00
|
|
|
+ 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;
|