Refactoring for refactoring's sake. I wasn't happy with how things were split up

This commit is contained in:
Sollace 2018-04-29 14:22:26 +02:00
parent 07f1dfb60b
commit fd68e60923
7 changed files with 644 additions and 643 deletions

View file

@ -1,14 +1,21 @@
package com.minelittlepony.model;
import com.minelittlepony.model.armour.ModelPonyArmor;
import com.minelittlepony.model.armour.PonyArmor;
import com.minelittlepony.model.capabilities.IModel;
import com.minelittlepony.model.components.PonySnout;
import com.minelittlepony.model.components.PonyTail;
import com.minelittlepony.pony.data.IPonyData;
import com.minelittlepony.pony.data.PonyData;
import com.minelittlepony.pony.data.PonySize;
import com.minelittlepony.render.AbstractPonyRenderer;
import com.minelittlepony.render.PonyRenderer;
import com.minelittlepony.render.plane.PlaneRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelPlayer;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.EnumHandSide;
@ -17,9 +24,10 @@ import net.minecraft.util.math.MathHelper;
import java.util.Random;
import static net.minecraft.client.renderer.GlStateManager.*;
import static com.minelittlepony.model.PonyModelConstants.*;
/**
* TODO: move this into constructor and make separate classes for the races.
* Foundation class for all types of ponies.
*/
public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
@ -46,10 +54,341 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
*/
public boolean rainboom;
public PlaneRenderer upperTorso;
public PlaneRenderer neck;
public PonyTail tail;
public PonySnout snout;
public AbstractPonyModel(boolean arms) {
super(0, arms);
}
@Override
public PonyArmor createArmour() {
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor());
}
@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);
float headRotateAngleY = isSleeping ? 1.4f : headYaw / 57.29578F;
float headRotateAngleX = isSleeping ? 0.1f : headPitch / 57.29578F;
headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch)));
headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch)));
updateHeadRotation(headRotateAngleX, headRotateAngleY);
float bodySwingRotation = 0;
if (swingProgress > -9990.0F && !metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F;
}
rotateLook(move, swing, bodySwingRotation, age);
setLegs(move, swing, age, entity);
holdItem(swing);
swingItem(entity, swingProgress);
if (isCrouching()) {
adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
sneakLegs();
setHead(0, 6, -2);
} else if (isRiding) {
adjustBodyRiding();
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;
} else {
adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(age);
setHead(0, 0, 0);
}
if (isSleeping) ponySleep();
aimBow(leftArmPose, rightArmPose, age);
fixSpecialRotationPoints(move);
animateWears();
snout.setGender(metadata.getGender());
}
protected void adjustBodyRiding() {
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);
bodySwing /= 5;
upperTorso.rotateAngleY = bodySwing;
bipedBody.rotateAngleY = bodySwing;
neck.rotateAngleY = bodySwing;
}
private void animateWears() {
copyModelAngles(bipedLeftArm, bipedLeftArmwear);
copyModelAngles(bipedRightArm, bipedRightArmwear);
copyModelAngles(bipedLeftLeg, bipedLeftLegwear);
copyModelAngles(bipedRightLeg, bipedRightLegwear);
copyModelAngles(bipedBody, bipedBodyWear);
}
/**
* Sets the head rotation angle.
*/
protected void setHead(float posX, float posY, float posZ) {
bipedHead.setRotationPoint(posX, posY, posZ);
bipedHeadwear.setRotationPoint(posX, posY, posZ);
}
/**
* Called to update the head rotation.
*
* @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;
}
protected void setLegs(float move, float swing, float tick, Entity entity) {
if (isFlying(entity)) {
rotateLegsInFlight(move, swing, tick, entity);
} else {
rotateLegsOnGround(move, swing, tick, entity);
}
bipedLeftArm.rotateAngleZ = 0;
bipedRightArm.rotateAngleZ = 0;
adjustLegs(move, swing, tick);
}
protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) {
float armX = MathHelper.sin(-swing / 2);
float legX = MathHelper.sin(swing / 2);
bipedLeftArm.rotateAngleX = armX;
bipedRightArm.rotateAngleX = armX;
bipedLeftLeg.rotateAngleX = legX;
bipedRightLeg.rotateAngleX = legX;
bipedLeftArm.rotateAngleY = -0.2F;
bipedLeftLeg.rotateAngleY = 0.2F;
bipedRightArm.rotateAngleY = 0.2F;
bipedRightLeg.rotateAngleY = -0.2F;
}
protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) {
float pi = PI * (float) Math.pow(swing, 16);
float mve = move * 0.6662F; // magic number ahoy
float srt = swing / 4;
float leftArm = MathHelper.cos(mve + pi) * srt;
float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt;
float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt;
float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt;
bipedLeftArm.rotateAngleX = leftArm;
bipedRightArm.rotateAngleX = rightArm;
bipedLeftLeg.rotateAngleX = leftLeg;
bipedRightLeg.rotateAngleX = rightLeg;
bipedLeftArm.rotateAngleY = 0;
bipedRightArm.rotateAngleY = 0;
bipedLeftLeg.rotateAngleY = 0;
bipedRightLeg.rotateAngleY = 0;
}
protected float getLegOutset() {
if (isSleeping) return 2.6f;
if (isCrouching()) return 0;
return 4;
}
protected float getLegSpread() {
return rainboom ? 2 : 1;
}
protected void adjustLegs(float move, float swing, float tick) {
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5;
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5;
float spread = getLegSpread();
bipedRightArm.rotationPointZ = spread + sin;
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;
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8;
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
}
protected void holdItem(float swing) {
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
alignArmForAction(bipedLeftArm, leftArmPose, both, swing);
alignArmForAction(bipedRightArm, rightArmPose, both, swing);
}
protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) {
switch (pose) {
case ITEM:
float swag = 1;
if (!isFlying && both) {
swag -= (float)Math.pow(swing, 2);
}
float mult = 1 - swag/2;
arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag;
case EMPTY:
arm.rotateAngleY = 0;
break;
case BLOCK:
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F;
arm.rotateAngleY = PI / 6;
break;
default:
}
}
protected void swingItem(Entity entity, float swingProgress) {
if (swingProgress > -9990.0F && !isSleeping) {
EnumHandSide mainSide = getMainHand(entity);
if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return;
swingArm(getArmForSide(mainSide));
}
}
protected void swingArm(ModelRenderer arm) {
float swing = 1 - (float)Math.pow(1 - swingProgress, 3);
float deltaX = MathHelper.sin(swing * PI);
float deltaZ = MathHelper.sin(swingProgress * PI);
float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F;
arm.rotateAngleX -= deltaAim + deltaX * 1.2F;
arm.rotateAngleY += bipedBody.rotateAngleY * 2;
arm.rotateAngleZ = -deltaZ * 0.4F;
}
protected void swingArms(float tick) {
if (isSleeping) return;
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) {
bipedRightArm.rotateAngleZ += cos;
bipedRightArm.rotateAngleX += sin;
}
if (leftArmPose != ArmPose.EMPTY) {
bipedLeftArm.rotateAngleZ += cos;
bipedLeftArm.rotateAngleX += sin;
}
}
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
adjustNeck(rotateAngleX, rotationPointY, rotationPointZ);
}
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
bipedBody.rotateAngleX = rotateAngleX;
bipedBody.rotationPointY = rotationPointY;
bipedBody.rotationPointZ = rotationPointZ;
upperTorso.rotateAngleX = rotateAngleX;
upperTorso.rotationPointY = rotationPointY;
upperTorso.rotationPointZ = rotationPointZ;
}
protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ);
}
/**
* Aligns legs to a sneaky position.
*/
protected void sneakLegs() {
bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
}
protected void ponySleep() {
bipedRightArm.rotateAngleX = ROTATE_270;
bipedLeftArm.rotateAngleX = ROTATE_270;
bipedRightLeg.rotateAngleX = ROTATE_90;
bipedLeftLeg.rotateAngleX = ROTATE_90;
setHead(1, 2, isSneak ? -1 : 1);
AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6);
AbstractPonyRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
}
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false);
}
protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) {
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;
if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1);
}
protected void fixSpecialRotationPoints(float move) {
}
/**
* Sets up this model's initial values, like a constructor...
* @param yOffset YPosition for this model. Always 0.
@ -63,12 +402,176 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
/**
* Loads texture values.
*/
protected abstract void initTextures();
protected void initTextures() {
boxList.clear();
initHeadTextures();
initBodyTextures();
initLegTextures();
initTailTextures();
}
/**
* Loads texture positions and boxes. Pretty much just finishes the job of initTextures.
*/
protected abstract void initPositions(float yOffset, float stretch);
protected void initPositions(float yOffset, float stretch) {
initHeadPositions(yOffset, stretch);
initBodyPositions(yOffset, stretch);
initLegPositions(yOffset, stretch);
initTailPositions(yOffset, stretch);
}
protected void initTailTextures() {
tail = new PonyTail(this);
}
protected void initHeadTextures() {
bipedHead = new PonyRenderer(this, 0, 0);
bipedHeadwear = new PonyRenderer(this, 32, 0);
snout = new PonySnout(this);
}
protected void initBodyTextures() {
bipedBody = new ModelRenderer(this, 16, 16);
if (textureHeight == 64) {
bipedBodyWear = new ModelRenderer(this, 16, 32);
}
upperTorso = new PlaneRenderer(this, 24, 0);
neck = new PlaneRenderer(this, 0, 16);
}
protected void initLegTextures() {
bipedLeftArm = new ModelRenderer(this, 32, 48);
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedLeftArmwear = new ModelRenderer(this, 48, 48);
bipedRightArmwear = new ModelRenderer(this, 40, 32);
bipedLeftLeg = new ModelRenderer(this, 16, 48);
bipedRightLeg = new ModelRenderer(this, 0, 16);
bipedLeftLegwear = new ModelRenderer(this, 0, 48);
bipedRightLegwear = new ModelRenderer(this, 0, 32);
}
protected void initTailPositions(float yOffset, float stretch) {
tail.init(yOffset, stretch);
}
protected void initHeadPositions(float yOffset, float stretch) {
snout.init(yOffset, stretch);
((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)
.flipX()
.box(2, -6, 1, 2, 2, 2, stretch);
((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);
}
/**
* Creates the main torso and neck.
*/
protected void initBodyPositions(float yOffset, float stretch) {
bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch);
bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F);
bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
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;
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;
}
protected int getArmWidth() {
return 4;
}
protected int getArmDepth() {
return 4;
}
protected float getLegRotationX() {
return 3;
}
protected float getArmRotationY() {
return 8;
}
protected void initLegPositions(float yOffset, float stretch) {
int armWidth = getArmWidth();
int armDepth = getArmDepth();
float rarmX = getLegRotationX();
float rarmY = getArmRotationY();
float armX = THIRDP_ARM_CENTRE_X - 2;
float armY = THIRDP_ARM_CENTRE_Y - 6;
float armZ = THIRDP_ARM_CENTRE_Z - 2;
bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedRightLeg.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0);
bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0);
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
if (bipedLeftArmwear != null) {
bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0);
}
if (bipedRightArmwear != null) {
bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0);
}
if (bipedLeftLegwear != null) {
bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(3, yOffset, 0);
}
if (bipedRightLegwear != null) {
bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(-3, yOffset, 0);
}
}
public ArmPose getArmPoseForSide(EnumHandSide side) {
return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose;
@ -116,15 +619,80 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
* @param tick Render partial ticks
*/
protected void rotateArmHolding(ModelRenderer arm, float direction, float swingProgress, float tick) {
float swing = MathHelper.sin(swingProgress * (float)Math.PI);
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * (float)Math.PI);
float swing = MathHelper.sin(swingProgress * PI);
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI);
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) / 10;
arm.rotateAngleZ = 0;
arm.rotateAngleY = direction * (0.1F - swing * 0.6F);
arm.rotateAngleX = -1.5707964F;
arm.rotateAngleX -= swing * 1.2F - roll * 0.4F;
arm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
arm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.1F;
arm.rotateAngleX += sin;
arm.rotateAngleY = direction * (0.1F - swing * 0.6F);
arm.rotateAngleZ = cos;
}
@Override
public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) {
pushMatrix();
transform(BodyPart.HEAD);
renderHead(entityIn, move, swing, age, headYaw, headPitch, scale);
popMatrix();
pushMatrix();
transform(BodyPart.NECK);
renderNeck();
popMatrix();
pushMatrix();
transform(BodyPart.BODY);
renderBody(entityIn, move, swing, age, headYaw, headPitch, scale);
popMatrix();
pushMatrix();
transform(BodyPart.LEGS);
renderLegs();
popMatrix();
}
protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) {
bipedHead.render(scale);
bipedHeadwear.render(scale);
bipedHead.postRender(scale);
}
protected void renderNeck() {
GlStateManager.scale(0.9, 0.9, 0.9);
neck.render(scale);
}
protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) {
bipedBody.render(scale);
if (textureHeight == 64) {
bipedBodyWear.render(scale);
}
upperTorso.render(scale);
bipedBody.postRender(scale);
tail.render(scale);
}
protected void renderLegs() {
if (!isSneak) bipedBody.postRender(scale);
bipedLeftArm.render(scale);
bipedRightArm.render(scale);
bipedLeftLeg.render(scale);
bipedRightLeg.render(scale);
if (textureHeight == 64) {
bipedLeftArmwear.render(scale);
bipedRightArmwear.render(scale);
bipedLeftLegwear.render(scale);
bipedRightLegwear.render(scale);
}
}
@Override

View file

@ -14,13 +14,6 @@ public class ModelMobPony extends ModelAlicorn {
super(false);
}
@Override
protected void adjustLegs(float move, float swing, float tick) {
super.adjustLegs(move, swing, tick);
rotateRightArm(move, tick);
rotateLeftArm(move, tick);
}
/**
* Returns true if the angle is to the right?
*/
@ -28,38 +21,25 @@ public class ModelMobPony extends ModelAlicorn {
return MathHelper.sin(move / 20f) < 0;
}
/**
* Called to update the left arm's final rotation.
* Subclasses may replace it with their own implementations.
*
* @param move Limb swing amount.
* @param tick Render partial ticks.
*/
protected void rotateRightArm(float move, float tick) {
if (rightArmPose == ArmPose.EMPTY) return;
if (canCast()) {
unicornArmRight.setRotationPoint(-7, 12, -2);
rotateArmHolding(unicornArmRight, -1, swingProgress, tick);
} else {
rotateArmHolding(bipedRightArm, -1, swingProgress, tick);
@Override
protected void adjustLegs(float move, float swing, float tick) {
super.adjustLegs(move, swing, tick);
if (rightArmPose != ArmPose.EMPTY) {
if (canCast()) {
unicornArmRight.setRotationPoint(-7, 12, -2);
rotateArmHolding(unicornArmRight, -1, swingProgress, tick);
} else {
rotateArmHolding(bipedRightArm, -1, swingProgress, tick);
}
}
}
/**
* Same as rotateRightArm but for the left arm (duh).
*
* @param move Limb swing amount.
* @param tick Render partial ticks.
*/
protected void rotateLeftArm(float move, float tick) {
if (leftArmPose == ArmPose.EMPTY) return;
if (!canCast()) {
unicornArmRight.setRotationPoint(-7, 12, -2);
rotateArmHolding(unicornArmLeft, -1, swingProgress, tick);
} else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick);
if (leftArmPose != ArmPose.EMPTY) {
if (!canCast()) {
unicornArmRight.setRotationPoint(-7, 12, -2);
rotateArmHolding(unicornArmLeft, -1, swingProgress, tick);
} else {
rotateArmHolding(bipedLeftArm, -1, swingProgress, tick);
}
}
}
}

View file

@ -77,6 +77,11 @@ public class ModelPonyArmor extends ModelMobPony {
protected void renderNeck() {
}
@Override
protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
}
@Override
protected void renderBody(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
bipedBody.render(this.scale);

View file

@ -3,10 +3,10 @@ package com.minelittlepony.model.armour;
import com.minelittlepony.render.AbstractPonyRenderer;
public class ModelZombiePonyArmor extends ModelPonyArmor {
// Copied from ModelZombiePony
@Override
protected void rotateRightArm(float move, float tick) {
protected void adjustLegs(float move, float swing, float tick) {
super.adjustLegs(move, swing, tick);
if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) {
@ -16,11 +16,6 @@ public class ModelZombiePonyArmor extends ModelPonyArmor {
}
}
@Override
protected void rotateLeftArm(float move, float tick) {
// Zombies are unidexterous.
}
@Override
protected void fixSpecialRotationPoints(float move) {
if (rightArmPose != ArmPose.EMPTY) return;

View file

@ -6,23 +6,24 @@ import net.minecraft.util.math.MathHelper;
import static com.minelittlepony.model.PonyModelConstants.*;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.pony.data.TailLengths;
import com.minelittlepony.render.plane.PlaneRenderer;
public class PonyTail extends PlaneRenderer {
private final TailSegment[] segments = new TailSegment[4];
private static final int SEGMENTS = 4;
private final AbstractPonyModel theModel;
private int tailStop = 0;
public PonyTail(AbstractPonyModel model) {
super(model);
theModel = model;
}
public void init(float yOffset, float stretch) {
for (int i = 0; i < segments.length; i++) {
addChild(segments[i] = new TailSegment(theModel, i, yOffset, stretch));
for (int i = 0; i < SEGMENTS; i++) {
addChild(new TailSegment(theModel, i, yOffset, stretch));
}
}
@ -53,6 +54,8 @@ public class PonyTail extends PlaneRenderer {
rotationPointY += 6;
rotationPointZ++;
}
tailStop = theModel.metadata.getTail().ordinal();
}
public void swingX(float tick) {
@ -66,42 +69,40 @@ public class PonyTail extends PlaneRenderer {
rotateAngleX = -BODY_ROTATE_ANGLE_X_SNEAK + 0.1F;
}
public void render(TailLengths tail, float scale) {
int tailStop = tail.ordinal();
for (int i = 0; i < segments.length; i++) {
segments[i].isHidden = i >= tailStop;
}
super.render(scale);
}
private class TailSegment extends PlaneRenderer {
private final int index;
public TailSegment(ModelBase model, int index, float yOffset, float stretch) {
super(model);
this.index = index;
offsetY = ((float)index)/4 + 0.063f;
init(index, yOffset, stretch);
init(yOffset, stretch);
}
public void init(int index, float yOffset, float stretch) {
public void init(float yOffset, float stretch) {
int texX = (index % 2) * 4;
around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z);
if (index == 0) {
tex(32, 0).addTopPlane(-2, 0, 2, 4, 4, stretch);
}
around(TAIL_RP_X, TAIL_RP_Y + yOffset, TAIL_RP_Z);
tex(36, texX)
.addEastPlane(2, 0, 2, 4, 4, stretch)
.addWestPlane(-2, 0, 2, 4, 4, stretch);
tex(32, texX)
.addBackPlane(-2, 0, 2, 4, 4, stretch)
.addFrontPlane(-2, 0, 6, 4, 4, stretch);
tex(32, 0)
.addBottomPlane(-2, 4, 2, 4, 4, stretch);
tex(36, texX).addEastPlane( 2, 0, 2, 4, 4, stretch)
.addWestPlane(-2, 0, 2, 4, 4, stretch);
tex(32, texX).addBackPlane(-2, 0, 2, 4, 4, stretch)
.addFrontPlane(-2, 0, 6, 4, 4, stretch);
tex(32, 0).addBottomPlane(-2, 4, 2, 4, 4, stretch);
}
@Override
public void render(float scale) {
if (index < tailStop) {
super.render(scale);
}
}
}
}

View file

@ -1,24 +1,9 @@
package com.minelittlepony.model.player;
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.PonySnout;
import com.minelittlepony.model.components.PonyTail;
import com.minelittlepony.render.AbstractPonyRenderer;
import com.minelittlepony.render.PonyRenderer;
import com.minelittlepony.render.plane.PlaneRenderer;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper;
import static net.minecraft.client.renderer.GlStateManager.popMatrix;
import static net.minecraft.client.renderer.GlStateManager.pushMatrix;
import static com.minelittlepony.model.PonyModelConstants.*;
public class ModelEarthPony extends AbstractPonyModel {
@ -26,587 +11,58 @@ public class ModelEarthPony extends AbstractPonyModel {
public PonyRenderer bipedCape;
public PlaneRenderer upperTorso;
public PlaneRenderer neck;
public PonyTail tail;
public PonySnout snout;
public ModelEarthPony(boolean smallArms) {
super(smallArms);
this.smallArms = smallArms;
}
@Override
public PonyArmor createArmour() {
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor());
}
@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);
rotateHead(headYaw, headPitch);
float bodySwingRotation = 0;
if (swingProgress > -9990.0F && !metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.2F;
}
rotateLook(move, swing, bodySwingRotation, age);
setLegs(move, swing, age, entity);
holdItem(swing);
swingItem(entity, swingProgress);
if (isCrouching()) {
adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
sneakLegs();
setHead(0, 6, -2);
} else if (isRiding) {
adjustBodyRiding();
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;
} else {
adjustBody(BODY_ROTATE_ANGLE_X_NOTSNEAK, BODY_RP_Y_NOTSNEAK, BODY_RP_Z_NOTSNEAK);
bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
swingArms(age);
setHead(0, 0, 0);
}
if (isSleeping) ponySleep();
aimBow(leftArmPose, rightArmPose, age);
fixSpecialRotationPoints(move);
animateWears();
if (bipedCape != null) {
bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0;
snout.setGender(metadata.getGender());
}
bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0;
}
protected void adjustBodyRiding() {
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 float getLegOutset() {
if (isCrouching() && smallArms) return 1;
return super.getLegOutset();
}
protected void rotateLook(float move, float swing, float bodySwing, float ticks) {
tail.setRotationAndAngles(rainboom, move, swing, bodySwing, ticks);
bodySwing /= 5;
upperTorso.rotateAngleY = bodySwing;
bipedBody.rotateAngleY = bodySwing;
neck.rotateAngleY = bodySwing;
protected int getArmWidth() {
return smallArms ? 3 : super.getArmWidth();
}
private void animateWears() {
copyModelAngles(bipedLeftArm, bipedLeftArmwear);
copyModelAngles(bipedRightArm, bipedRightArmwear);
copyModelAngles(bipedLeftLeg, bipedLeftLegwear);
copyModelAngles(bipedRightLeg, bipedRightLegwear);
copyModelAngles(bipedBody, bipedBodyWear);
protected float getLegRotationX() {
return smallArms ? 2 : super.getLegRotationX();
}
/**
* Sets the head rotation angle.
*/
protected void setHead(float posX, float posY, float posZ) {
bipedHead.setRotationPoint(posX, posY, posZ);
bipedHeadwear.setRotationPoint(posX, posY, posZ);
}
/**
* 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;
headRotateAngleX = Math.min(headRotateAngleX, (float) (0.5f - Math.toRadians(motionPitch)));
headRotateAngleX = Math.max(headRotateAngleX, (float) (-1.25f - Math.toRadians(motionPitch)));
updateHeadRotation(headRotateAngleX, headRotateAngleY);
}
/**
* Called to update the head rotation.
*
* @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;
}
protected void setLegs(float move, float swing, float tick, Entity entity) {
if (isFlying(entity)) {
rotateLegsInFlight(move, swing, tick, entity);
} else {
rotateLegsOnGround(move, swing, tick, entity);
}
bipedLeftArm.rotateAngleZ = 0;
bipedRightArm.rotateAngleZ = 0;
adjustLegs(move, swing, tick);
}
protected void rotateLegsInFlight(float move, float swing, float tick, Entity entity) {
float armX = MathHelper.sin(-swing / 2);
float legX = MathHelper.sin(swing / 2);
bipedLeftArm.rotateAngleX = armX;
bipedRightArm.rotateAngleX = armX;
bipedLeftLeg.rotateAngleX = legX;
bipedRightLeg.rotateAngleX = legX;
bipedLeftArm.rotateAngleY = -0.2F;
bipedLeftLeg.rotateAngleY = 0.2F;
bipedRightArm.rotateAngleY = 0.2F;
bipedRightLeg.rotateAngleY = -0.2F;
}
protected void rotateLegsOnGround(float move, float swing, float tick, Entity entity) {
float pi = PI * (float) Math.pow(swing, 16);
float mve = move * 0.6662F; // magic number ahoy
float srt = swing / 4;
float leftArm = MathHelper.cos(mve + pi) * srt;
float rightArm = MathHelper.cos(mve + PI + pi / 2) * srt;
float leftLeg = MathHelper.cos(mve + PI - (pi * 0.4f)) * srt;
float rightLeg = MathHelper.cos(mve + pi * 0.2f) * srt;
bipedLeftArm.rotateAngleX = leftArm;
bipedRightArm.rotateAngleX = rightArm;
bipedLeftLeg.rotateAngleX = leftLeg;
bipedRightLeg.rotateAngleX = rightLeg;
bipedLeftArm.rotateAngleY = 0;
bipedRightArm.rotateAngleY = 0;
bipedLeftLeg.rotateAngleY = 0;
bipedRightLeg.rotateAngleY = 0;
}
private float getLegOutset() {
if (isSleeping) return 2.6f;
if (isCrouching()) return smallArms ? 1 : 0;
return 4;
}
protected float getLegSpread() {
return rainboom ? 2 : 1;
protected float getArmRotationY() {
return smallArms ? 8.5f : super.getArmRotationY();
}
protected void adjustLegs(float move, float swing, float tick) {
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5;
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5;
float spread = getLegSpread();
bipedRightArm.rotationPointZ = spread + sin;
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;
super.adjustLegs(move, swing, tick);
// Push the front legs back apart if we're a thin pony
if (smallArms) {
bipedLeftArm.rotationPointX++;
bipedLeftLeg.rotationPointX++;
}
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8;
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
}
protected void holdItem(float swing) {
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
alignArmForAction(bipedLeftArm, leftArmPose, both, swing);
alignArmForAction(bipedRightArm, rightArmPose, both, swing);
}
protected void alignArmForAction(ModelRenderer arm, ArmPose pose, boolean both, float swing) {
switch (pose) {
case ITEM:
float swag = 1;
if (!isFlying && both) {
swag -= (float)Math.pow(swing, 2);
}
float mult = 1 - swag/2;
arm.rotateAngleX = bipedLeftArm.rotateAngleX * mult - (PI / 10) * swag;
case EMPTY:
arm.rotateAngleY = 0;
break;
case BLOCK:
blockArm(arm);
break;
default:
}
}
private void blockArm(ModelRenderer arm) {
arm.rotateAngleX = arm.rotateAngleX / 2 - 0.9424779F;
arm.rotateAngleY = PI / 6;
}
protected void swingItem(Entity entity, float swingProgress) {
if (swingProgress > -9990.0F && !isSleeping) {
EnumHandSide mainSide = getMainHand(entity);
if (getArmPoseForSide(mainSide) == ArmPose.EMPTY) return;
swingArm(getArmForSide(mainSide));
}
}
protected void swingArm(ModelRenderer arm) {
float swing = 1 - (float)Math.pow(1 - swingProgress, 3);
float deltaX = MathHelper.sin(swing * PI);
float deltaZ = MathHelper.sin(swingProgress * PI);
float deltaAim = deltaZ * (0.7F - bipedHead.rotateAngleX) * 0.75F;
arm.rotateAngleX -= deltaAim + deltaX * 1.2F;
arm.rotateAngleZ = deltaZ * -0.4F;
arm.rotateAngleY += bipedBody.rotateAngleY * 2;
}
protected void swingArms(float tick) {
if (isSleeping) return;
float cos = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(tick * 0.067F) * 0.05F;
if (rightArmPose != ArmPose.EMPTY) {
bipedRightArm.rotateAngleZ += cos;
bipedRightArm.rotateAngleX += sin;
}
if (leftArmPose != ArmPose.EMPTY) {
bipedLeftArm.rotateAngleZ += cos;
bipedLeftArm.rotateAngleX += sin;
}
}
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
adjustNeck(rotateAngleX, rotationPointY, rotationPointZ);
}
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
bipedBody.rotateAngleX = rotateAngleX;
bipedBody.rotationPointY = rotationPointY;
bipedBody.rotationPointZ = rotationPointZ;
upperTorso.rotateAngleX = rotateAngleX;
upperTorso.rotationPointY = rotationPointY;
upperTorso.rotationPointZ = rotationPointZ;
}
protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
neck.setRotationPoint(NECK_ROT_X + rotateAngleX, rotationPointY, rotationPointZ);
}
/**
* Aligns legs to a sneaky position.
*/
protected void sneakLegs() {
bipedRightArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
bipedLeftArm.rotateAngleX -= SNEAK_LEG_X_ROTATION_ADJUSTMENT;
bipedLeftLeg.rotationPointY = bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_SNEAK;
}
protected void ponySleep() {
bipedRightArm.rotateAngleX = ROTATE_270;
bipedLeftArm.rotateAngleX = ROTATE_270;
bipedRightLeg.rotateAngleX = ROTATE_90;
bipedLeftLeg.rotateAngleX = ROTATE_90;
setHead(1, 2, isSneak ? -1 : 1);
AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0, 2, 6);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, 0, 2, 6);
AbstractPonyRenderer.shiftRotationPoint(bipedRightLeg, 0, 2, -8);
AbstractPonyRenderer.shiftRotationPoint(bipedLeftLeg, 0, 2, -8);
}
protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) {
if (rightArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedRightArm, tick, false);
if (leftArm == ArmPose.BOW_AND_ARROW) aimBowPony(bipedLeftArm, tick, false);
}
protected void aimBowPony(ModelRenderer arm, float tick, boolean shift) {
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;
if (shift) AbstractPonyRenderer.shiftRotationPoint(arm, 0, 0, 1);
}
protected void fixSpecialRotationPoints(float move) {
}
@Override
public void render(Entity entityIn, float move, float swing, float age, float headYaw, float headPitch, float scale) {
pushMatrix();
transform(BodyPart.HEAD);
renderHead(entityIn, move, swing, age, headYaw, headPitch, scale);
popMatrix();
pushMatrix();
transform(BodyPart.NECK);
renderNeck();
popMatrix();
pushMatrix();
transform(BodyPart.BODY);
renderBody(entityIn, move, swing, age, headYaw, headPitch, scale);
popMatrix();
pushMatrix();
transform(BodyPart.LEGS);
renderLegs();
popMatrix();
}
protected void renderHead(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) {
bipedHead.render(scale);
bipedHeadwear.render(scale);
bipedHead.postRender(scale);
}
protected void renderNeck() {
GlStateManager.scale(0.9, 0.9, 0.9);
neck.render(scale);
}
protected void renderBody(Entity entity, float move, float swing, float age, float headYaw, float headPitch, float scale) {
bipedBody.render(scale);
if (textureHeight == 64) {
bipedBodyWear.render(scale);
}
upperTorso.render(scale);
bipedBody.postRender(scale);
tail.render(metadata.getTail(), scale);
}
protected void renderLegs() {
if (!isSneak) bipedBody.postRender(scale);
bipedLeftArm.render(scale);
bipedRightArm.render(scale);
bipedLeftLeg.render(scale);
bipedRightLeg.render(scale);
if (textureHeight == 64) {
bipedLeftArmwear.render(scale);
bipedRightArmwear.render(scale);
bipedLeftLegwear.render(scale);
bipedRightLegwear.render(scale);
}
}
@Override
protected void initTextures() {
boxList.clear();
initHeadTextures();
initBodyTextures();
initLegTextures();
initTailTextures();
}
protected void initTailTextures() {
tail = new PonyTail(this);
}
protected void initHeadTextures() {
super.initHeadTextures();
bipedCape = new PonyRenderer(this, 0, 0).size(64, 32);
bipedHead = new PonyRenderer(this, 0, 0);
bipedHeadwear = new PonyRenderer(this, 32, 0);
snout = new PonySnout(this);
}
protected void initBodyTextures() {
bipedBody = new ModelRenderer(this, 16, 16);
if (textureHeight == 64) {
bipedBodyWear = new ModelRenderer(this, 16, 32);
}
upperTorso = new PlaneRenderer(this, 24, 0);
neck = new PlaneRenderer(this, 0, 16);
}
protected void initLegTextures() {
bipedLeftArm = new ModelRenderer(this, 32, 48);
bipedRightArm = new ModelRenderer(this, 40, 16);
bipedLeftArmwear = new ModelRenderer(this, 48, 48);
bipedRightArmwear = new ModelRenderer(this, 40, 32);
bipedLeftLeg = new ModelRenderer(this, 16, 48);
bipedRightLeg = new ModelRenderer(this, 0, 16);
bipedLeftLegwear = new ModelRenderer(this, 0, 48);
bipedRightLegwear = new ModelRenderer(this, 0, 32);
}
@Override
protected void initPositions(float yOffset, float stretch) {
initHeadPositions(yOffset, stretch);
initBodyPositions(yOffset, stretch);
initLegPositions(yOffset, stretch);
initTailPositions(yOffset, stretch);
}
protected void initTailPositions(float yOffset, float stretch) {
tail.init(yOffset, stretch);
}
protected void initHeadPositions(float yOffset, float stretch) {
snout.init(yOffset, stretch);
super.initHeadPositions(yOffset, stretch);
bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
((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)
.flipX()
.box(2, -6, 1, 2, 2, 2, stretch);
((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);
}
/**
* Creates the main torso and neck.
*/
protected void initBodyPositions(float yOffset, float stretch) {
bipedBody.addBox(-4, 4, -2, 8, 8, 4, stretch);
bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
bipedBodyWear.addBox(-4, 4, -2, 8, 8, 4, stretch + 0.25F);
bipedBodyWear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
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;
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;
}
protected int getArmWidth() {
return smallArms ? 3 : 4;
}
protected int getArmDepth() {
return 4;
}
protected void initLegPositions(float yOffset, float stretch) {
int armWidth = getArmWidth();
int armDepth = getArmDepth();
float rarmY = smallArms ? 8.5f : 8;
float rarmX = smallArms ? 2 : 3;
super.initLegPositions(yOffset, stretch);
if (smallArms) {
float armX = THIRDP_ARM_CENTRE_X - 2;
float armY = THIRDP_ARM_CENTRE_Y - 6;
float armZ = THIRDP_ARM_CENTRE_Z - 2;
bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedRightArm.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedRightLeg.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0);
bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0);
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
if (bipedLeftArmwear != null) {
bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedLeftArmwear.setRotationPoint(3, yOffset + rarmY, 0);
}
if (bipedRightArmwear != null) {
bipedRightArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedRightArmwear.setRotationPoint(-3, yOffset + rarmY, 0);
}
if (bipedLeftLegwear != null) {
bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(3, yOffset, 0);
}
if (bipedRightLegwear != null) {
bipedRightLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
bipedRightLegwear.setRotationPoint(-3, yOffset, 0);
}
}

View file

@ -13,7 +13,8 @@ public class ModelZombiePony extends ModelMobPony {
}
@Override
protected void rotateRightArm(float move, float tick) {
protected void adjustLegs(float move, float swing, float tick) {
super.adjustLegs(move, swing, tick);
if (rightArmPose != ArmPose.EMPTY) return;
if (islookAngleRight(move)) {
@ -23,11 +24,6 @@ public class ModelZombiePony extends ModelMobPony {
}
}
@Override
protected void rotateLeftArm(float move, float tick) {
// zombies are unidexterous.
}
@Override
protected void fixSpecialRotationPoints(float move) {
if (rightArmPose != ArmPose.EMPTY) return;