Fixed wings not responding to your velocity when jumping (whithout flying)

This commit is contained in:
Sollace 2021-08-25 14:01:49 +02:00
parent c3e854fdd1
commit dda6576731

View file

@ -61,6 +61,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
private int wallHitCooldown; private int wallHitCooldown;
private Vec3d lastPos = Vec3d.ZERO; private Vec3d lastPos = Vec3d.ZERO;
private Vec3d lastVel = Vec3d.ZERO;
private final PlayerDimensions dimensions; private final PlayerDimensions dimensions;
@ -108,7 +109,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
} }
} }
} else { } else {
spreadAmount += MathHelper.clamp(-getVerticalMotion(), 0, 2); spreadAmount += MathHelper.clamp(-lastVel.y, -0.3F, 2);
spreadAmount += Math.sin(entity.age / 9F) / 9F; spreadAmount += Math.sin(entity.age / 9F) / 9F;
if (entity.isSneaking()) { if (entity.isSneaking()) {
@ -147,11 +148,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
} }
private double getHorizontalMotion() { private double getHorizontalMotion() {
return entity.getPos().subtract(lastPos).horizontalLengthSquared(); return lastVel.horizontalLengthSquared();
}
private double getVerticalMotion() {
return entity.getPos().y - lastPos.y;
} }
@Override @Override
@ -165,6 +162,9 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
ticksToGlide--; ticksToGlide--;
} }
lastVel = entity.getPos().subtract(lastPos);
lastPos = entity.getPos();
final MutableVector velocity = new MutableVector(entity.getVelocity()); final MutableVector velocity = new MutableVector(entity.getVelocity());
if (isGravityNegative() && !entity.isSneaking() && entity.isInSneakingPose()) { if (isGravityNegative() && !entity.isSneaking() && entity.isInSneakingPose()) {
@ -273,8 +273,6 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
soundPlaying = false; soundPlaying = false;
} }
lastPos = entity.getPos();
if (!entity.isOnGround()) { if (!entity.isOnGround()) {
float heavyness = 1 - EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.015F; float heavyness = 1 - EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.015F;
velocity.x *= heavyness; velocity.x *= heavyness;