2015-11-17 06:09:04 +01:00
|
|
|
package com.brohoof.minelittlepony.model;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
import static net.minecraft.client.renderer.GlStateManager.rotate;
|
|
|
|
import static net.minecraft.client.renderer.GlStateManager.scale;
|
|
|
|
import static net.minecraft.client.renderer.GlStateManager.translate;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
2015-12-09 04:14:42 +01:00
|
|
|
import com.brohoof.minelittlepony.PonyData;
|
2015-12-14 09:29:10 +01:00
|
|
|
import com.brohoof.minelittlepony.PonySize;
|
|
|
|
import com.brohoof.minelittlepony.model.part.IPonyPart;
|
2016-04-07 05:49:28 +02:00
|
|
|
import com.brohoof.minelittlepony.model.pony.ModelHumanPlayer;
|
2015-12-16 05:29:47 +01:00
|
|
|
import com.brohoof.minelittlepony.model.pony.ModelPlayerPony;
|
2015-12-14 09:29:10 +01:00
|
|
|
import com.brohoof.minelittlepony.renderer.PlaneRenderer;
|
|
|
|
import com.google.common.collect.Lists;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
|
|
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
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;
|
|
|
|
import net.minecraft.client.renderer.GlStateManager;
|
2015-08-02 00:36:33 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.player.EnumPlayerModelParts;
|
|
|
|
import net.minecraft.item.EnumAction;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2016-01-26 22:43:39 +01:00
|
|
|
import net.minecraft.util.MathHelper;
|
2015-08-02 00:36:33 +02:00
|
|
|
|
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();
|
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
protected List<IPonyPart> modelParts = Lists.newArrayList();
|
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
|
|
|
}
|
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
public final void init(float yOffset, float stretch) {
|
2016-01-28 05:26:12 +01:00
|
|
|
this.boxList.clear();
|
2015-12-14 09:29:10 +01:00
|
|
|
this.initTextures();
|
|
|
|
this.initPositions(yOffset, stretch);
|
|
|
|
for (IPonyPart part : modelParts) {
|
|
|
|
part.init(this, yOffset, stretch);
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
protected void initTextures() {}
|
|
|
|
|
|
|
|
protected void initPositions(float yOffset, float stretch) {}
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2016-03-05 05:54:50 +01:00
|
|
|
protected void animate(float move, float swing, float tick, float horz, float vert) {}
|
2015-08-02 00:36:33 +02:00
|
|
|
|
2015-12-14 09:29:10 +01:00
|
|
|
protected void render() {}
|
2015-08-02 00:36:33 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(Entity player, float Move, float Moveswing, float Loop, float Right, float Down, float Scale) {
|
|
|
|
if (player instanceof AbstractClientPlayer) {
|
|
|
|
setModelVisibilities((AbstractClientPlayer) player);
|
|
|
|
}
|
|
|
|
if (!doCancelRender()) {
|
2016-03-01 05:42:22 +01:00
|
|
|
this.setRotationAngles(Move, Moveswing, Loop, Right, Down, Scale, player);
|
2015-12-14 09:29:10 +01:00
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
this.render();
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
for (IPonyPart part : modelParts) {
|
|
|
|
GlStateManager.pushMatrix();
|
|
|
|
part.render(metadata, scale);
|
|
|
|
GlStateManager.popMatrix();
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
} else {
|
|
|
|
super.render(player, Move, Moveswing, Loop, Right, Down, Scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-17 07:51:02 +02:00
|
|
|
@Override
|
2016-01-19 06:34:07 +01:00
|
|
|
public void renderRightArm() {
|
|
|
|
this.steveRightArm.render(0.0625F);
|
|
|
|
this.steveRightArmwear.render(0.0625F);
|
2015-08-17 07:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-01-19 06:34:07 +01:00
|
|
|
public void renderLeftArm() {
|
|
|
|
this.steveLeftArm.render(0.0625f);
|
|
|
|
this.steveLeftArmwear.render(0.0625f);
|
2015-08-17 07:51:02 +02:00
|
|
|
}
|
|
|
|
|
2016-01-26 22:43:39 +01:00
|
|
|
@Override
|
2016-03-01 05:42:22 +01:00
|
|
|
public void setRotationAngles(float Move, float Moveswing, float Loop, float Right, float Down, float Scale, Entity entityIn) {
|
|
|
|
if (doCancelRender()) {
|
|
|
|
super.setRotationAngles(Move, Moveswing, Loop, Right, Down, Scale, entityIn);
|
|
|
|
return;
|
|
|
|
}
|
2016-03-05 05:54:50 +01:00
|
|
|
this.animate(Move, Moveswing, Loop, Right, Down);
|
2016-03-01 05:42:22 +01:00
|
|
|
for (IPonyPart part : modelParts) {
|
2016-03-05 05:54:50 +01:00
|
|
|
part.animate(metadata, Move, Moveswing, Loop, Right, Down);
|
2016-03-01 05:42:22 +01:00
|
|
|
}
|
|
|
|
this.steveRightArm.rotateAngleX = MathHelper.cos(Move * 0.6662F + (float) Math.PI) * 2.0F * Moveswing * 0.5F;
|
2016-01-26 22:43:39 +01:00
|
|
|
this.steveRightArm.rotateAngleY = 0;
|
|
|
|
this.steveRightArm.rotateAngleZ = 0;
|
2016-03-01 05:42:22 +01:00
|
|
|
this.steveLeftArm.rotateAngleX = MathHelper.cos(Move * 0.6662F) * 2.0F * Moveswing * 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 06:07:38 +02:00
|
|
|
protected void setModelVisibilities(AbstractClientPlayer clientPlayer) {
|
2015-08-02 00:36:33 +02:00
|
|
|
ModelPlayer modelplayer = this;
|
|
|
|
|
|
|
|
if (clientPlayer.isSpectator()) {
|
|
|
|
modelplayer.setInvisible(false);
|
|
|
|
modelplayer.bipedHead.showModel = true;
|
|
|
|
modelplayer.bipedHeadwear.showModel = true;
|
|
|
|
} else {
|
|
|
|
ItemStack itemstack = clientPlayer.inventory.getCurrentItem();
|
|
|
|
modelplayer.setInvisible(true);
|
|
|
|
modelplayer.bipedHeadwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.HAT);
|
|
|
|
modelplayer.bipedBodyWear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
|
|
|
|
modelplayer.bipedLeftLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_PANTS_LEG);
|
|
|
|
modelplayer.bipedRightLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
|
|
|
|
modelplayer.bipedLeftArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
|
|
|
|
modelplayer.bipedRightArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
|
|
|
|
modelplayer.heldItemLeft = 0;
|
|
|
|
modelplayer.aimedBow = false;
|
|
|
|
modelplayer.isSneak = clientPlayer.isSneaking();
|
|
|
|
|
|
|
|
if (itemstack == null) {
|
|
|
|
modelplayer.heldItemRight = 0;
|
|
|
|
} else {
|
|
|
|
modelplayer.heldItemRight = 1;
|
|
|
|
|
|
|
|
if (clientPlayer.getItemInUseCount() > 0) {
|
|
|
|
EnumAction enumaction = itemstack.getItemUseAction();
|
|
|
|
|
|
|
|
if (enumaction == EnumAction.BLOCK) {
|
|
|
|
modelplayer.heldItemRight = 3;
|
|
|
|
} else if (enumaction == EnumAction.BOW) {
|
|
|
|
modelplayer.aimedBow = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 setRotationPoint(PlaneRenderer aPlaneRenderer, float setX, float setY, float setZ) {
|
2015-12-14 09:29:10 +01:00
|
|
|
aPlaneRenderer.rotationPointX = setX;
|
|
|
|
aPlaneRenderer.rotationPointY = setY;
|
|
|
|
aPlaneRenderer.rotationPointZ = setZ;
|
|
|
|
}
|
|
|
|
|
2016-03-01 05:42:22 +01:00
|
|
|
public static void shiftRotationPoint(PlaneRenderer aPlaneRenderer, float shiftX, float shiftY, float shiftZ) {
|
2015-12-14 09:29:10 +01:00
|
|
|
aPlaneRenderer.rotationPointX += shiftX;
|
|
|
|
aPlaneRenderer.rotationPointY += shiftY;
|
|
|
|
aPlaneRenderer.rotationPointZ += shiftZ;
|
|
|
|
}
|
|
|
|
|
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) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, -1.0F, 0.25F);
|
|
|
|
}
|
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) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
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-16 05:29:47 +01:00
|
|
|
if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, -0.08F, 0.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (this.metadata.getSize() == PonySize.LARGE) {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, -0.47F, 0.2F);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (part) {
|
|
|
|
case HEAD:
|
|
|
|
|
|
|
|
translate(0.0F, -0.17F, -0.04F);
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, 0.0F, -0.1F);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, 0.15F, 0.0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NECK:
|
|
|
|
translate(0.0F, -0.15F, -0.07F);
|
|
|
|
if (this.isSneak && !this.isFlying) {
|
|
|
|
translate(0.0F, 0.0F, -0.05F);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-16 05:29:47 +01:00
|
|
|
} else if (this.metadata.getSize() == PonySize.TALL) {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, -0.43F, 0.25F);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (part) {
|
|
|
|
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);
|
2015-12-16 05:29:47 +01:00
|
|
|
if (this instanceof ModelPlayerPony && ((ModelPlayerPony) this).rainboom) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, 0.05F, 0.0F);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
2016-01-26 09:20:12 +01:00
|
|
|
if (this.isSleeping) {
|
2015-12-14 09:29:10 +01:00
|
|
|
translate(0.0F, -0.535F, 0.25F);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@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;
|
|
|
|
}
|
|
|
|
}
|
2015-08-02 00:36:33 +02:00
|
|
|
}
|