From 8d296149af956154cbf04a26d1555f66a30df2b8 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Tue, 14 Jun 2016 21:37:41 -0400 Subject: [PATCH] Add some angle flight. Fully enabled while flying. Only when falling otherwise. --- .../mixin/MixinRenderPlayer.java | 45 +++++++++++++++++++ .../model/AbstractPonyModel.java | 4 ++ .../model/pony/ModelPlayerPony.java | 4 +- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java index b37e577f..799d06b4 100644 --- a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java @@ -6,6 +6,7 @@ import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.At.Shift; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -166,6 +167,50 @@ public abstract class MixinRenderPlayer extends RenderLivingBase 0) { + angle = 0; + } else { + angle /= 2; + } + } + if (player.moveForward < 0) { + angle *= -1; + } + + // if (player.motionY > 0.2 && dist < 1) { + // + // // TODO straight up/down + // angle = Math.signum(player.motionY) * Math.PI / 3; + // } + if (angle > Math.PI / 3) + angle = Math.PI / 3; + if (angle < -Math.PI / 3) + angle = -Math.PI / 3; + + this.playerModel.getModel().motionPitch = (float) Math.toDegrees(angle); + + GlStateManager.rotate((float) Math.toDegrees(angle), 1F, 0F, 0F); + + } + } + @Redirect( method = "rotateCorpse(Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V", at = @At( diff --git a/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java b/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java index a5b2e3a9..04ffd408 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java +++ b/src/main/java/com/brohoof/minelittlepony/model/AbstractPonyModel.java @@ -38,6 +38,7 @@ public abstract class AbstractPonyModel extends ModelPlayer { public boolean isSleeping; public PonyData metadata = new PonyData(); + public float motionPitch; protected List modelParts = Lists.newArrayList(); @@ -332,6 +333,9 @@ public abstract class AbstractPonyModel extends ModelPlayer { translate(0.0F, -0.535F, 0.25F); } } + if (part == BodyPart.HEAD) { + rotate(motionPitch, 1F, 0F, 0F); + } } @Override diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java index a37f5e6b..8f4961c1 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java @@ -184,8 +184,8 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst headRotateAngleX = vert / 57.29578F; } - final float max = 0.5f; - final float min = -1.25f; + final float max = (float) (0.5f - Math.toRadians(this.motionPitch)); + final float min = (float) (-1.25f - Math.toRadians(this.motionPitch)); headRotateAngleX = Math.min(headRotateAngleX, max); headRotateAngleX = Math.max(headRotateAngleX, min); this.bipedHead.rotateAngleY = headRotateAngleY;