2016-11-17 05:45:04 +01:00
|
|
|
package com.minelittlepony.model;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2016-11-17 05:45:04 +01:00
|
|
|
import com.minelittlepony.PonyData;
|
|
|
|
import com.minelittlepony.PonySize;
|
|
|
|
import com.minelittlepony.model.pony.ModelHumanPlayer;
|
|
|
|
import com.minelittlepony.model.pony.ModelPlayerPony;
|
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;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
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;
|
|
|
|
|
|
|
|
import static net.minecraft.client.renderer.GlStateManager.rotate;
|
|
|
|
import static net.minecraft.client.renderer.GlStateManager.scale;
|
|
|
|
import static net.minecraft.client.renderer.GlStateManager.translate;
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
/**
|
|
|
|
* TODO move this into constructor and make separate classes for the races.
|
|
|
|
*/
|
2015-12-16 05:29:47 +01:00
|
|
|
public abstract class AbstractPonyModel extends ModelPlayer {
|
2015-12-09 04:14:42 +01:00
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
protected float scale = 0.0625F;
|
2016-01-19 06:34:07 +01:00
|
|
|
|
|
|
|
public ModelRenderer steveLeftArm;
|
|
|
|
public ModelRenderer steveRightArm;
|
|
|
|
public ModelRenderer steveLeftArmwear;
|
|
|
|
public ModelRenderer steveRightArmwear;
|
2016-01-26 09:20:12 +01:00
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
public boolean isFlying;
|
|
|
|
public boolean isSleeping;
|
2015-12-09 04:14:42 +01:00
|
|
|
|
|
|
|
public PonyData metadata = new PonyData();
|
2016-06-15 03:37:41 +02:00
|
|
|
public float motionPitch;
|
2015-12-09 04:14:42 +01:00
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2016-01-19 06:34:07 +01:00
|
|
|
public AbstractPonyModel(boolean arms) {
|
|
|
|
super(0, arms);
|
|
|
|
this.steveLeftArm = this.bipedLeftArm;
|
|
|
|
this.steveRightArm = this.bipedRightArm;
|
|
|
|
this.steveLeftArmwear = this.bipedLeftArmwear;
|
|
|
|
this.steveRightArmwear = this.bipedLeftArmwear;
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
public void init(float yOffset, float stretch) {
|
2015-12-14 09:29:10 +01:00
|
|
|
this.initTextures();
|
|
|
|
this.initPositions(yOffset, stretch);
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
protected void initTextures() {
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
protected void initPositions(float yOffset, float stretch) {
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2016-01-26 22:43:39 +01:00
|
|
|
@Override
|
2016-11-25 05:40:19 +01:00
|
|
|
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
|
2016-03-01 05:42:22 +01:00
|
|
|
if (doCancelRender()) {
|
2016-11-25 05:40:19 +01:00
|
|
|
super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
|
2016-03-01 05:42:22 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-11-25 05:40:19 +01:00
|
|
|
this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F;
|
2016-01-26 22:43:39 +01:00
|
|
|
this.steveRightArm.rotateAngleY = 0;
|
|
|
|
this.steveRightArm.rotateAngleZ = 0;
|
2016-11-25 05:40:19 +01:00
|
|
|
this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F;
|
2016-01-26 22:43:39 +01:00
|
|
|
this.steveLeftArm.rotateAngleY = 0;
|
|
|
|
this.steveLeftArm.rotateAngleZ = 0;
|
|
|
|
|
|
|
|
copyModelAngles(steveRightArm, steveRightArmwear);
|
|
|
|
copyModelAngles(steveLeftArm, steveLeftArmwear);
|
|
|
|
}
|
|
|
|
|
2015-08-02 00:36:33 +02:00
|
|
|
protected boolean doCancelRender() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-01 05:42:22 +01:00
|
|
|
public static void setRotationPoint(ModelRenderer aRenderer, float setX, float setY, float setZ) {
|
2015-12-14 09:29:10 +01:00
|
|
|
aRenderer.rotationPointX = setX;
|
|
|
|
aRenderer.rotationPointY = setY;
|
|
|
|
aRenderer.rotationPointZ = setZ;
|
|
|
|
}
|
|
|
|
|
2016-03-01 05:42:22 +01:00
|
|
|
public static void shiftRotationPoint(ModelRenderer aRenderer, float shiftX, float shiftY, float shiftZ) {
|
2015-12-14 09:29:10 +01:00
|
|
|
aRenderer.rotationPointX += shiftX;
|
|
|
|
aRenderer.rotationPointY += shiftY;
|
|
|
|
aRenderer.rotationPointZ += shiftZ;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void transform(BodyPart part) {
|
2016-04-07 05:49:28 +02:00
|
|
|
if (this instanceof ModelHumanPlayer)
|
2016-04-03 07:05:31 +02:00
|
|
|
return;
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isRiding) {
|
|
|
|
translate(0.0F, -0.6F, -0.2F);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2015-12-14 09:29:10 +01:00
|
|
|
rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
|
|
|
rotate(270.0F, 0.0F, 0.0F, 1.0F);
|
|
|
|
rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
|
|
|
rotate(180.0F, 0.0F, 0.0F, 1.0F);
|
|
|
|
rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
|
|
|
}
|
|
|
|
|
2015-12-15 06:32:57 +01:00
|
|
|
if (this.metadata.getSize() == PonySize.FOAL || isChild) {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSneak && !this.isFlying) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, -0.12F, 0.0F);
|
|
|
|
}
|
|
|
|
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2016-07-10 05:57:05 +02:00
|
|
|
translate(0.0F, -1.2F, 0.25F);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isRiding) {
|
|
|
|
translate(0, -.1, 0);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
switch (part) {
|
2016-11-25 05:40:19 +01:00
|
|
|
case NECK:
|
|
|
|
case HEAD:
|
|
|
|
translate(0.0F, 0.76F, 0.0F);
|
|
|
|
scale(0.9F, 0.9F, 0.9F);
|
|
|
|
if (part == BodyPart.HEAD)
|
|
|
|
break;
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, -0.01F, 0.15F);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
break;
|
2016-11-25 05:40:19 +01:00
|
|
|
case BODY:
|
|
|
|
case TAIL:
|
|
|
|
translate(0.0F, 0.76F, -0.04F);
|
|
|
|
scale(0.6F, 0.6F, 0.6F);
|
|
|
|
break;
|
|
|
|
case LEGS:
|
|
|
|
translate(0.0F, 0.89F, 0.0F);
|
|
|
|
scale(0.6F, 0.41F, 0.6F);
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, 0.12F, 0.0F);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) {
|
|
|
|
translate(0.0F, -0.08F, 0.0F);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
break;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (this.metadata.getSize() == PonySize.LARGE) {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2016-07-10 05:57:05 +02:00
|
|
|
translate(0.0F, -0.7F, 0.2F);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (part) {
|
2016-11-25 05:40:19 +01:00
|
|
|
case HEAD:
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
translate(0.0F, -0.17F, -0.04F);
|
|
|
|
if (this.isSleeping) {
|
|
|
|
translate(0.0F, 0.0F, -0.1F);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, 0.15F, 0.0F);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
break;
|
|
|
|
case NECK:
|
|
|
|
translate(0.0F, -0.15F, -0.07F);
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, 0.0F, -0.05F);
|
|
|
|
}
|
2015-12-14 09:29:10 +01:00
|
|
|
|
2016-11-25 05:40:19 +01:00
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
translate(0.0F, -0.2F, -0.04F);
|
|
|
|
scale(1.15F, 1.2F, 1.2F);
|
|
|
|
break;
|
|
|
|
case TAIL:
|
|
|
|
translate(0.0F, -0.2F, 0.08F);
|
|
|
|
break;
|
|
|
|
case LEGS:
|
|
|
|
translate(0.0F, -0.14F, 0.0F);
|
|
|
|
scale(1.15F, 1.12F, 1.15F);
|
|
|
|
break;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
2015-12-16 05:29:47 +01:00
|
|
|
} else if (this.metadata.getSize() == PonySize.TALL) {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2016-07-10 05:57:05 +02:00
|
|
|
translate(0.0F, -0.65F, 0.25F);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (part) {
|
2016-11-25 05:40:19 +01:00
|
|
|
case HEAD:
|
|
|
|
translate(0.0F, -0.15F, 0.01F);
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, 0.05F, 0.0F);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NECK:
|
|
|
|
translate(0.0F, -0.19F, -0.01F);
|
|
|
|
scale(1.0F, 1.1F, 1.0F);
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, -0.06F, -0.04F);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case BODY:
|
|
|
|
case TAIL:
|
|
|
|
translate(0.0F, -0.1F, 0.0F);
|
|
|
|
scale(1.0F, 1.0F, 1.0F);
|
|
|
|
break;
|
|
|
|
case LEGS:
|
|
|
|
translate(0.0F, -0.25F, 0.03F);
|
|
|
|
scale(1.0F, 1.18F, 1.0F);
|
|
|
|
if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) {
|
|
|
|
translate(0.0F, 0.05F, 0.0F);
|
|
|
|
}
|
|
|
|
break;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
} else {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2016-07-10 05:57:05 +02:00
|
|
|
translate(0.0F, -0.75F, 0.25F);
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
2016-06-15 03:37:41 +02:00
|
|
|
if (part == BodyPart.HEAD) {
|
|
|
|
rotate(motionPitch, 1F, 0F, 0F);
|
|
|
|
}
|
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;
|
2015-12-14 09:29:10 +01:00
|
|
|
this.isFlying = pony.isFlying;
|
|
|
|
this.isSleeping = pony.isSleeping;
|
2016-11-12 04:42:46 +01:00
|
|
|
this.metadata = pony.metadata;
|
2016-12-04 08:19:37 +01:00
|
|
|
this.motionPitch = pony.motionPitch;
|
2015-12-14 09:29:10 +01:00
|
|
|
}
|
|
|
|
}
|
2016-04-09 03:39:52 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ModelRenderer getRandomModelBox(Random rand) {
|
|
|
|
// empty lists cause problems
|
2016-11-25 05:40:19 +01:00
|
|
|
ModelRenderer mr;
|
2016-04-09 03:39:52 +02:00
|
|
|
do {
|
|
|
|
// try until it's not
|
|
|
|
mr = super.getRandomModelBox(rand);
|
|
|
|
} while (mr.cubeList.isEmpty());
|
|
|
|
return mr;
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|