Use local velocity on the client (since other players don't send their velocity)

This commit is contained in:
Sollace 2023-08-16 19:41:54 +01:00
parent 50f3df37a2
commit 49e74f4c54
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 12 additions and 3 deletions

View file

@ -44,7 +44,7 @@ public class Main extends MineLPDelegate implements ClientModInitializer {
if (pony.getMotion().isFlying()) {
model.getAttributes().wingAngle = MathHelper.clamp(pony.getMotion().getWingAngle() / 3F - (float)Math.PI * 0.4F, -2, 0);
Vec3d motion = entity.getVelocity();
Vec3d motion = pony.getMotion().getClientVelocity();
double zMotion = Math.sqrt(motion.x * motion.x + motion.z * motion.z);
model.getAttributes().isGoingFast |= zMotion > 0.4F;
model.getAttributes().isGoingFast |= pony.getMotion().isDiving();

View file

@ -1,5 +1,7 @@
package com.minelittlepony.unicopia.entity.player;
import net.minecraft.util.math.Vec3d;
/**
* Interface for controlling flight.
*/
@ -18,4 +20,6 @@ public interface Motion {
float getWingAngle();
PlayerDimensions getDimensions();
Vec3d getClientVelocity();
}

View file

@ -94,6 +94,11 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
return dimensions;
}
@Override
public Vec3d getClientVelocity() {
return lastVel;
}
public final float getPersistantGravityModifier() {
return super.getGravityModifier();
}
@ -133,7 +138,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
@Override
public boolean isRainbooming() {
return pony.getSpellSlot().get(SpellType.RAINBOOM, true).isPresent();
return SpellType.RAINBOOM.isOn(pony);
}
@Override
@ -208,7 +213,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
}
public double getHorizontalMotion() {
return lastVel.horizontalLengthSquared();
return getClientVelocity().horizontalLengthSquared();
}
@Override