From 49e74f4c54f934f83775aa0c3022fffbfe2f6872 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 16 Aug 2023 19:41:54 +0100 Subject: [PATCH] Use local velocity on the client (since other players don't send their velocity) --- .../unicopia/client/minelittlepony/Main.java | 2 +- .../minelittlepony/unicopia/entity/player/Motion.java | 4 ++++ .../unicopia/entity/player/PlayerPhysics.java | 9 +++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java index 62d63018..c5922d42 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java +++ b/src/main/java/com/minelittlepony/unicopia/client/minelittlepony/Main.java @@ -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(); diff --git a/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java b/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java index a0a400c8..b72b4060 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/Motion.java @@ -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(); } 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 d0b2b097..912d2eb6 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/player/PlayerPhysics.java @@ -94,6 +94,11 @@ public class PlayerPhysics extends EntityPhysics 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 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 implements Tickab } public double getHorizontalMotion() { - return lastVel.horizontalLengthSquared(); + return getClientVelocity().horizontalLengthSquared(); } @Override