mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Fixed food levels going out of sync between the client and the server
This commit is contained in:
parent
8f654177ec
commit
f885198085
1 changed files with 4 additions and 3 deletions
|
@ -373,7 +373,7 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean subtractEnergyCost(double foodSubtract) {
|
public boolean subtractEnergyCost(double foodSubtract) {
|
||||||
if (!entity.isCreative()) {
|
if (!entity.isCreative() && !entity.world.isClient) {
|
||||||
|
|
||||||
float currentMana = mana.getMana().get();
|
float currentMana = mana.getMana().get();
|
||||||
float foodManaRatio = 10;
|
float foodManaRatio = 10;
|
||||||
|
@ -384,13 +384,14 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
||||||
mana.getMana().set(0);
|
mana.getMana().set(0);
|
||||||
foodSubtract -= currentMana / foodManaRatio;
|
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) {
|
if (food < 0) {
|
||||||
entity.getHungerManager().add(-entity.getHungerManager().getFoodLevel(), 0);
|
entity.getHungerManager().add(-entity.getHungerManager().getFoodLevel(), 0);
|
||||||
entity.damage(MagicalDamageSource.EXHAUSTION, -food/2);
|
entity.damage(MagicalDamageSource.EXHAUSTION, -food/2);
|
||||||
} else {
|
} else {
|
||||||
entity.getHungerManager().add((int)-foodSubtract, 0);
|
entity.getHungerManager().add(-lostLevels, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue