2016-11-17 05:45:04 +01:00
|
|
|
package com.minelittlepony.model;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2018-04-29 14:22:26 +02:00
|
|
|
import com.minelittlepony.model.armour.ModelPonyArmor;
|
2018-04-25 16:40:47 +02:00
|
|
|
import com.minelittlepony.model.armour.PonyArmor;
|
2018-04-28 18:13:35 +02:00
|
|
|
import com.minelittlepony.model.capabilities.IModel;
|
2018-05-11 13:52:42 +02:00
|
|
|
import com.minelittlepony.model.capabilities.IModelPart;
|
2018-04-29 14:22:26 +02:00
|
|
|
import com.minelittlepony.model.components.PonySnout;
|
|
|
|
import com.minelittlepony.model.components.PonyTail;
|
2018-04-25 13:02:10 +02:00
|
|
|
import com.minelittlepony.pony.data.IPonyData;
|
|
|
|
import com.minelittlepony.pony.data.PonyData;
|
|
|
|
import com.minelittlepony.pony.data.PonySize;
|
2018-04-29 14:22:26 +02:00
|
|
|
import com.minelittlepony.render.AbstractPonyRenderer;
|
|
|
|
import com.minelittlepony.render.PonyRenderer;
|
|
|
|
import com.minelittlepony.render.plane.PlaneRenderer;
|
2018-04-24 14:55:32 +02:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
import net.minecraft.client.model.ModelBase;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.client.model.ModelPlayer;
|
2015-12-14 09:29:10 +01:00
|
|
|
import net.minecraft.client.model.ModelRenderer;
|
2018-04-29 14:22:26 +02:00
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
2018-04-27 20:37:54 +02:00
|
|
|
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 java.util.Random;
|
|
|
|
|
2016-12-29 09:07:43 +01:00
|
|
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
2018-04-29 14:22:26 +02:00
|
|
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
2016-11-25 05:40:19 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
/**
|
2018-04-29 14:22:26 +02:00
|
|
|
* Foundation class for all types of ponies.
|
2016-11-25 05:40:19 +01:00
|
|
|
*/
|
2018-04-28 18:13:35 +02:00
|
|
|
public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
2015-12-09 04:14:42 +01:00
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
public boolean isFlying;
|
|
|
|
public boolean isSleeping;
|
2018-06-03 22:23:32 +02:00
|
|
|
public boolean isSwimming;
|
2015-12-09 04:14:42 +01:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
/**
|
|
|
|
* Associcated pony data.
|
|
|
|
*/
|
2018-04-24 14:55:32 +02:00
|
|
|
public IPonyData metadata = new PonyData();
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
/**
|
|
|
|
* Vertical pitch whilst flying.
|
|
|
|
*/
|
2016-06-15 03:37:41 +02:00
|
|
|
public float motionPitch;
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
/**
|
|
|
|
* Flag indicating that this model is performing a rainboom (flight).
|
|
|
|
*/
|
2018-05-10 18:24:27 +02:00
|
|
|
protected boolean rainboom;
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-29 14:22:26 +02:00
|
|
|
public PlaneRenderer upperTorso;
|
|
|
|
public PlaneRenderer neck;
|
|
|
|
|
2018-05-11 13:52:42 +02:00
|
|
|
public IModelPart tail;
|
2018-04-29 14:22:26 +02:00
|
|
|
public PonySnout snout;
|
|
|
|
|
2016-01-19 06:34:07 +01:00
|
|
|
public AbstractPonyModel(boolean arms) {
|
|
|
|
super(0, arms);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2018-04-29 14:22:26 +02:00
|
|
|
@Override
|
|
|
|
public PonyArmor createArmour() {
|
|
|
|
return new PonyArmor(new ModelPonyArmor(), new ModelPonyArmor());
|
|
|
|
}
|
|
|
|
|
2018-05-10 18:24:27 +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-06-03 16:38:03 +02:00
|
|
|
rainboom = canFly() && Math.sqrt(entity.motionX * entity.motionX + entity.motionZ * entity.motionZ) > 0.4F;
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the model's various rotation angles.
|
|
|
|
*
|
|
|
|
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
|
|
|
|
* @param swing Degree to which each 'limb' swings.
|
2018-06-03 16:38:03 +02:00
|
|
|
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
2018-05-01 12:38:13 +02:00
|
|
|
* @param headYaw Horizontal head motion in radians.
|
|
|
|
* @param headPitch Vertical head motion in radians.
|
|
|
|
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
|
|
|
|
* @param entity The entity we're being called for.
|
|
|
|
*/
|
2018-04-29 14:22:26 +02:00
|
|
|
@Override
|
2018-05-01 12:38:13 +02:00
|
|
|
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
|
2018-05-10 18:24:27 +02:00
|
|
|
checkRainboom(entity, swing);
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2018-06-03 16:38:03 +02:00
|
|
|
shakeBody(move, swing, getWobbleAmount(), ticks);
|
|
|
|
rotateLegs(move, swing, ticks, entity);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-10 18:24:27 +02:00
|
|
|
if (!rainboom) {
|
|
|
|
holdItem(swing);
|
|
|
|
}
|
2018-05-01 12:38:13 +02:00
|
|
|
swingItem(entity);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
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;
|
2018-05-01 12:38:13 +02:00
|
|
|
swingArms(ticks);
|
2018-04-29 14:22:26 +02:00
|
|
|
setHead(0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isSleeping) ponySleep();
|
|
|
|
|
|
|
|
animateWears();
|
|
|
|
|
2018-05-01 16:46:59 +02:00
|
|
|
snout.setGender(metadata.getGender());
|
2018-04-29 14:22:26 +02:00
|
|
|
}
|
|
|
|
|
2018-06-02 20:05:22 +02:00
|
|
|
protected float getWobbleAmount() {
|
2018-06-03 16:38:03 +02:00
|
|
|
|
|
|
|
if (swingProgress <= 0) {
|
2018-06-02 20:05:22 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2018-06-03 16:38:03 +02:00
|
|
|
|
2018-06-03 19:59:55 +02:00
|
|
|
return MathHelper.sin(MathHelper.sqrt(swingProgress) * PI * 2) * 0.04F;
|
2018-06-02 20:05:22 +02:00
|
|
|
}
|
|
|
|
|
2018-04-29 14:22:26 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the model's various rotation angles.
|
|
|
|
*
|
|
|
|
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
|
|
|
|
* @param swing Degree to which each 'limb' swings.
|
|
|
|
* @param bodySwing Horizontal (Y) body rotation.
|
|
|
|
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
|
|
|
*/
|
2018-06-03 16:38:03 +02:00
|
|
|
protected void shakeBody(float move, float swing, float bodySwing, float ticks) {
|
2018-06-03 19:59:55 +02:00
|
|
|
tail.setRotationAndAngles(rainboom, move, swing, bodySwing * 5, ticks);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-01 12:38:13 +02:00
|
|
|
* Sets the head rotation point.
|
2018-04-29 14:22:26 +02:00
|
|
|
*/
|
|
|
|
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.
|
|
|
|
*
|
2018-05-01 12:38:13 +02:00
|
|
|
* @param x New rotation X
|
|
|
|
* @param y New rotation Y
|
2018-04-29 14:22:26 +02:00
|
|
|
*/
|
|
|
|
protected void updateHeadRotation(float x, float y) {
|
|
|
|
bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY = y;
|
|
|
|
bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX = x;
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Used to set the legs rotation based on walking/crouching animations.
|
|
|
|
*
|
|
|
|
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
|
|
|
|
*
|
|
|
|
*/
|
2018-06-03 16:38:03 +02:00
|
|
|
protected void rotateLegs(float move, float swing, float ticks, Entity entity) {
|
2018-05-10 18:34:55 +02:00
|
|
|
if (isFlying()) {
|
2018-05-01 12:38:13 +02:00
|
|
|
rotateLegsInFlight(move, swing, ticks, entity);
|
2018-04-29 14:22:26 +02:00
|
|
|
} else {
|
2018-05-01 12:38:13 +02:00
|
|
|
rotateLegsOnGround(move, swing, ticks, entity);
|
2018-04-29 14:22:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bipedRightArm.rotateAngleZ = 0;
|
2018-06-03 16:38:03 +02:00
|
|
|
bipedLeftArm.rotateAngleZ = 0;
|
|
|
|
|
|
|
|
float sin = MathHelper.sin(bipedBody.rotateAngleY) * 5;
|
|
|
|
float cos = MathHelper.cos(bipedBody.rotateAngleY) * 5;
|
|
|
|
|
|
|
|
float spread = getLegSpread();
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-06-03 16:38:03 +02:00
|
|
|
bipedRightArm.rotationPointZ = spread + sin;
|
|
|
|
bipedLeftArm.rotationPointZ = spread - sin;
|
|
|
|
|
|
|
|
float legRPX = cos - getLegOutset();
|
|
|
|
|
|
|
|
bipedRightArm.rotationPointX = -legRPX;
|
|
|
|
bipedRightLeg.rotationPointX = -legRPX;
|
|
|
|
|
|
|
|
bipedLeftArm.rotationPointX = legRPX;
|
|
|
|
bipedLeftLeg.rotationPointX = legRPX;
|
|
|
|
|
|
|
|
bipedRightArm.rotateAngleY += bipedBody.rotateAngleY;
|
|
|
|
bipedLeftArm.rotateAngleY += bipedBody.rotateAngleY;
|
|
|
|
|
|
|
|
bipedRightArm.rotationPointY = bipedLeftArm.rotationPointY = 8;
|
|
|
|
bipedRightLeg.rotationPointZ = bipedLeftLeg.rotationPointZ = 10;
|
2018-04-29 14:22:26 +02:00
|
|
|
}
|
|
|
|
|
2018-06-03 16:38:03 +02:00
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Rotates legs in quopy fashion whilst flying.
|
|
|
|
*
|
|
|
|
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
|
|
|
|
* @param swing Degree to which each 'limb' swings.
|
|
|
|
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
|
|
|
* @param entity The entity we're being called for.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected void rotateLegsInFlight(float move, float swing, float ticks, Entity entity) {
|
2018-05-10 18:24:27 +02:00
|
|
|
float armX = rainboom ? ROTATE_270 : MathHelper.sin(-swing / 2);
|
|
|
|
float legX = rainboom ? ROTATE_90 : MathHelper.sin(swing / 2);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Rotates legs in quopy fashion for walking.
|
|
|
|
*
|
|
|
|
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
|
|
|
|
* @param swing Degree to which each 'limb' swings.
|
|
|
|
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
|
|
|
* @param entity The entity we're being called for.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected void rotateLegsOnGround(float move, float swing, float ticks, Entity entity) {
|
|
|
|
float angle = PI * (float) Math.pow(swing, 16);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
float baseRotation = move * 0.6662F; // magic number ahoy
|
|
|
|
float scale = swing / 4;
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
bipedLeftArm.rotateAngleX = MathHelper.cos(baseRotation + angle) * scale;
|
|
|
|
bipedRightArm.rotateAngleX = MathHelper.cos(baseRotation + PI + angle / 2) * scale;
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
bipedLeftLeg.rotateAngleX = MathHelper.cos(baseRotation + PI - (angle * 0.4f)) * scale;
|
|
|
|
bipedRightLeg.rotateAngleX = MathHelper.cos(baseRotation + angle / 5) * scale;
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
bipedLeftArm.rotateAngleY = 0;
|
|
|
|
bipedRightArm.rotateAngleY = 0;
|
|
|
|
|
|
|
|
bipedLeftLeg.rotateAngleY = 0;
|
|
|
|
bipedRightLeg.rotateAngleY = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected float getLegOutset() {
|
2018-04-29 23:06:34 +02:00
|
|
|
if (isSleeping) return 3.6f;
|
|
|
|
if (isCrouching()) return 1;
|
|
|
|
return 5;
|
2018-04-29 14:22:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected float getLegSpread() {
|
|
|
|
return rainboom ? 2 : 1;
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Adjusts legs as if holding an item. Delegates to the correct arm/leg/limb as neccessary.
|
|
|
|
*
|
|
|
|
* @param swing
|
|
|
|
*/
|
2018-04-29 14:22:26 +02:00
|
|
|
protected void holdItem(float swing) {
|
|
|
|
boolean both = leftArmPose == ArmPose.ITEM && rightArmPose == ArmPose.ITEM;
|
|
|
|
|
2018-06-03 16:38:03 +02:00
|
|
|
alignArmForAction(bipedLeftArm, leftArmPose, rightArmPose, both, swing, 1);
|
|
|
|
alignArmForAction(bipedRightArm, rightArmPose, leftArmPose, both, swing, -1);
|
2018-04-29 14:22:26 +02:00
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Aligns an arm for the appropriate arm pose
|
|
|
|
*
|
|
|
|
* @param arm The arm model to align
|
|
|
|
* @param pose The post to align to
|
|
|
|
* @param both True if we have something in both hands
|
|
|
|
* @param swing Degree to which each 'limb' swings.
|
|
|
|
*/
|
2018-06-03 16:38:03 +02:00
|
|
|
protected void alignArmForAction(ModelRenderer arm, ArmPose pose, ArmPose complement, boolean both, float swing, float reflect) {
|
2018-04-29 14:22:26 +02:00
|
|
|
switch (pose) {
|
|
|
|
case ITEM:
|
|
|
|
float swag = 1;
|
|
|
|
if (!isFlying && both) {
|
|
|
|
swag -= (float)Math.pow(swing, 2);
|
|
|
|
}
|
|
|
|
float mult = 1 - swag/2;
|
2018-06-03 13:23:27 +02:00
|
|
|
arm.rotateAngleX = arm.rotateAngleX * mult - (PI / 10) * swag;
|
2018-06-03 16:38:03 +02:00
|
|
|
arm.rotateAngleZ = -reflect * (PI / 15);
|
|
|
|
if (isSneak) {
|
|
|
|
arm.rotationPointX -= reflect * 2;
|
|
|
|
}
|
2018-04-29 14:22:26 +02:00
|
|
|
case EMPTY:
|
|
|
|
arm.rotateAngleY = 0;
|
|
|
|
break;
|
|
|
|
case BLOCK:
|
2018-06-03 17:30:53 +02:00
|
|
|
arm.rotateAngleX = (arm.rotateAngleX / 2 - 0.9424779F) - 0.3F;
|
|
|
|
arm.rotateAngleY = reflect * PI / 9;
|
|
|
|
arm.rotationPointX += reflect;
|
|
|
|
arm.rotationPointZ += 3;
|
|
|
|
if (isSneak) {
|
|
|
|
arm.rotationPointY += 4;
|
2018-06-03 16:38:03 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BOW_AND_ARROW:
|
|
|
|
aimBow(arm, swing);
|
2018-04-29 14:22:26 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-03 16:38:03 +02:00
|
|
|
protected void aimBow(ModelRenderer arm, float ticks) {
|
|
|
|
arm.rotateAngleX = ROTATE_270 + bipedHead.rotateAngleX + (MathHelper.sin(ticks * 0.067F) * 0.05F);
|
|
|
|
arm.rotateAngleY = bipedHead.rotateAngleY - 0.06F;
|
|
|
|
arm.rotateAngleZ = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
|
|
|
|
if (isSneak) {
|
|
|
|
arm.rotationPointY += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Animates arm swinging. Delegates to the correct arm/leg/limb as neccessary.
|
|
|
|
*
|
|
|
|
* @param entity The entity we are being called for.
|
|
|
|
*/
|
|
|
|
protected void swingItem(Entity entity) {
|
2018-06-03 16:38:03 +02:00
|
|
|
if (swingProgress > 0 && !isSleeping) {
|
2018-04-29 14:22:26 +02:00
|
|
|
EnumHandSide mainSide = getMainHand(entity);
|
|
|
|
|
|
|
|
swingArm(getArmForSide(mainSide));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Animates arm swinging.
|
|
|
|
*
|
|
|
|
* @param arm The arm to swing
|
|
|
|
*/
|
2018-04-29 14:22:26 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Animates the walking animation.
|
|
|
|
*
|
|
|
|
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
|
|
|
*/
|
|
|
|
protected void swingArms(float ticks) {
|
2018-04-29 14:22:26 +02:00
|
|
|
if (isSleeping) return;
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
|
|
|
|
float sin = MathHelper.sin(ticks * 0.067F) * 0.05F;
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
public void init(float yOffset, float stretch) {
|
2018-05-01 12:38:13 +02:00
|
|
|
// TODO: Splitting things like this isn't strictly neccessary and just complicates things.
|
2018-04-25 21:29:49 +02:00
|
|
|
initTextures();
|
2018-04-26 16:01:31 +02:00
|
|
|
initPositions(yOffset, stretch);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Loads texture values.
|
|
|
|
*/
|
2018-04-29 14:22:26 +02:00
|
|
|
protected void initTextures() {
|
|
|
|
boxList.clear();
|
|
|
|
initHeadTextures();
|
|
|
|
initBodyTextures();
|
|
|
|
initLegTextures();
|
|
|
|
initTailTextures();
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Loads texture positions and boxes. Pretty much just finishes the job of initTextures.
|
|
|
|
*/
|
2018-04-29 14:22:26 +02:00
|
|
|
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(4, 0) .addEastPlane( 4, -4, 4, 8, 4, stretch)
|
2018-04-29 20:18:57 +02:00
|
|
|
.tex(56, 0) .addBottomPlane(-4, 4, -4, 8, 8, stretch)
|
2018-04-29 14:22:26 +02:00
|
|
|
.tex(36, 16) .addBackPlane(-4, -4, 8, 8, 4, stretch)
|
|
|
|
.addBackPlane(-4, 0, 8, 8, 4, stretch)
|
|
|
|
.addBottomPlane(-4, 4, 4, 8, 4, stretch)
|
2018-04-30 11:49:29 +02:00
|
|
|
.flipZ().tex(32, 20).addTopPlane(-4, -4, -4, 8, 12, stretch)
|
|
|
|
.tex(24, 0).addWestPlane(-4, -4, -4, 8, 8, stretch)
|
2018-04-29 14:22:26 +02:00
|
|
|
.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();
|
|
|
|
|
2018-04-29 18:00:26 +02:00
|
|
|
float armX = THIRDP_ARM_CENTRE_X;
|
2018-04-29 14:22:26 +02:00
|
|
|
float armY = THIRDP_ARM_CENTRE_Y - 6;
|
2018-04-29 18:00:26 +02:00
|
|
|
float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth;
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
bipedLeftArm .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
|
2018-04-29 18:00:26 +02:00
|
|
|
bipedRightArm.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
bipedLeftLeg .addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch);
|
2018-04-29 18:00:26 +02:00
|
|
|
bipedRightLeg.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
bipedLeftArm .setRotationPoint( rarmX, yOffset + rarmY, 0);
|
|
|
|
bipedRightArm.setRotationPoint(-rarmX, yOffset + rarmY, 0);
|
|
|
|
|
|
|
|
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
|
|
|
|
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
|
|
|
|
|
2018-05-01 16:46:59 +02:00
|
|
|
bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
|
|
|
bipedLeftArmwear.setRotationPoint(rarmX, yOffset + rarmY, 0);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-01 16:46:59 +02:00
|
|
|
bipedRightArmwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
|
|
|
bipedRightArmwear.setRotationPoint(-rarmX, yOffset + rarmY, 0);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-01 16:46:59 +02:00
|
|
|
bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
|
|
|
bipedRightLegwear.setRotationPoint(rarmX, yOffset, 0);
|
2018-04-29 14:22:26 +02:00
|
|
|
|
2018-05-01 16:46:59 +02:00
|
|
|
bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
|
|
|
bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0);
|
2018-04-29 14:22:26 +02:00
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2018-04-27 20:37:54 +02:00
|
|
|
public ArmPose getArmPoseForSide(EnumHandSide side) {
|
|
|
|
return side == EnumHandSide.RIGHT ? rightArmPose : leftArmPose;
|
|
|
|
}
|
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
@Override
|
2018-05-10 18:24:27 +02:00
|
|
|
public IPonyData getMetadata() {
|
|
|
|
return metadata;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-05-10 18:24:27 +02:00
|
|
|
@Override
|
|
|
|
public boolean isCrouching() {
|
|
|
|
return !rainboom && isSneak && !isFlying;
|
2018-04-26 16:01:31 +02:00
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2018-05-10 18:24:27 +02:00
|
|
|
@Override
|
|
|
|
public boolean isGoingFast() {
|
|
|
|
return rainboom;
|
|
|
|
}
|
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
@Override
|
|
|
|
public boolean isFlying() {
|
2018-05-10 18:34:55 +02:00
|
|
|
return isFlying && canFly();
|
2018-04-28 18:13:35 +02:00
|
|
|
}
|
|
|
|
|
2018-06-03 22:23:32 +02:00
|
|
|
@Override
|
|
|
|
public boolean isSwimming() {
|
|
|
|
return isSwimming;
|
|
|
|
}
|
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
@Override
|
2018-04-26 16:01:31 +02:00
|
|
|
public boolean isChild() {
|
|
|
|
return metadata.getSize() == PonySize.FOAL || isChild;
|
|
|
|
}
|
|
|
|
|
2018-04-28 18:13:35 +02:00
|
|
|
@Override
|
|
|
|
public float getSwingAmount() {
|
|
|
|
return swingProgress;
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
* Sets the model's various rotation angles.
|
|
|
|
*
|
|
|
|
* @param entity The entity we're being called for.
|
|
|
|
* @param move Entity motion parameter - i.e. velocity in no specific direction used in bipeds to calculate step amount.
|
|
|
|
* @param swing Degree to which each 'limb' swings.
|
|
|
|
* @param ticks Total whole and partial ticks since the entity's existance. Used in animations together with {@code swing} and {@code move}.
|
|
|
|
* @param headYaw Horizontal head motion in radians.
|
|
|
|
* @param headPitch Vertical head motion in radians.
|
|
|
|
* @param scale Scaling factor used to render this model. Determined by the return value of {@link RenderLivingBase.prepareScale}. Usually {@code 0.0625F}.
|
|
|
|
*/
|
2018-04-29 14:22:26 +02:00
|
|
|
@Override
|
2018-05-11 13:52:42 +02:00
|
|
|
public void render(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
2018-04-29 14:22:26 +02:00
|
|
|
|
|
|
|
pushMatrix();
|
|
|
|
transform(BodyPart.HEAD);
|
2018-05-11 13:52:42 +02:00
|
|
|
renderHead(entity, move, swing, ticks, headYaw, headPitch, scale);
|
2018-04-29 14:22:26 +02:00
|
|
|
popMatrix();
|
|
|
|
|
|
|
|
pushMatrix();
|
|
|
|
transform(BodyPart.NECK);
|
2018-06-03 22:23:32 +02:00
|
|
|
renderNeck(scale);
|
2018-04-29 14:22:26 +02:00
|
|
|
popMatrix();
|
|
|
|
|
|
|
|
pushMatrix();
|
|
|
|
transform(BodyPart.BODY);
|
2018-05-11 13:52:42 +02:00
|
|
|
renderBody(entity, move, swing, ticks, headYaw, headPitch, scale);
|
2018-04-29 14:22:26 +02:00
|
|
|
popMatrix();
|
|
|
|
|
|
|
|
pushMatrix();
|
|
|
|
transform(BodyPart.LEGS);
|
2018-06-03 22:23:32 +02:00
|
|
|
renderLegs(scale);
|
2018-04-29 14:22:26 +02:00
|
|
|
popMatrix();
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Called to render the head.
|
|
|
|
*
|
|
|
|
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
2018-04-29 14:22:26 +02:00
|
|
|
bipedHead.render(scale);
|
|
|
|
bipedHeadwear.render(scale);
|
|
|
|
bipedHead.postRender(scale);
|
|
|
|
}
|
|
|
|
|
2018-06-03 22:23:32 +02:00
|
|
|
protected void renderNeck(float scale) {
|
2018-04-29 14:22:26 +02:00
|
|
|
GlStateManager.scale(0.9, 0.9, 0.9);
|
|
|
|
neck.render(scale);
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Called to render the head.
|
|
|
|
*
|
|
|
|
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
2018-04-29 14:22:26 +02:00
|
|
|
bipedBody.render(scale);
|
|
|
|
if (textureHeight == 64) {
|
|
|
|
bipedBodyWear.render(scale);
|
|
|
|
}
|
|
|
|
upperTorso.render(scale);
|
|
|
|
bipedBody.postRender(scale);
|
|
|
|
tail.render(scale);
|
|
|
|
}
|
|
|
|
|
2018-06-03 22:23:32 +02:00
|
|
|
protected void renderLegs(float scale) {
|
2018-04-29 14:22:26 +02:00
|
|
|
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);
|
|
|
|
}
|
2018-04-25 16:40:47 +02:00
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2018-04-29 11:56:26 +02:00
|
|
|
@Override
|
2015-12-14 09:29:10 +01:00
|
|
|
public void transform(BodyPart part) {
|
2018-06-02 23:32:01 +02:00
|
|
|
if (isRiding) translate(0, -0.4F, -0.2F);
|
2018-04-26 16:01:31 +02:00
|
|
|
|
|
|
|
if (isSleeping) {
|
2018-04-29 20:18:57 +02:00
|
|
|
rotate(90, 1, 0, 0);
|
2018-04-26 16:01:31 +02:00
|
|
|
rotate(180, 0, 1, 0);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
2018-04-29 20:18:57 +02:00
|
|
|
if (part == BodyPart.HEAD) {
|
|
|
|
rotate(motionPitch, 1, 0, 0);
|
|
|
|
}
|
|
|
|
|
2018-05-01 12:38:13 +02:00
|
|
|
// TODO: Get these out of here
|
2018-04-26 16:01:31 +02:00
|
|
|
if (isChild()) {
|
|
|
|
transformFoal(part);
|
|
|
|
} else if (metadata.getSize() == PonySize.LARGE) {
|
|
|
|
transformLarge(part);
|
|
|
|
} else if (metadata.getSize() == PonySize.TALL) {
|
|
|
|
transformTall(part);
|
2015-12-14 09:29:10 +01:00
|
|
|
} else {
|
2018-04-29 20:18:57 +02:00
|
|
|
if (isSleeping) translate(0, -0.61F, 0.25F);
|
2018-04-26 16:01:31 +02:00
|
|
|
}
|
2018-04-29 20:18:57 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
}
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
private void transformTall(BodyPart part) {
|
2018-04-29 20:18:57 +02:00
|
|
|
if (isSleeping) translate(0, -0.5F, 0.25F);
|
2018-04-26 16:01:31 +02:00
|
|
|
|
|
|
|
switch (part) {
|
|
|
|
case HEAD:
|
|
|
|
translate(0, -0.15F, 0.01F);
|
|
|
|
if (isCrouching()) translate(0, 0.05F, 0);
|
|
|
|
break;
|
|
|
|
case NECK:
|
|
|
|
translate(0, -0.19F, -0.01F);
|
|
|
|
scale(1, 1.1F, 1);
|
|
|
|
if (isCrouching()) translate(0, -0.06F, -0.04F);
|
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
case TAIL:
|
|
|
|
translate(0, -0.1F, 0);
|
|
|
|
scale(1, 1, 1);
|
|
|
|
break;
|
|
|
|
case LEGS:
|
|
|
|
translate(0, -0.25F, 0.03F);
|
|
|
|
scale(1, 1.18F, 1);
|
|
|
|
if (rainboom) translate(0, 0.05F, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
private void transformLarge(BodyPart part) {
|
2018-04-29 20:18:57 +02:00
|
|
|
if (isSleeping) translate(0, -0.98F, 0.2F);
|
2018-04-26 16:01:31 +02:00
|
|
|
|
|
|
|
switch (part) {
|
|
|
|
case HEAD:
|
|
|
|
translate(0, -0.17F, -0.04F);
|
|
|
|
if (isSleeping) translate(0, 0, -0.1F);
|
|
|
|
if (isCrouching()) translate(0, 0.15F, 0);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NECK:
|
|
|
|
translate(0, -0.15F, -0.07F);
|
|
|
|
if (isCrouching()) translate(0, 0, -0.05F);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
translate(0, -0.2F, -0.04F);
|
|
|
|
scale(1.15F, 1.2F, 1.2F);
|
|
|
|
break;
|
|
|
|
case TAIL:
|
|
|
|
translate(0, -0.2F, 0.08F);
|
|
|
|
break;
|
|
|
|
case LEGS:
|
|
|
|
translate(0, -0.14F, 0);
|
|
|
|
scale(1.15F, 1.12F, 1.15F);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
private void transformFoal(BodyPart part) {
|
2018-04-26 23:53:03 +02:00
|
|
|
if (isCrouching()) translate(0, -0.12F, 0);
|
2018-04-29 20:18:57 +02:00
|
|
|
if (isSleeping) translate(0, -1.48F, 0.25F);
|
2018-06-02 23:32:01 +02:00
|
|
|
if (isRiding) translate(0, 0.1F, 0);
|
2018-04-27 09:48:55 +02:00
|
|
|
|
2018-04-26 16:01:31 +02:00
|
|
|
switch (part) {
|
|
|
|
case NECK:
|
|
|
|
case HEAD:
|
|
|
|
translate(0, 0.76F, 0);
|
|
|
|
scale(0.9F, 0.9F, 0.9F);
|
|
|
|
if (part == BodyPart.HEAD)
|
|
|
|
break;
|
|
|
|
if (isCrouching()) translate(0, -0.01F, 0.15F);
|
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
case TAIL:
|
|
|
|
translate(0, 0.76F, -0.04F);
|
|
|
|
scale(0.6F, 0.6F, 0.6F);
|
|
|
|
break;
|
|
|
|
case LEGS:
|
|
|
|
translate(0, 0.89F, 0);
|
|
|
|
scale(0.6F, 0.41F, 0.6F);
|
|
|
|
if (isCrouching()) translate(0, 0.12F, 0);
|
|
|
|
if (rainboom) translate(0, -0.08F, 0);
|
|
|
|
break;
|
2016-06-15 03:37:41 +02:00
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* Copies this model's attributes from some other.
|
|
|
|
*/
|
2015-12-14 09:29:10 +01:00
|
|
|
@Override
|
|
|
|
public void setModelAttributes(ModelBase model) {
|
|
|
|
super.setModelAttributes(model);
|
2015-12-16 05:29:47 +01:00
|
|
|
if (model instanceof AbstractPonyModel) {
|
|
|
|
AbstractPonyModel pony = (AbstractPonyModel) model;
|
2018-04-25 21:29:49 +02:00
|
|
|
isFlying = pony.isFlying;
|
|
|
|
isSleeping = pony.isSleeping;
|
|
|
|
metadata = pony.metadata;
|
|
|
|
motionPitch = pony.motionPitch;
|
2018-04-26 16:01:31 +02:00
|
|
|
rainboom = pony.rainboom;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
2016-04-09 03:39:52 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ModelRenderer getRandomModelBox(Random rand) {
|
2018-04-25 22:01:31 +02:00
|
|
|
// grab one at random, but cycle through the list until you find one that's filled.
|
|
|
|
// Return if you find one, or if you get back to where you started in which case there isn't any.
|
2018-04-26 23:53:03 +02:00
|
|
|
int randomI = rand.nextInt(boxList.size());
|
|
|
|
int index = randomI;
|
2018-04-25 22:01:31 +02:00
|
|
|
|
2018-04-26 23:53:03 +02:00
|
|
|
ModelRenderer result;
|
2016-04-09 03:39:52 +02:00
|
|
|
do {
|
2018-04-26 23:53:03 +02:00
|
|
|
result = boxList.get(randomI);
|
|
|
|
if (!result.cubeList.isEmpty()) return result;
|
2018-04-25 22:01:31 +02:00
|
|
|
|
2018-04-26 23:53:03 +02:00
|
|
|
index = (index + 1) % boxList.size();
|
|
|
|
} while (index != randomI);
|
2018-04-25 22:01:31 +02:00
|
|
|
|
2018-04-26 23:53:03 +02:00
|
|
|
return result;
|
2016-04-09 03:39:52 +02:00
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|