@@ -1,12 +1,13 @@
|
||||
--- a/net/minecraft/world/food/FoodMetaData.java
|
||||
+++ b/net/minecraft/world/food/FoodMetaData.java
|
||||
@@ -7,15 +7,33 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -6,15 +6,34 @@
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.level.GameRules;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutUpdateHealth;
|
||||
+import net.minecraft.server.level.EntityPlayer;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class FoodMetaData {
|
||||
@@ -34,27 +35,29 @@
|
||||
+ // CraftBukkit end
|
||||
|
||||
private void add(int i, float f) {
|
||||
this.foodLevel = Math.min(i + this.foodLevel, 20);
|
||||
@@ -30,7 +48,17 @@
|
||||
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
|
||||
|
||||
if (foodinfo != null) {
|
||||
- this.add(foodinfo.nutrition(), foodinfo.saturation());
|
||||
+ // CraftBukkit start
|
||||
+ int oldFoodLevel = foodLevel;
|
||||
+
|
||||
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.nutrition() + oldFoodLevel, itemstack);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.add(event.getFoodLevel() - oldFoodLevel, foodinfo.saturation());
|
||||
+ }
|
||||
+
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.foodLevel = MathHelper.clamp(i + this.foodLevel, 0, 20);
|
||||
@@ -29,6 +48,20 @@
|
||||
this.add(foodinfo.nutrition(), foodinfo.saturation());
|
||||
}
|
||||
@@ -44,7 +72,15 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void eat(ItemStack itemstack, FoodInfo foodinfo) {
|
||||
+ int oldFoodLevel = foodLevel;
|
||||
+
|
||||
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.nutrition() + oldFoodLevel, itemstack);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.add(event.getFoodLevel() - oldFoodLevel, foodinfo.saturation());
|
||||
+ }
|
||||
+
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void tick(EntityHuman entityhuman) {
|
||||
EnumDifficulty enumdifficulty = entityhuman.level().getDifficulty();
|
||||
|
||||
@@ -38,7 +71,15 @@
|
||||
if (this.saturationLevel > 0.0F) {
|
||||
this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F);
|
||||
} else if (enumdifficulty != EnumDifficulty.PEACEFUL) {
|
||||
@@ -71,7 +74,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,23 +88,25 @@
|
||||
@@ -46,23 +87,25 @@
|
||||
|
||||
if (flag && this.saturationLevel > 0.0F && entityhuman.isHurt() && this.foodLevel >= 20) {
|
||||
++this.tickTimer;
|
||||
|
||||
Reference in New Issue
Block a user