MineLittlePony/src/main/java/com/minelittlepony/model/ponies/ModelPlayerPony.java

676 lines
24 KiB
Java
Raw Normal View History

package com.minelittlepony.model.ponies;
2015-08-02 00:36:33 +02:00
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.ModelPonyArmor;
import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.model.components.PegasusWings;
import com.minelittlepony.model.components.PonySnout;
import com.minelittlepony.model.components.PonyTail;
import com.minelittlepony.model.components.UnicornHorn;
2018-04-26 16:01:31 +02:00
import com.minelittlepony.render.PonyRenderer;
import com.minelittlepony.render.plane.PlaneRenderer;
2015-08-02 00:36:33 +02:00
import net.minecraft.client.model.ModelRenderer;
2016-04-09 08:24:15 +02:00
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumHandSide;
2016-05-04 03:23:57 +02:00
import net.minecraft.util.math.MathHelper;
2015-08-02 00:36:33 +02:00
2016-11-25 05:40:19 +01:00
import static net.minecraft.client.renderer.GlStateManager.popMatrix;
import static net.minecraft.client.renderer.GlStateManager.pushMatrix;
import static com.minelittlepony.model.PonyModelConstants.*;
2016-11-25 05:40:19 +01:00
public class ModelPlayerPony extends AbstractPonyModel {
private final boolean smallArms;
2015-08-02 00:36:33 +02:00
public ModelRenderer bipedCape;
2018-04-26 16:01:31 +02:00
public PlaneRenderer upperTorso;
public PlaneRenderer neck;
public PonyRenderer unicornArmRight;
public PonyRenderer unicornArmLeft;
2018-04-26 16:01:31 +02:00
public PonyTail tail;
public PonySnout snout;
public UnicornHorn horn;
public PegasusWings wings;
2015-08-02 00:36:33 +02:00
public ModelPlayerPony(boolean smallArms) {
super(smallArms);
this.smallArms = smallArms;
}
@Override
public PonyArmor createArmour() {
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor());
}
@Override
public void init(float yOffset, float stretch) {
super.init(yOffset, stretch);
snout = new PonySnout(this, yOffset, stretch);
horn = new UnicornHorn(this, yOffset, stretch);
wings = new PegasusWings(this, yOffset, stretch);
2015-08-02 00:36:33 +02:00
}
@Override
public void setRotationAngles(float move, float swing, float age, float headYaw, float headPitch, float scale, Entity entity) {
super.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity);
checkRainboom(entity, swing);
rotateHead(headYaw, headPitch);
2018-04-26 23:53:49 +02:00
float bodySwingRotation = 0;
if (swingProgress > -9990.0F && !metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F;
2015-08-02 00:36:33 +02:00
}
rotateLook(move, swing, bodySwingRotation, age);
2015-08-02 00:36:33 +02:00
setLegs(move, swing, age, entity);
holdItem(swing);
swingItem(entity, swingProgress);
2018-04-26 16:01:31 +02:00
if (isCrouching() && !rainboom) {
adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
sneakLegs();
setHead(0, 6, -2);
} else if (isRiding) {
adjustBodyRiding();
2018-04-26 16:01:31 +02:00
bipedLeftLeg.rotationPointZ = 15;
bipedLeftLeg.rotationPointY = 10;
bipedLeftLeg.rotateAngleX = -PI / 4;
bipedLeftLeg.rotateAngleY = -PI / 5;
bipedRightLeg.rotationPointZ = 15;
bipedRightLeg.rotationPointY = 10;
bipedRightLeg.rotateAngleX = -PI / 4;
bipedRightLeg.rotateAngleY = PI / 5;
bipedLeftArm.rotateAngleZ = -PI * 0.06f;
bipedRightArm.rotateAngleZ = PI * 0.06f;
2015-08-02 00:36:33 +02:00
} else {
2018-04-26 16:01:31 +02:00
adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
2016-01-26 09:20:12 +01:00
2018-04-26 16:01:31 +02:00
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(age);
2018-04-26 16:01:31 +02:00
setHead(0, 0, 0);
2015-08-02 00:36:33 +02:00
}
2018-04-26 16:01:31 +02:00
if (isSleeping) ponySleep();
2015-08-02 00:36:33 +02:00
aimBow(leftArmPose, rightArmPose, age);
fixSpecialRotationPoints(move);
2015-08-02 00:36:33 +02:00
animateWears();
2016-01-26 09:20:12 +01:00
2018-04-26 17:20:40 +02:00
if (bipedCape != null) {
bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0;
2018-04-26 17:20:40 +02:00
snout.setGender(metadata.getGender());
wings.setRotationAngles(move, swing, age, headYaw, headPitch, scale, entity);
2018-04-26 17:20:40 +02:00
}
2015-08-02 00:36:33 +02:00
}
protected void adjustBodyRiding() {
2018-04-26 16:01:31 +02:00
adjustBodyComponents(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
adjustNeck(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
setHead(0, 0, 0);
}
protected void rotateLook(float move, float swing, float bodySwing, float ticks) {
tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks);
2018-04-26 16:01:31 +02:00
bodySwing /= 5;
2018-04-26 16:01:31 +02:00
upperTorso.rotateAngleY = bodySwing;
bipedBody.rotateAngleY = bodySwing;
neck.rotateAngleY = bodySwing;
}
2015-08-02 00:36:33 +02:00
private void animateWears() {
copyModelAngles(bipedLeftArm, bipedLeftArmwear);
copyModelAngles(bipedRightArm, bipedRightArmwear);
copyModelAngles(bipedLeftLeg, bipedLeftLegwear);
copyModelAngles(bipedRightLeg, bipedRightLegwear);
copyModelAngles(bipedBody, bipedBodyWear);
}
2018-04-26 16:01:31 +02:00
/**
* Checks flying and speed conditions and sets rainboom to true if we're a species with wings and is going faaast.
*/
protected void checkRainboom(Entity entity, float swing) {
2018-04-26 16:01:31 +02:00
rainboom = isFlying(entity) && swing >= 0.9999F;
2015-08-02 00:36:33 +02:00
}
2018-04-26 16:01:31 +02:00
/**
* Sets the head rotation angle.
*/
2015-08-02 00:36:33 +02:00
protected void setHead(float posX, float posY, float posZ) {
2018-04-26 16:01:31 +02:00
bipedHead.setRotationPoint(posX, posY, posZ);
bipedHeadwear.setRotationPoint(posX, posY, posZ);
2015-08-02 00:36:33 +02:00
}
2018-04-26 16:01:31 +02:00
/**
* Rotates the head within reason. X is clamped to around motionPitch.
* Both arguments are also ignored when sleeping.
*/
private void rotateHead(float horz, float vert) {
float headRotateAngleY = isSleeping ? 1.4f : horz / 57.29578F;
float headRotateAngleX = isSleeping ? 0.1f : vert / 57.29578F;
2018-04-26 16:01:31 +02:00
headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch)));
headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch)));
2018-04-26 16:01:31 +02:00
updateHeadRotation(headRotateAngleX, headRotateAngleY);
}
2018-04-26 16:01:31 +02:00
/**
* Called to update the head rotation.
*
2018-04-26 16:01:31 +02:00
* @param x New rotation X
* @param y New rotation Y
*/
protected void updateHeadRotation(float x, float y) {
bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y;
bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x;
2015-08-02 00:36:33 +02:00
}
protected void setLegs(float move, float swing, float tick, Entity entity) {
2018-04-26 16:01:31 +02:00
rotateLegs(move, swing, tick, entity);
adjustLegs();
2015-08-02 00:36:33 +02:00
}
protected void rotateLegs(float move, float swing, float tick, Entity entity) {
2018-04-26 23:53:49 +02:00
float leftArm;
float rightArm;
float leftLeg;
float rightLeg;
if (isFlying(entity)) {
2018-04-26 16:01:31 +02:00
if (rainboom) {
rightArm = leftArm = ROTATE_270;
rightLeg = leftLeg = ROTATE_90;
2015-08-02 00:36:33 +02:00
} else {
rightArm = leftArm = MathHelper.sin(-swing / 2);
rightLeg = leftLeg = MathHelper.sin(swing / 2);
2015-08-02 00:36:33 +02:00
}
2018-04-26 23:53:49 +02:00
bipedLeftLeg.rotateAngleY = bipedRightArm.rotateAngleY = 0.2F;
bipedLeftArm.rotateAngleY = bipedRightLeg.rotateAngleY = -0.2F;
2015-08-02 00:36:33 +02:00
} else {
float pi = PI * (float) Math.pow(swing, 16);
float mve = move * 0.6662F; // magic number ahoy
float srt = swing / 4;
leftArm = MathHelper.cos(mve + pi) * srt;
rightArm = MathHelper.cos(mve + PI + pi / 2) * srt;
leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt;
rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt;
2015-08-02 00:36:33 +02:00
2018-04-26 16:01:31 +02:00
bipedLeftArm.rotateAngleY = 0;
bipedRightArm.rotateAngleY = 0;
bipedLeftLeg.rotateAngleY = 0;
bipedRightLeg.rotateAngleY = 0;
unicornArmRight.rotateAngleY = 0;
unicornArmLeft.rotateAngleY = 0;
}
2015-08-02 00:36:33 +02:00
2018-04-26 16:01:31 +02:00
bipedLeftArm.rotateAngleX = leftArm;
bipedRightArm.rotateAngleX = rightArm;
bipedLeftLeg.rotateAngleX = leftLeg;
bipedRightLeg.rotateAngleX = rightLeg;
bipedLeftArm.rotateAngleZ = 0;
bipedRightArm.rotateAngleZ = 0;
unicornArmLeft.rotateAngleZ = 0;
unicornArmRight.rotateAngleZ = 0;
unicornArmLeft.rotateAngleX = 0;
unicornArmRight.rotateAngleX = 0;
}
private float getLegOutset() {
if (isSleeping) return 2.6f;
if (isSneak && !isFlying) return smallArms ? 1 : 0;
return 4;
2015-08-02 00:36:33 +02:00
}
protected void adjustLegs() {
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5;
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5;
float spread = rainboom ? 2 : 1;
2015-08-02 00:36:33 +02:00
2018-04-25 21:38:11 +02:00
bipedRightArm.rotationPointZ = spread + sin;
2015-08-02 00:36:33 +02:00
bipedLeftArm.rotationPointZ = spread - sin;
float legOutset = getLegOutset();
float rpxl = cos + 1 - legOutset;
float rpxr = legOutset - cos - 1;
bipedRightArm.rotationPointX = rpxr;
bipedRightLeg.rotationPointX = rpxr;
bipedLeftArm.rotationPointX = rpxl;
bipedLeftLeg.rotationPointX = rpxl;
// Push the front legs back apart if we're a thin pony
if (smallArms) {
bipedLeftArm.rotationPointX--;
bipedLeftArm.rotationPointX += 2;
}
2015-08-02 00:36:33 +02:00
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
2015-08-02 00:36:33 +02:00
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8;
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
2015-08-02 00:36:33 +02:00
}
protected void holdItem(float swing) {
2018-04-26 16:01:31 +02:00
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
if (!rainboom && !metadata.hasMagic()) {
alignArmForAction(bipedLeftArm, leftArmPose, both, swing);
alignArmForAction(bipedRightArm, rightArmPose, both, swing);
} else if (metadata.hasMagic()) {
alignArmForAction(unicornArmLeft, leftArmPose, both, swing);
alignArmForAction(unicornArmRight, rightArmPose, both, swing);
2015-08-02 00:36:33 +02:00
}
horn.setUsingMagic(leftArmPose != ArmPose.EMPTY || rightArmPose != ArmPose.EMPTY);
2015-08-02 00:36:33 +02:00
}
private void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) {
switch (pose) {
case ITEM:
float swag = 1;
if (!isFlying && both) {
2018-04-26 16:01:31 +02:00
swag -= (float)Math.pow(swing, 2);
}
2018-04-26 16:01:31 +02:00
float mult = 1 - swag/2f;
arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag;
case EMPTY:
arm.rotateAngleY = 0;
break;
case BLOCK:
2018-04-26 16:01:31 +02:00
blockArm(arm);
break;
default:
}
}
private void blockArm(ModelRenderer arm) {
2018-04-26 16:01:31 +02:00
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F;
arm.rotateAngleY = PI / 6;
}
2015-08-02 00:36:33 +02:00
protected void swingItem(Entity entity, float swingProgress) {
if (swingProgress > -9990.0F && !isSleeping) {
EnumHandSide mainSide = getMainHand(entity);
2018-04-27 20:37:54 +02:00
if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return;
2018-04-26 16:01:31 +02:00
if (metadata.hasMagic()) {
2018-04-27 20:37:54 +02:00
swingArm(getUnicornArmForSide(mainSide));
2015-08-02 00:36:33 +02:00
} else {
2018-04-26 23:53:49 +02:00
swingArm(getArmForSide(mainSide));
2015-08-02 00:36:33 +02:00
}
}
}
2018-04-26 23:53:49 +02:00
private void swingArm(ModelRenderer arm) {
float swing = 1 - (float)Math.pow(1 - swingProgress, 3);
2018-04-26 23:53:49 +02:00
float deltaX = MathHelper.sin(swing * PI);
float deltaZ = MathHelper.sin(swingProgress * PI);
2018-04-26 23:53:49 +02:00
float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F;
2018-04-26 23:53:49 +02:00
arm.rotateAngleX -= deltaAim + deltaX * 1.2F;
arm.rotateAngleZ = deltaZ * -0.4F;
arm.rotateAngleY += bipedBody.rotateAngleY * 2;
2015-08-02 00:36:33 +02:00
}
2016-11-25 05:40:19 +01:00
protected void swingArms(float tick) {
2018-04-27 20:37:54 +02:00
if (isSleeping) return;
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) * 0.05F;
2018-04-27 20:37:54 +02:00
if (rightArmPose != ArmPose.EMPTY) {
2018-04-26 23:53:49 +02:00
if (metadata.hasMagic()) {
unicornArmRight.rotateAngleZ += cos;
unicornArmRight.rotateAngleX += sin;
2015-08-02 00:36:33 +02:00
} else {
2018-04-26 23:53:49 +02:00
bipedRightArm.rotateAngleZ += cos;
bipedRightArm.rotateAngleX += sin;
2015-08-02 00:36:33 +02:00
}
}
2018-04-27 20:37:54 +02:00
if (leftArmPose != ArmPose.EMPTY) {
2018-04-26 23:53:49 +02:00
if (metadata.hasMagic()) {
unicornArmLeft.rotateAngleZ += cos;
unicornArmLeft.rotateAngleX += sin;
} else {
2018-04-26 23:53:49 +02:00
bipedLeftArm.rotateAngleZ += cos;
bipedLeftArm.rotateAngleX += sin;
}
}
2015-08-02 00:36:33 +02:00
}
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
2018-04-26 23:53:49 +02:00
adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
adjustNeck(rotateAngleX, rotationPointY, rotationPointZ);
2015-08-02 00:36:33 +02:00
}
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
2018-04-26 16:01:31 +02:00
bipedBody.rotateAngleX = rotateAngleX;
bipedBody.rotationPointY = rotationPointY;
bipedBody.rotationPointZ = rotationPointZ;
2018-04-26 16:01:31 +02:00
upperTorso.rotateAngleX = rotateAngleX;
upperTorso.rotationPointY = rotationPointY;
upperTorso.rotationPointZ = rotationPointZ;
2015-08-02 00:36:33 +02:00
}
protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
2018-04-26 16:01:31 +02:00
neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ);
2015-08-02 00:36:33 +02:00
}
2018-04-27 20:37:54 +02:00
public PonyRenderer getUnicornArmForSide(EnumHandSide side) {
return side == EnumHandSide.LEFT ? unicornArmLeft : unicornArmRight;
}
2018-04-26 16:01:31 +02:00
/**
* Aligns legs to a sneaky position.
*/
2015-08-02 00:36:33 +02:00
protected void sneakLegs() {
2018-04-26 16:01:31 +02:00
unicornArmRight.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT;
unicornArmLeft.rotateAngleX += SNEAK_LEG_X_ROTATION_ADJUSTMENT;
2015-08-02 00:36:33 +02:00
2018-04-26 16:01:31 +02:00
bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
2015-08-02 00:36:33 +02:00
}
protected void ponySleep() {
2018-04-26 16:01:31 +02:00
bipedRightArm.rotateAngleX = ROTATE_270;
bipedLeftArm.rotateAngleX = ROTATE_270;
bipedRightLeg.rotateAngleX = ROTATE_90;
bipedLeftLeg.rotateAngleX = ROTATE_90;
2018-04-26 16:01:31 +02:00
setHead(1, 2, isSneak ? -1 : 1);
2018-04-26 16:01:31 +02:00
shiftRotationPoint(bipedRightArm, 0, 2, 6);
shiftRotationPoint(bipedLeftArm, 0, 2, 6);
shiftRotationPoint(bipedRightLeg, 0, 2, -8);
shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
2015-08-02 00:36:33 +02:00
}
2016-05-04 03:23:57 +02:00
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) {
if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) {
2015-08-02 00:36:33 +02:00
2018-04-26 23:53:49 +02:00
if (metadata.hasMagic()) {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmRight, tick, true);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(unicornArmLeft, tick, false);
2016-05-04 03:23:57 +02:00
} else {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false);
2016-05-04 03:23:57 +02:00
}
}
2015-08-02 00:36:33 +02:00
}
protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) {
2018-04-26 16:01:31 +02:00
arm.rotateAngleZ = 0;
arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F;
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX;
arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F;
2018-04-26 16:01:31 +02:00
if (shift) shiftRotationPoint(arm, 0, 0, 1);
2015-08-02 00:36:33 +02:00
}
2016-11-25 05:40:19 +01:00
protected void fixSpecialRotationPoints(float move) {
}
2015-08-02 00:36:33 +02:00
@Override
public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) {
2016-01-26 09:20:12 +01:00
pushMatrix();
2018-04-26 16:01:31 +02:00
transform(BodyPart.HEAD);
renderHead(entityIn, move, swing, age, headYaw, headPitch, scale);
2016-01-26 09:20:12 +01:00
popMatrix();
2015-08-02 00:36:33 +02:00
2016-01-26 09:20:12 +01:00
pushMatrix();
2018-04-26 16:01:31 +02:00
transform(BodyPart.NECK);
renderNeck();
2016-01-26 09:20:12 +01:00
popMatrix();
2015-08-02 00:36:33 +02:00
2016-01-26 09:20:12 +01:00
pushMatrix();
2018-04-26 16:01:31 +02:00
transform(BodyPart.BODY);
renderBody(entityIn, move, swing, age, headYaw, headPitch, scale);
2016-01-26 09:20:12 +01:00
popMatrix();
2015-08-02 00:36:33 +02:00
2016-01-26 09:20:12 +01:00
pushMatrix();
2018-04-26 16:01:31 +02:00
transform(BodyPart.LEGS);
renderLegs();
2016-01-26 09:20:12 +01:00
popMatrix();
2015-08-02 00:36:33 +02:00
}
protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) {
2018-04-26 16:01:31 +02:00
bipedHead.render(scale);
bipedHeadwear.render(scale);
bipedHead.postRender(scale);
horn.render(entity, move, swing, age, headYaw, headPitch, scale);
2015-08-02 00:36:33 +02:00
}
protected void renderNeck() {
2016-04-09 08:24:15 +02:00
GlStateManager.scale(0.9, 0.9, 0.9);
2018-04-26 16:01:31 +02:00
neck.render(scale);
2015-08-02 00:36:33 +02:00
}
protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) {
2018-04-26 16:01:31 +02:00
bipedBody.render(scale);
if (textureHeight == 64) {
bipedBodyWear.render(scale);
2015-08-02 00:36:33 +02:00
}
2018-04-26 16:01:31 +02:00
upperTorso.render(scale);
bipedBody.postRender(scale);
wings.render(entity, move, swing, age, headYaw, headPitch, scale);
2018-04-26 17:20:40 +02:00
tail.render(metadata.getTail(), scale);
2015-08-02 00:36:33 +02:00
}
protected void renderLegs() {
2018-04-26 16:01:31 +02:00
if (!isSneak) bipedBody.postRender(scale);
bipedLeftArm.render(scale);
bipedRightArm.render(scale);
bipedLeftLeg.render(scale);
bipedRightLeg.render(scale);
2018-04-26 16:01:31 +02:00
if (textureHeight == 64) {
bipedLeftArmwear.render(scale);
bipedRightArmwear.render(scale);
bipedLeftLegwear.render(scale);
bipedRightLegwear.render(scale);
2015-08-02 00:36:33 +02:00
}
}
2016-04-07 04:13:05 +02:00
@Override
2015-08-02 00:36:33 +02:00
protected void initTextures() {
2018-04-26 16:01:31 +02:00
boxList.clear();
initHeadTextures();
initBodyTextures();
initLegTextures();
tail = new PonyTail(this);
2015-08-02 00:36:33 +02:00
}
protected void initHeadTextures() {
2018-04-26 16:01:31 +02:00
bipedCape = new PonyRenderer(this, 0, 0).size(64, 32);
bipedHead = new PonyRenderer(this, 0, 0);
bipedHeadwear = new PonyRenderer(this, 32, 0);
2015-08-02 00:36:33 +02:00
}
protected void initBodyTextures() {
2018-04-26 16:01:31 +02:00
bipedBody = new ModelRenderer(this, 16, 16);
2018-04-26 16:01:31 +02:00
if (textureHeight == 64) {
bipedBodyWear = new ModelRenderer(this, 16, 32);
2015-08-02 00:36:33 +02:00
}
2018-04-26 16:01:31 +02:00
upperTorso = new PlaneRenderer(this, 24, 0);
neck = new PlaneRenderer(this, 0, 16);
2015-08-02 00:36:33 +02:00
}
protected void initLegTextures() {
2018-04-26 16:01:31 +02:00
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedRightLeg = new ModelRenderer(this, 0, 16);
2015-08-02 00:36:33 +02:00
2018-04-26 16:01:31 +02:00
bipedLeftArm = new ModelRenderer(this, 32, 48);
bipedLeftLeg = new ModelRenderer(this, 16, 48);
2015-08-02 00:36:33 +02:00
2018-04-26 16:01:31 +02:00
bipedRightArmwear = new ModelRenderer(this, 40, 32);
bipedRightLegwear = new ModelRenderer(this, 0, 32);
2018-04-26 16:01:31 +02:00
bipedLeftArmwear = new ModelRenderer(this, 48, 48);
bipedLeftLegwear = new ModelRenderer(this, 0, 48);
2015-08-02 06:19:14 +02:00
2018-04-26 16:01:31 +02:00
unicornArmRight = new PonyRenderer(this, 40, 32).size(64, 64);
unicornArmLeft = new PonyRenderer(this, 40, 32).size(64, 64);
2018-04-26 16:01:31 +02:00
boxList.remove(unicornArmRight);
2015-08-02 00:36:33 +02:00
}
2016-04-07 04:13:05 +02:00
@Override
2015-08-02 00:36:33 +02:00
protected void initPositions(float yOffset, float stretch) {
2018-04-26 16:01:31 +02:00
initHeadPositions(yOffset, stretch);
initBodyPositions(yOffset, stretch);
initLegPositions(yOffset, stretch);
initTailPositions(yOffset, stretch);
}
2018-04-26 16:01:31 +02:00
protected void initTailPositions(float yOffset, float stretch) {
tail.init(yOffset, stretch);
2015-08-02 00:36:33 +02:00
}
protected void initHeadPositions(float yOffset, float stretch) {
2018-04-26 16:01:31 +02:00
bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
2018-04-26 16:01:31 +02:00
((PonyRenderer)bipedHead).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch)
.tex(12, 16)
.box(-4, -6, 1, 2, 2, 2, stretch)
.mirror()
.box(2, -6, 1, 2, 2, 2, stretch);
2018-04-26 16:01:31 +02:00
((PonyRenderer)bipedHeadwear).offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2)
.box(-4, -4, -4, 8, 8, 8, stretch + 0.5F);
2015-08-02 00:36:33 +02:00
}
2018-04-26 16:01:31 +02:00
/**
* Creates the main torso and neck.
*/
2015-08-02 00:36:33 +02:00
protected void initBodyPositions(float yOffset, float stretch) {
2018-04-26 16:01:31 +02:00
bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch);
bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
2018-04-26 16:01:31 +02:00
bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F);
bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
2018-04-26 16:01:31 +02:00
upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.tex(24, 0) .addEastPlane( 4, -4, -4, 8, 8, stretch)
.tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch)
.tex(4, 0) .addEastPlane( 4, -4, 4, 8, 4, stretch)
.tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch)
.addBackPlane(-4, 0, 8, 8, 4, stretch)
.addBottomPlane(-4, 4, 4, 8, 4, stretch)
.flipZ().tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch)
.tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch)
.tex(4, 0) .addWestPlane(-4, -4, 4, 8, 4, stretch)
// Tail stub
.child(0)
.tex(32, 0).addTopPlane(-1, 2, 2, 2, 6, stretch)
.addBottomPlane(-1, 4, 2, 2, 6, stretch)
.addEastPlane( 1, 2, 2, 2, 6, stretch)
.addBackPlane(-1, 2, 8, 2, 2, stretch)
.flipZ().addWestPlane(-1, 2, 2, 2, 6, stretch)
.rotateAngleX = 0.5F;
2018-04-26 16:01:31 +02:00
neck.at(NECK_CENTRE_X, NECK_CENTRE_Y, NECK_CENTRE_Z)
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
.addFrontPlane(0, 0, 0, 4, 4, stretch)
.addBackPlane(0, 0, 4, 4, 4, stretch)
.addEastPlane(4, 0, 0, 4, 4, stretch)
.addWestPlane(0, 0, 0, 4, 4, stretch)
.rotateAngleX = NECK_ROT_X;
2015-08-02 00:36:33 +02:00
}
protected void initLegPositions(float yOffset, float stretch) {
int armWidth = smallArms ? 3 : 4;
float rarmY = smallArms ? 8.5f : 8;
float rarmX = smallArms ? 2 : 3;
float armX = THIRDP_ARM_CENTRE_X - 2;
float armY = THIRDP_ARM_CENTRE_Y - 6;
float armZ = THIRDP_ARM_CENTRE_Z - 2;
2018-04-26 16:01:31 +02:00
bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, 4, stretch);
bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, 4, stretch);
2018-04-26 16:01:31 +02:00
bipedLeftLeg .addBox(armX, armY, armZ, 4, 12, 4, stretch);
bipedRightLeg.addBox(armX, armY, armZ, 4, 12, 4, stretch);
2018-04-26 16:01:31 +02:00
bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0);
bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0);
2018-04-26 16:01:31 +02:00
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
if (bipedLeftArmwear != null) {
2018-04-26 16:01:31 +02:00
bipedLeftArmwear.addBox(armX, armY, armZ, 3, 12, 4, stretch + 0.25f);
bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0);
}
if (bipedRightArmwear != null) {
2018-04-26 16:01:31 +02:00
bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, 4, stretch + 0.25f);
bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0);
}
2018-04-26 16:01:31 +02:00
if (bipedLeftLegwear != null) {
bipedLeftLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(3, yOffset, 0);
}
2015-08-02 00:36:33 +02:00
if (bipedRightLegwear != null) {
2018-04-26 16:01:31 +02:00
bipedRightLegwear.addBox(armX, armY, armZ, 4, 12, 4, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(-3, yOffset, 0);
2015-08-02 00:36:33 +02:00
}
2018-04-27 20:37:54 +02:00
unicornArmLeft .box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(5, yOffset + 2, 0);
unicornArmRight.box(FIRSTP_ARM_CENTRE_X - 2, armY, armZ, 4, 12, 4, stretch + .25f).around(-5, yOffset + 2, 0);
2015-08-02 00:36:33 +02:00
}
@Override
public void renderCape(float scale) {
2018-04-26 16:01:31 +02:00
bipedCape.render(scale);
2015-08-02 00:36:33 +02:00
}
}