From bb0718bbd3c09074f21ff3a679fa1b9b4f1b64d2 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 21 Feb 2019 12:35:23 +0200 Subject: [PATCH] Rewrote flying to be easier to control --- .../player/PlayerGravityDelegate.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java b/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java index c7b7423c..e3007166 100644 --- a/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java +++ b/src/main/java/com/minelittlepony/unicopia/player/PlayerGravityDelegate.java @@ -134,11 +134,7 @@ class PlayerGravityDelegate implements IUpdatable, IGravity, InbtSerialisable, I entity.playSound(SoundEvents.ENTITY_GUARDIAN_FLOP, 1, 1); } - float forward = 0.00015F * flightExperience; - - entity.motionX += - forward * MathHelper.sin(entity.rotationYaw * 0.017453292F); - entity.motionY -= 0.05F - getHorizontalMotion(entity) / 100; - entity.motionZ += forward * MathHelper.cos(entity.rotationYaw * 0.017453292F); + moveFlying(entity); if (ticksInAir > 0 && ticksInAir % 12 == 0) { entity.playSound(USounds.WING_FLAP, 0.5F, 1); @@ -154,6 +150,22 @@ class PlayerGravityDelegate implements IUpdatable, IGravity, InbtSerialisable, I } } + protected void moveFlying(EntityPlayer player) { + + float forward = 0.00015F * flightExperience * player.moveForward; + + // vertical drop due to gravity + if (!player.isSneaking()) { + player.motionY -= 0.05F - getHorizontalMotion(player) / 100; + } else { + forward += 0.005F; + player.motionY -= 0.0005F; + } + + player.motionX += - forward * MathHelper.sin(player.rotationYaw * 0.017453292F); + player.motionZ += forward * MathHelper.cos(player.rotationYaw * 0.017453292F); + } + public void landHard(EntityPlayer player, float distance, float damageMultiplier) { if (distance <= 0) { return;