From dda6576731a5ebd08e434c1a07c590ad9dbd0db7 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 25 Aug 2021 14:01:49 +0200 Subject: [PATCH] Fixed wings not responding to your velocity when jumping (whithout flying) --- .../unicopia/entity/player/PlayerPhysics.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java index 0a133da2..d7d44da8 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -61,6 +61,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab private int wallHitCooldown; private Vec3d lastPos = Vec3d.ZERO; + private Vec3d lastVel = Vec3d.ZERO; private final PlayerDimensions dimensions; @@ -108,7 +109,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } } } else { - spreadAmount += MathHelper.clamp(-getVerticalMotion(), 0, 2); + spreadAmount += MathHelper.clamp(-lastVel.y, -0.3F, 2); spreadAmount += Math.sin(entity.age / 9F) / 9F; if (entity.isSneaking()) { @@ -147,11 +148,7 @@ public class PlayerPhysics extends EntityPhysics implements Tickab } private double getHorizontalMotion() { - return entity.getPos().subtract(lastPos).horizontalLengthSquared(); - } - - private double getVerticalMotion() { - return entity.getPos().y - lastPos.y; + return lastVel.horizontalLengthSquared(); } @Override @@ -165,6 +162,9 @@ public class PlayerPhysics extends EntityPhysics implements Tickab ticksToGlide--; } + lastVel = entity.getPos().subtract(lastPos); + lastPos = entity.getPos(); + final MutableVector velocity = new MutableVector(entity.getVelocity()); if (isGravityNegative() && !entity.isSneaking() && entity.isInSneakingPose()) { @@ -273,8 +273,6 @@ public class PlayerPhysics extends EntityPhysics implements Tickab soundPlaying = false; } - lastPos = entity.getPos(); - if (!entity.isOnGround()) { float heavyness = 1 - EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.015F; velocity.x *= heavyness;