Clean up elytra code

This commit is contained in:
Sollace 2018-04-27 09:46:44 +02:00
parent 36ee3966d7
commit 17624c484a

View file

@ -1,6 +1,5 @@
package com.minelittlepony.model.components;
import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.render.PonyRenderer;
import net.minecraft.client.entity.AbstractClientPlayer;
@ -10,6 +9,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.math.Vec3d;
import static com.minelittlepony.model.PonyModelConstants.*;
/**
* Modified from ModelElytra.
*/
public class PonyElytra extends ModelBase {
private PonyRenderer rightWing = new PonyRenderer(this, 22, 0);
private PonyRenderer leftWing = new PonyRenderer(this, 22, 0);
@ -28,55 +32,56 @@ public class PonyElytra extends ModelBase {
}
@Override
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entity) {
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entity);
final float PI = (float) Math.PI;
float rotateX = PI / 2F;
float rotateY = PI / 8F;
float rotateX = PI / 2;
float rotateY = PI / 8;
float rotateZ = PI / 12;
float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK;
if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).isElytraFlying()) {
float f4 = 1;
if (entityIn.motionY < 0) {
Vec3d vec3d = (new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ)).normalize();
f4 = 1 - (float) Math.pow(-vec3d.y, 1.5);
float rpY = BODY_RP_Y_NOTSNEAK;
if (entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isElytraFlying()) {
float velY = 1;
if (entity.motionY < 0) {
Vec3d motion = (new Vec3d(entity.motionX, entity.motionY, entity.motionZ)).normalize();
velY = 1 - (float) Math.pow(-motion.y, 1.5);
}
rotateX = f4 * PI * (2 / 3F) + (1 - f4) * rotateX;
rotateY = f4 * ((float) Math.PI / 2F) + (1 - f4) * rotateY;
} else if (entityIn.isSneaking()) {
rotateX = ((float) Math.PI * 1.175F);
rotateX = velY * PI * (2 / 3F) + (1 - velY) * rotateX;
rotateY = velY * (PI / 2) + (1 - velY) * rotateY;
} else if (entity.isSneaking()) {
rotateX = PI * 1.175F;
rotateY = PI / 2;
rpY = PonyModelConstants.BODY_RP_Y_SNEAK;
rotateZ = PI / 4F;
rotateZ = PI / 4;
rpY = BODY_RP_Y_SNEAK;
}
this.leftWing.rotationPointX = 5;
this.leftWing.rotationPointY = rpY;
leftWing.rotationPointX = 5;
leftWing.rotationPointY = rpY;
if (entityIn instanceof AbstractClientPlayer) {
AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer) entityIn;
abstractclientplayer.rotateElytraX = (float) (abstractclientplayer.rotateElytraX + (rotateX - abstractclientplayer.rotateElytraX) * 0.1D);
abstractclientplayer.rotateElytraY = (float) (abstractclientplayer.rotateElytraY + (rotateY - abstractclientplayer.rotateElytraY) * 0.1D);
abstractclientplayer.rotateElytraZ = (float) (abstractclientplayer.rotateElytraZ + (rotateZ - abstractclientplayer.rotateElytraZ) * 0.1D);
this.leftWing.rotateAngleX = abstractclientplayer.rotateElytraX;
this.leftWing.rotateAngleY = abstractclientplayer.rotateElytraY;
this.leftWing.rotateAngleZ = abstractclientplayer.rotateElytraZ;
if (entity instanceof AbstractClientPlayer) {
AbstractClientPlayer player = (AbstractClientPlayer) entity;
player.rotateElytraX += (rotateX - player.rotateElytraX) / 10;
player.rotateElytraY += (rotateY - player.rotateElytraY) / 10;
player.rotateElytraZ += (rotateZ - player.rotateElytraZ) / 10;
leftWing.rotateAngleX = player.rotateElytraX;
leftWing.rotateAngleY = player.rotateElytraY;
leftWing.rotateAngleZ = player.rotateElytraZ;
} else {
this.leftWing.rotateAngleX = rotateX;
this.leftWing.rotateAngleZ = rotateZ;
this.leftWing.rotateAngleY = rotateY;
leftWing.rotateAngleX = rotateX;
leftWing.rotateAngleZ = rotateZ;
leftWing.rotateAngleY = rotateY;
}
this.rightWing.rotationPointX = -this.leftWing.rotationPointX;
this.rightWing.rotateAngleY = -this.leftWing.rotateAngleY;
this.rightWing.rotationPointY = this.leftWing.rotationPointY;
this.rightWing.rotateAngleX = this.leftWing.rotateAngleX;
this.rightWing.rotateAngleZ = -this.leftWing.rotateAngleZ;
rightWing.rotationPointX = -leftWing.rotationPointX;
rightWing.rotationPointY = leftWing.rotationPointY;
rightWing.rotateAngleX = leftWing.rotateAngleX;
rightWing.rotateAngleY = -leftWing.rotateAngleY;
rightWing.rotateAngleZ = -leftWing.rotateAngleZ;
}
}