2018-04-25 16:40:47 +02:00
|
|
|
package com.minelittlepony.model.components;
|
|
|
|
|
|
|
|
import com.minelittlepony.model.PonyModelConstants;
|
2018-04-26 23:53:49 +02:00
|
|
|
import com.minelittlepony.render.PonyRenderer;
|
2016-05-10 21:10:29 +02:00
|
|
|
|
|
|
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
|
|
|
import net.minecraft.client.model.ModelBase;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
public class PonyElytra extends ModelBase {
|
2018-04-26 23:53:49 +02:00
|
|
|
private PonyRenderer rightWing = new PonyRenderer(this, 22, 0);
|
|
|
|
private PonyRenderer leftWing = new PonyRenderer(this, 22, 0);
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2018-04-25 16:40:47 +02:00
|
|
|
public PonyElytra() {
|
2018-04-26 23:53:49 +02:00
|
|
|
this.leftWing .box(-10, 0, 0, 10, 20, 2, 1);
|
|
|
|
this.rightWing.mirror().box( 0, 0, 0, 10, 20, 2, 1);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-04-26 23:53:49 +02:00
|
|
|
public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
2016-05-10 21:10:29 +02:00
|
|
|
GlStateManager.disableRescaleNormal();
|
|
|
|
GlStateManager.disableCull();
|
2018-04-26 23:53:49 +02:00
|
|
|
leftWing.render(scale);
|
|
|
|
rightWing.render(scale);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
2018-04-26 23:53:49 +02:00
|
|
|
|
2016-05-10 21:10:29 +02:00
|
|
|
final float PI = (float) Math.PI;
|
|
|
|
float rotateX = PI / 2F;
|
2018-04-26 23:53:49 +02:00
|
|
|
float rotateY = PI / 8F;
|
2016-05-10 21:10:29 +02:00
|
|
|
float rotateZ = PI / 12;
|
2018-04-26 23:53:49 +02:00
|
|
|
|
2016-05-10 21:10:29 +02:00
|
|
|
float rpY = PonyModelConstants.BODY_RP_Y_NOTSNEAK;
|
2018-04-26 23:53:49 +02:00
|
|
|
|
2016-05-10 21:10:29 +02:00
|
|
|
if (entityIn instanceof EntityLivingBase && ((EntityLivingBase) entityIn).isElytraFlying()) {
|
2018-04-26 23:53:49 +02:00
|
|
|
float f4 = 1;
|
2016-05-10 21:10:29 +02:00
|
|
|
|
2018-04-26 23:53:49 +02:00
|
|
|
if (entityIn.motionY < 0) {
|
2016-05-10 21:10:29 +02:00
|
|
|
Vec3d vec3d = (new Vec3d(entityIn.motionX, entityIn.motionY, entityIn.motionZ)).normalize();
|
2018-04-26 23:53:49 +02:00
|
|
|
f4 = 1 - (float) Math.pow(-vec3d.y, 1.5);
|
2016-05-10 21:10:29 +02:00
|
|
|
}
|
|
|
|
|
2018-04-26 23:53:49 +02:00
|
|
|
rotateX = f4 * PI * (2 / 3F) + (1 - f4) * rotateX;
|
|
|
|
rotateY = f4 * ((float) Math.PI / 2F) + (1 - f4) * rotateY;
|
2016-05-10 21:10:29 +02:00
|
|
|
} else if (entityIn.isSneaking()) {
|
|
|
|
rotateX = ((float) Math.PI * 1.175F);
|
|
|
|
rotateY = PI / 2;
|
|
|
|
rpY = PonyModelConstants.BODY_RP_Y_SNEAK;
|
|
|
|
rotateZ = PI / 4F;
|
|
|
|
}
|
|
|
|
|
2018-04-26 23:53:49 +02:00
|
|
|
this.leftWing.rotationPointX = 5;
|
2016-05-10 21:10:29 +02:00
|
|
|
this.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;
|
|
|
|
} else {
|
|
|
|
this.leftWing.rotateAngleX = rotateX;
|
|
|
|
this.leftWing.rotateAngleZ = rotateZ;
|
|
|
|
this.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;
|
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
}
|