Increase energy cost when flying over the void. Fixes #356

This commit is contained in:
Sollace 2024-05-19 00:17:34 +01:00
parent 2cdce6504c
commit 715519e1f1
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
2 changed files with 19 additions and 7 deletions

View file

@ -393,7 +393,9 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
private void tickGrounded() { private void tickGrounded() {
prevStrafe = 0; prevStrafe = 0;
strafe = 0; strafe = 0;
ticksInAir = 0; if (entity.isOnGround()) {
ticksInAir = 0;
}
wallHitCooldown = MAX_WALL_HIT_CALLDOWN; wallHitCooldown = MAX_WALL_HIT_CALLDOWN;
soundPlaying = false; soundPlaying = false;
descentRate = 0; descentRate = 0;
@ -524,9 +526,15 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
mana.add(MathHelper.clamp(cost, -100, 0)); mana.add(MathHelper.clamp(cost, -100, 0));
if (mana.getPercentFill() < 0.2) { boolean overVoid = PosHelper.isOverVoid(pony.asWorld(), pony.getOrigin(), getGravitySignum());
pony.getMagicalReserves().getExertion().addPercent(2);
pony.getMagicalReserves().getExhaustion().add(2 + (int)(getHorizontalMotion() * 50)); if (overVoid) {
mana.addPercent(-2);
}
if (mana.getPercentFill() < (overVoid ? 0.4F : 0.2F)) {
pony.getMagicalReserves().getExertion().addPercent(overVoid ? 4 : 2);
pony.getMagicalReserves().getExhaustion().add((overVoid ? 4 : 0) + 2 + (int)(getHorizontalMotion() * 50));
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) { if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
float exhaustion = (0.3F * ticksInAir) / 70; float exhaustion = (0.3F * ticksInAir) / 70;
@ -537,10 +545,10 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
entity.addExhaustion(exhaustion); entity.addExhaustion(exhaustion);
} }
if (pony.getMagicalReserves().getExhaustion().get() > 99 && ticksInAir % 25 == 0) { if (pony.getMagicalReserves().getExhaustion().getPercentFill() > 0.99F && ticksInAir % 25 == 0 && !pony.isClient()) {
entity.damage(pony.damageOf(UDamageTypes.EXHAUSTION), 2); entity.damage(pony.damageOf(UDamageTypes.EXHAUSTION), entity.getWorld().random.nextBetween(2, 4));
if (entity.getWorld().random.nextInt(110) == 1 && !pony.isClient()) { if (entity.getWorld().random.nextInt(110) == 1) {
pony.getLevel().add(1); pony.getLevel().add(1);
if (Abilities.RAINBOOM.canUse(pony.getCompositeRace())) { if (Abilities.RAINBOOM.canUse(pony.getCompositeRace())) {
pony.getMagicalReserves().getCharge().addPercent(4); pony.getMagicalReserves().getCharge().addPercent(4);

View file

@ -37,6 +37,10 @@ public interface PosHelper {
return mutable.toImmutable(); return mutable.toImmutable();
} }
static boolean isOverVoid(World world, BlockPos pos, int signum) {
return signum > 0 && findSolidGroundAt(world, pos, signum).getY() < world.getBottomY();
}
static void fastAll(BlockPos origin, Consumer<BlockPos.Mutable> consumer, Direction... directions) { static void fastAll(BlockPos origin, Consumer<BlockPos.Mutable> consumer, Direction... directions) {
final BlockPos immutable = origin instanceof BlockPos.Mutable m ? m.toImmutable() : origin; final BlockPos immutable = origin instanceof BlockPos.Mutable m ? m.toImmutable() : origin;
final BlockPos.Mutable mutable = origin instanceof BlockPos.Mutable m ? m : origin.mutableCopy(); final BlockPos.Mutable mutable = origin instanceof BlockPos.Mutable m ? m : origin.mutableCopy();