diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2014-11-26 08:32:16 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2014-11-28 17:16:30 +1100 |
commit | 24557bc2b37deb6a0edf497d547471832457b1dd (patch) | |
tree | c560572889a3b0b34964a0cddb35dc87fda3c914 /nms-patches/FoodMetaData.patch | |
parent | a4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff) | |
download | craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip |
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'nms-patches/FoodMetaData.patch')
-rw-r--r-- | nms-patches/FoodMetaData.patch | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/nms-patches/FoodMetaData.patch b/nms-patches/FoodMetaData.patch new file mode 100644 index 00000000..bfd974b3 --- /dev/null +++ b/nms-patches/FoodMetaData.patch @@ -0,0 +1,66 @@ +--- ../work/decompile-bb26c12b/net/minecraft/server/FoodMetaData.java 2014-11-27 08:59:46.753421618 +1100 ++++ src/main/java/net/minecraft/server/FoodMetaData.java 2014-11-27 08:42:10.104851005 +1100 +@@ -6,9 +6,17 @@ + public float saturationLevel = 5.0F; + public float exhaustionLevel; + public int foodTickTimer; ++ private EntityHuman entityhuman; // CraftBukkit + private int e = 20; + +- public FoodMetaData() {} ++ public FoodMetaData() { throw new AssertionError("Whoopsie, we missed the bukkit."); } // CraftBukkit start - throw an error ++ ++ // CraftBukkit start - added EntityHuman constructor ++ public FoodMetaData(EntityHuman entityhuman) { ++ org.apache.commons.lang.Validate.notNull(entityhuman); ++ this.entityhuman = entityhuman; ++ } ++ // CraftBukkit end + + public void eat(int i, float f) { + this.foodLevel = Math.min(i + this.foodLevel, 20); +@@ -16,7 +24,17 @@ + } + + public void a(ItemFood itemfood, ItemStack itemstack) { +- this.eat(itemfood.getNutrition(itemstack), itemfood.getSaturationModifier(itemstack)); ++ // CraftBukkit start ++ int oldFoodLevel = foodLevel; ++ ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, itemfood.getNutrition(itemstack) + oldFoodLevel); ++ ++ if (!event.isCancelled()) { ++ this.eat(event.getFoodLevel() - oldFoodLevel, itemfood.getSaturationModifier(itemstack)); ++ } ++ ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), entityhuman.getFoodData().foodLevel, entityhuman.getFoodData().saturationLevel)); ++ // CraftBukkit end + } + + public void a(EntityHuman entityhuman) { +@@ -28,14 +46,23 @@ + if (this.saturationLevel > 0.0F) { + this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); + } else if (enumdifficulty != EnumDifficulty.PEACEFUL) { +- this.foodLevel = Math.max(this.foodLevel - 1, 0); ++ // CraftBukkit start ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, Math.max(this.foodLevel - 1, 0)); ++ ++ if (!event.isCancelled()) { ++ this.foodLevel = event.getFoodLevel(); ++ } ++ ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutUpdateHealth(((EntityPlayer) entityhuman).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); ++ // CraftBukkit end + } + } + + if (entityhuman.world.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && entityhuman.cl()) { + ++this.foodTickTimer; + if (this.foodTickTimer >= 80) { +- entityhuman.heal(1.0F); ++ // CraftBukkit - added RegainReason ++ entityhuman.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); + this.a(3.0F); + this.foodTickTimer = 0; + } |