diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/food/FoodData.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/food/FoodData.java.patch | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/food/FoodData.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/food/FoodData.java.patch new file mode 100644 index 0000000000..7c9248adc9 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/food/FoodData.java.patch @@ -0,0 +1,109 @@ +--- a/net/minecraft/world/food/FoodData.java ++++ b/net/minecraft/world/food/FoodData.java +@@ -12,11 +15,22 @@ + private float saturationLevel; + private float exhaustionLevel; + private int tickTimer; ++ // CraftBukkit start ++ private Player entityhuman; ++ public int saturatedRegenRate = 10; ++ public int unsaturatedRegenRate = 80; ++ public int starvationRate = 80; ++ // CraftBukkit end + private int lastFoodLevel = 20; + +- public FoodData() { +- this.saturationLevel = 5.0F; ++ public FoodData() { throw new AssertionError("Whoopsie, we missed the bukkit."); } // CraftBukkit start - throw an error ++ ++ // CraftBukkit start - added EntityHuman constructor ++ public FoodData(Player entityhuman) { ++ org.apache.commons.lang.Validate.notNull(entityhuman); ++ this.entityhuman = entityhuman; + } ++ // CraftBukkit end + + public void eat(int foodLevelModifier, float saturationLevelModifier) { + this.foodLevel = Math.min(foodLevelModifier + this.foodLevel, 20); +@@ -25,8 +39,18 @@ + + public void eat(Item item, ItemStack stack) { + if (item.isEdible()) { +- FoodProperties foodProperties = item.getFoodProperties(); +- this.eat(foodProperties.getNutrition(), foodProperties.getSaturationModifier()); ++ FoodProperties foodinfo = item.getFoodProperties(); ++ // CraftBukkit start ++ int oldFoodLevel = foodLevel; ++ ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, foodinfo.getNutrition() + oldFoodLevel, stack); ++ ++ if (!event.isCancelled()) { ++ this.eat(event.getFoodLevel() - oldFoodLevel, foodinfo.getSaturationModifier()); ++ } ++ ++ ((ServerPlayer) entityhuman).getBukkitEntity().sendHealthUpdate(); ++ // CraftBukkit end + } + } + +@@ -37,31 +63,43 @@ + this.exhaustionLevel -= 4.0F; + if (this.saturationLevel > 0.0F) { + this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); +- } else if (difficulty != Difficulty.PEACEFUL) { +- this.foodLevel = Math.max(this.foodLevel - 1, 0); ++ } else if (enumdifficulty != Difficulty.PEACEFUL) { ++ // CraftBukkit start ++ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(player, Math.max(this.foodLevel - 1, 0)); ++ ++ if (!event.isCancelled()) { ++ this.foodLevel = event.getFoodLevel(); ++ } ++ ++ ((ServerPlayer) player).connection.send(new ClientboundSetHealthPacket(((ServerPlayer) player).getBukkitEntity().getScaledHealth(), this.foodLevel, this.saturationLevel)); ++ // CraftBukkit end + } + } + +- boolean _boolean = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); +- if (_boolean && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { +- this.tickTimer++; +- if (this.tickTimer >= 10) { +- float min = Math.min(this.saturationLevel, 6.0F); +- player.heal(min / 6.0F); +- this.addExhaustion(min); ++ boolean flag = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); ++ ++ if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { ++ ++this.tickTimer; ++ if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit ++ float f = Math.min(this.saturationLevel, 6.0F); ++ ++ player.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason ++ // this.addExhaustion(f); CraftBukkit - EntityExhaustionEvent ++ player.causeFoodExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent + this.tickTimer = 0; + } +- } else if (_boolean && this.foodLevel >= 18 && player.isHurt()) { +- this.tickTimer++; +- if (this.tickTimer >= 80) { +- player.heal(1.0F); +- this.addExhaustion(6.0F); ++ } else if (flag && this.foodLevel >= 18 && player.isHurt()) { ++ ++this.tickTimer; ++ if (this.tickTimer >= this.unsaturatedRegenRate) { // CraftBukkit - add regen rate manipulation ++ player.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason ++ // this.a(6.0F); CraftBukkit - EntityExhaustionEvent ++ player.causeFoodExhaustion(6.0f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent + this.tickTimer = 0; + } + } else if (this.foodLevel <= 0) { +- this.tickTimer++; +- if (this.tickTimer >= 80) { +- if (player.getHealth() > 10.0F || difficulty == Difficulty.HARD || player.getHealth() > 1.0F && difficulty == Difficulty.NORMAL) { ++ ++this.tickTimer; ++ if (this.tickTimer >= this.starvationRate) { // CraftBukkit - add regen rate manipulation ++ if (player.getHealth() > 10.0F || enumdifficulty == Difficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == Difficulty.NORMAL) { + player.hurt(player.damageSources().starve(), 1.0F); + } + |