From f8851980852c5676971cef08dc8cca1351b752b9 Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 29 Jan 2021 19:22:43 +0200 Subject: [PATCH] Fixed food levels going out of sync between the client and the server --- .../com/minelittlepony/unicopia/entity/player/Pony.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java index 7947b9cc..68917d1b 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Pony.java @@ -373,7 +373,7 @@ public class Pony implements Caster, Equine, Transmi @Override public boolean subtractEnergyCost(double foodSubtract) { - if (!entity.isCreative()) { + if (!entity.isCreative() && !entity.world.isClient) { float currentMana = mana.getMana().get(); float foodManaRatio = 10; @@ -384,13 +384,14 @@ public class Pony implements Caster, Equine, Transmi mana.getMana().set(0); foodSubtract -= currentMana / foodManaRatio; - int food = (int)(entity.getHungerManager().getFoodLevel() - foodSubtract); + int lostLevels = (int)Math.ceil(foodSubtract); + int food = entity.getHungerManager().getFoodLevel() - lostLevels; if (food < 0) { entity.getHungerManager().add(-entity.getHungerManager().getFoodLevel(), 0); entity.damage(MagicalDamageSource.EXHAUSTION, -food/2); } else { - entity.getHungerManager().add((int)-foodSubtract, 0); + entity.getHungerManager().add(-lostLevels, 0); } } }