mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-13 16:24:23 +01:00
Fixed funky rotations when swimming.
This commit is contained in:
parent
f1d1a2857d
commit
f80166dd99
2 changed files with 12 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue