From f80166dd99b99ec5053867c928cbd030917d56da Mon Sep 17 00:00:00 2001 From: Sollace Date: Fri, 5 Jul 2019 11:00:41 +0200 Subject: [PATCH] Fixed funky rotations when swimming. --- .../client/transform/PostureSwimming.java | 10 ++++++---- .../util/transform/MotionCompositor.java | 6 ++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java b/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java index 58cd4e36..168acddb 100644 --- a/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java +++ b/src/main/java/com/minelittlepony/client/transform/PostureSwimming.java @@ -2,7 +2,7 @@ package com.minelittlepony.client.transform; import net.minecraft.entity.player.PlayerEntity; -import com.minelittlepony.util.math.MathUtil; +import com.minelittlepony.model.IModel; import com.mojang.blaze3d.platform.GlStateManager; public class PostureSwimming extends PostureFlight { @@ -17,10 +17,12 @@ public class PostureSwimming extends PostureFlight { @Override protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) { - double motionLerp = MathUtil.clampLimit(Math.sqrt(motionX * motionX + motionZ * motionZ) * 30, 1) / 2; + return 90; // mojang handles this + } + @Override + public void transform(IModel model, PlayerEntity player, double motionX, double motionY, double motionZ, float yaw, float ticks) { GlStateManager.translated(0, 0.9, -1); - - return 90 + super.calculateIncline(player, motionX, motionY, motionZ) * motionLerp; + super.transform(model, player, motionX, motionY, motionZ, yaw, ticks); } } diff --git a/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java b/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java index b639a161..3643f332 100644 --- a/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java +++ b/src/main/java/com/minelittlepony/util/transform/MotionCompositor.java @@ -12,6 +12,9 @@ import com.minelittlepony.util.math.MathUtil; */ public abstract class MotionCompositor { + /** + * Gets the angle of horizontal roll in degrees based on the player's vertical and horizontal motion. + */ protected double calculateRoll(PlayerEntity player, double motionX, double motionY, double motionZ) { // since model roll should probably be calculated from model rotation rather than entity rotation... @@ -36,6 +39,9 @@ public abstract class MotionCompositor { return MathHelper.clamp(roll, -54, 54); } + /** + * Gets the angle of inclination in degrees based on the player's vertical and horizontal motion. + */ protected double calculateIncline(PlayerEntity player, double motionX, double motionY, double motionZ) { double dist = Math.sqrt(motionX * motionX + motionZ * motionZ); double angle = Math.atan2(motionY, dist);