2016-11-25 05:40:19 +01:00
|
|
|
package com.minelittlepony.model;
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
import net.minecraft.client.model.ModelBase;
|
2015-12-14 09:29:10 +01:00
|
|
|
import net.minecraft.client.model.ModelRenderer;
|
2016-11-25 05:40:19 +01:00
|
|
|
import net.minecraft.entity.Entity;
|
2016-05-04 03:23:57 +02:00
|
|
|
import net.minecraft.util.math.MathHelper;
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
public class PegasusWings extends ModelBase implements PonyModelConstants {
|
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-04-09 08:24:15 +02:00
|
|
|
private final AbstractPonyModel pony;
|
2015-12-14 09:29:10 +01:00
|
|
|
|
|
|
|
public ModelRenderer[] leftWing;
|
|
|
|
public ModelRenderer[] rightWing;
|
|
|
|
|
|
|
|
public ModelRenderer[] leftWingExt;
|
|
|
|
public ModelRenderer[] rightWingExt;
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) {
|
2015-12-14 09:29:10 +01:00
|
|
|
this.pony = pony;
|
2016-11-12 04:41:52 +01:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWing = new ModelRenderer[3];
|
|
|
|
this.rightWing = new ModelRenderer[3];
|
|
|
|
this.leftWingExt = new ModelRenderer[6];
|
|
|
|
this.rightWingExt = new ModelRenderer[6];
|
|
|
|
|
|
|
|
for (int i = 0; i < leftWing.length; i++) {
|
2015-12-29 02:20:07 +01:00
|
|
|
this.leftWing[i] = new ModelRenderer(pony, 56, 32);
|
2016-05-20 10:59:24 +02:00
|
|
|
this.pony.boxList.remove(this.leftWing[i]);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
for (int i = 0; i < rightWing.length; i++) {
|
|
|
|
this.rightWing[i] = new ModelRenderer(pony, 56, 16);
|
2016-05-20 10:59:24 +02:00
|
|
|
this.pony.boxList.remove(this.rightWing[i]);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
for (int i = 0; i < leftWingExt.length; i++) {
|
2015-12-29 02:20:07 +01:00
|
|
|
this.leftWingExt[i] = new ModelRenderer(pony, 56, 35);
|
2016-05-20 10:59:24 +02:00
|
|
|
this.pony.boxList.remove(this.leftWingExt[i]);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
for (int i = 0; i < rightWingExt.length; i++) {
|
|
|
|
this.rightWingExt[i] = new ModelRenderer(pony, 56, 19);
|
2016-04-07 05:16:50 +02:00
|
|
|
// this seems to hide the wings being a different size when folded
|
|
|
|
this.rightWingExt[i].mirror = true;
|
2016-05-20 10:59:24 +02:00
|
|
|
this.pony.boxList.remove(this.rightWingExt[i]);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.leftWing[0].addBox(4.0F, 5.0F, 2.0F, 2, 6, 2, stretch);
|
|
|
|
this.leftWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
|
|
|
|
this.leftWing[0].rotateAngleX = ROTATE_90;
|
|
|
|
this.leftWing[1].addBox(4.0F, 5.0F, 4.0F, 2, 8, 2, stretch);
|
|
|
|
this.leftWing[1].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
|
|
|
|
this.leftWing[1].rotateAngleX = ROTATE_90;
|
|
|
|
this.leftWing[2].addBox(4.0F, 5.0F, 6.0F, 2, 6, 2, stretch);
|
|
|
|
this.leftWing[2].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
|
|
|
|
this.leftWing[2].rotateAngleX = ROTATE_90;
|
|
|
|
this.rightWing[0].addBox(-6.0F, 5.0F, 2.0F, 2, 6, 2, stretch);
|
|
|
|
this.rightWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
|
|
|
|
this.rightWing[0].rotateAngleX = ROTATE_90;
|
|
|
|
this.rightWing[1].addBox(-6.0F, 5.0F, 4.0F, 2, 8, 2, stretch);
|
|
|
|
this.rightWing[1].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
|
|
|
|
this.rightWing[1].rotateAngleX = ROTATE_90;
|
|
|
|
this.rightWing[2].addBox(-6.0F, 5.0F, 6.0F, 2, 6, 2, stretch);
|
|
|
|
this.rightWing[2].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
|
|
|
|
this.rightWing[2].rotateAngleX = ROTATE_90;
|
2017-02-14 21:12:05 +01:00
|
|
|
this.leftWingExt[0].addBox(-0.5F, 6.0F, 0.0F, 1, 8, 2, stretch + 0.1F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWingExt[0].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.leftWingExt[1].addBox(-0.5F, -1.2F, -0.2F, 1, 8, 2, stretch - 0.2F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWingExt[1].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.leftWingExt[2].addBox(-0.5F, 1.8F, 1.3F, 1, 8, 2, stretch - 0.1F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWingExt[2].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.leftWingExt[3].addBox(-0.5F, 5.0F, 2.0F, 1, 8, 2, stretch);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWingExt[3].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.leftWingExt[4].addBox(-0.5F, 0.0F, -0.2F, 1, 6, 2, stretch + 0.3F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWingExt[4].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.leftWingExt[5].addBox(-0.5F, 0.0F, 0.2F, 1, 3, 2, stretch + 0.19F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.leftWingExt[5].setRotationPoint(LEFT_WING_EXT_RP_X, LEFT_WING_EXT_RP_Y + yOffset, LEFT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.rightWingExt[0].addBox(-0.5F, 6.0F, 0.0F, 1, 8, 2, stretch + 0.1F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.rightWingExt[0].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.rightWingExt[1].addBox(-0.5F, -1.2F, -0.2F, 1, 8, 2, stretch - 0.2F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.rightWingExt[1].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.rightWingExt[2].addBox(-0.5F, 1.8F, 1.3F, 1, 8, 2, stretch - 0.1F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.rightWingExt[2].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.rightWingExt[3].addBox(-0.5F, 5.0F, 2.0F, 1, 8, 2, stretch);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.rightWingExt[3].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.rightWingExt[4].addBox(-0.5F, 0.0F, -0.2F, 1, 6, 2, stretch + 0.3F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.rightWingExt[4].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z);
|
2017-02-14 21:12:05 +01:00
|
|
|
this.rightWingExt[5].addBox(-0.5F, 0.0F, 0.2F, 1, 3, 2, stretch + 0.19F);
|
2015-12-14 09:29:10 +01:00
|
|
|
this.rightWingExt[5].setRotationPoint(RIGHT_WING_EXT_RP_X, RIGHT_WING_EXT_RP_Y + yOffset, RIGHT_WING_EXT_RP_Z);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-11-25 05:40:19 +01:00
|
|
|
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
|
2015-12-14 09:29:10 +01:00
|
|
|
|
|
|
|
float bodySwingRotation = 0.0F;
|
2016-11-25 05:40:19 +01:00
|
|
|
if (pony.swingProgress > -9990.0F && !pony.metadata.hasMagic()) {
|
2016-11-17 05:45:04 +01:00
|
|
|
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aLeftWing : this.leftWing) {
|
|
|
|
aLeftWing.rotateAngleY = bodySwingRotation * 0.2F;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aRightWing : this.rightWing) {
|
|
|
|
aRightWing.rotateAngleY = bodySwingRotation * 0.2F;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
if (pony.isSneak && !pony.isFlying) {
|
|
|
|
this.sneak();
|
2016-01-26 09:20:12 +01:00
|
|
|
} else {
|
2016-11-25 05:40:19 +01:00
|
|
|
this.unsneak(ageInTicks);
|
2015-12-14 09:29:10 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-04-09 08:24:15 +02:00
|
|
|
float angle = ROTATE_90;
|
2016-01-26 09:20:12 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aLeftWing : this.leftWing) {
|
|
|
|
aLeftWing.rotateAngleX = angle;
|
2016-01-26 09:20:12 +01:00
|
|
|
}
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aRightWing : this.rightWing) {
|
|
|
|
aRightWing.rotateAngleX = angle;
|
2016-01-26 09:20:12 +01:00
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
// Special
|
|
|
|
this.leftWingExt[1].rotateAngleX -= 0.85F;
|
|
|
|
this.leftWingExt[2].rotateAngleX -= 0.75F;
|
|
|
|
this.leftWingExt[3].rotateAngleX -= 0.5F;
|
|
|
|
this.leftWingExt[5].rotateAngleX -= 0.85F;
|
|
|
|
this.rightWingExt[1].rotateAngleX -= 0.85F;
|
|
|
|
this.rightWingExt[2].rotateAngleX -= 0.75F;
|
|
|
|
this.rightWingExt[3].rotateAngleX -= 0.5F;
|
|
|
|
this.rightWingExt[5].rotateAngleX -= 0.85F;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-11-25 05:40:19 +01:00
|
|
|
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
|
|
|
|
if (pony.metadata.getRace() != null && pony.metadata.getRace().hasWings()) {
|
2015-12-14 09:29:10 +01:00
|
|
|
if (!pony.isFlying && !pony.isSneak) {
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aLeftWing : this.leftWing) {
|
|
|
|
aLeftWing.render(scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aRightWing : this.rightWing) {
|
|
|
|
aRightWing.render(scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aLeftWingExt : this.leftWingExt) {
|
|
|
|
aLeftWingExt.render(scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aRightWingExt : this.rightWingExt) {
|
|
|
|
aRightWingExt.render(scale);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void sneak() {
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aLeftWingExt : this.leftWingExt) {
|
|
|
|
aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
|
|
|
aLeftWingExt.rotateAngleZ = LEFT_WING_ROTATE_ANGLE_Z_SNEAK;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < this.leftWingExt.length; ++i) {
|
|
|
|
this.rightWingExt[i].rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
|
|
|
this.rightWingExt[i].rotateAngleZ = RIGHT_WING_ROTATE_ANGLE_Z_SNEAK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void unsneak(float tick) {
|
2016-04-09 08:24:15 +02:00
|
|
|
if (pony.isFlying) {
|
2015-12-14 09:29:10 +01:00
|
|
|
float WingRotateAngleZ = MathHelper.sin(tick * 0.536F) * 1.0F;
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aLeftWingExt : this.leftWingExt) {
|
|
|
|
aLeftWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
|
|
|
aLeftWingExt.rotateAngleZ = -WingRotateAngleZ - ROTATE_270 - 0.4F;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
for (ModelRenderer aRightWingExt : this.rightWingExt) {
|
|
|
|
aRightWingExt.rotateAngleX = EXT_WING_ROTATE_ANGLE_X;
|
|
|
|
aRightWingExt.rotateAngleZ = WingRotateAngleZ + ROTATE_270 + 0.4F;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|