mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Add some angle flight. Fully enabled while flying. Only when falling otherwise.
This commit is contained in:
parent
f8bdd14322
commit
8d296149af
3 changed files with 51 additions and 2 deletions
|
@ -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<AbstractClientP
|
|||
return this.playerModel.getModel().steveRightArmwear;
|
||||
}
|
||||
|
||||
@Inject(
|
||||
method = "rotateCorpse(Lnet/minecraft/client/entity/AbstractClientPlayer;FFF)V",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/client/renderer/entity/RenderLivingBase;"
|
||||
+ "rotateCorpse(Lnet/minecraft/entity/EntityLivingBase;FFF)V",
|
||||
ordinal = 1,
|
||||
shift = Shift.AFTER))
|
||||
private void onRotateCorpse(AbstractClientPlayer player, float yaw, float pitch, float ticks, CallbackInfo ci) {
|
||||
if (this.mainModel instanceof ModelPlayerPony) {
|
||||
double motionY = player.motionY;
|
||||
if (player.onGround) {
|
||||
motionY = 0;
|
||||
}
|
||||
double dist = Math.sqrt(player.motionX * player.motionX + player.motionZ * player.motionZ);
|
||||
double angle = Math.atan2(motionY, dist);
|
||||
if (!player.capabilities.isFlying) {
|
||||
if (angle > 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(
|
||||
|
|
|
@ -38,6 +38,7 @@ public abstract class AbstractPonyModel extends ModelPlayer {
|
|||
public boolean isSleeping;
|
||||
|
||||
public PonyData metadata = new PonyData();
|
||||
public float motionPitch;
|
||||
|
||||
protected List<IPonyPart> 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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue