mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Smooth out consumption of food levels/fix food consumption being roudned UP
This commit is contained in:
parent
f885198085
commit
186d7cdbee
1 changed files with 25 additions and 9 deletions
|
@ -92,6 +92,8 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
|
||||
private int ticksHanging;
|
||||
|
||||
private float magicExhaustion = 0;
|
||||
|
||||
@Nullable
|
||||
private Race clientPreferredRace;
|
||||
|
||||
|
@ -255,6 +257,8 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
}
|
||||
}
|
||||
|
||||
magicExhaustion = burnFood(magicExhaustion);
|
||||
|
||||
powers.tick();
|
||||
|
||||
return false;
|
||||
|
@ -384,7 +388,16 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
mana.getMana().set(0);
|
||||
foodSubtract -= currentMana / foodManaRatio;
|
||||
|
||||
int lostLevels = (int)Math.ceil(foodSubtract);
|
||||
magicExhaustion += foodSubtract;
|
||||
}
|
||||
}
|
||||
|
||||
return entity.getHealth() > 0;
|
||||
}
|
||||
|
||||
private float burnFood(float foodSubtract) {
|
||||
int lostLevels = (int)Math.floor(foodSubtract);
|
||||
if (lostLevels > 0) {
|
||||
int food = entity.getHungerManager().getFoodLevel() - lostLevels;
|
||||
|
||||
if (food < 0) {
|
||||
|
@ -394,9 +407,8 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
entity.getHungerManager().add(-lostLevels, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return entity.getHealth() > 0;
|
||||
return foodSubtract - lostLevels;
|
||||
}
|
||||
|
||||
public Optional<Text> trySleep(BlockPos pos) {
|
||||
|
@ -416,6 +428,8 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
public void toNBT(CompoundTag compound) {
|
||||
compound.putString("playerSpecies", getSpecies().name());
|
||||
|
||||
compound.putFloat("magicExhaustion", magicExhaustion);
|
||||
|
||||
compound.put("powers", powers.toNBT());
|
||||
compound.put("gravity", gravity.toNBT());
|
||||
|
||||
|
@ -434,6 +448,8 @@ public class Pony implements Caster<PlayerEntity>, Equine<PlayerEntity>, Transmi
|
|||
powers.fromNBT(compound.getCompound("powers"));
|
||||
gravity.fromNBT(compound.getCompound("gravity"));
|
||||
|
||||
magicExhaustion = compound.getFloat("magicExhaustion");
|
||||
|
||||
if (compound.contains("effect")) {
|
||||
effectDelegate.set(SpellRegistry.instance().createEffectFromNBT(compound.getCompound("effect")));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue