Remove IPonyPart in favor of just a ModelBase.

This commit is contained in:
Matthew Messinger 2016-11-24 23:40:19 -05:00
parent ef0f069e34
commit e9f04db833
10 changed files with 102 additions and 259 deletions

View file

@ -1,30 +1,24 @@
package com.minelittlepony.model; package com.minelittlepony.model;
import com.google.common.collect.Lists;
import com.minelittlepony.PonyData; import com.minelittlepony.PonyData;
import com.minelittlepony.PonySize; import com.minelittlepony.PonySize;
import com.minelittlepony.model.part.IPonyPart;
import com.minelittlepony.model.pony.ModelHumanPlayer; import com.minelittlepony.model.pony.ModelHumanPlayer;
import com.minelittlepony.model.pony.ModelPlayerPony; import com.minelittlepony.model.pony.ModelPlayerPony;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelPlayer; import net.minecraft.client.model.ModelPlayer;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EnumPlayerModelParts;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import java.util.List;
import java.util.Random; import java.util.Random;
import static net.minecraft.client.renderer.GlStateManager.rotate; import static net.minecraft.client.renderer.GlStateManager.rotate;
import static net.minecraft.client.renderer.GlStateManager.scale; import static net.minecraft.client.renderer.GlStateManager.scale;
import static net.minecraft.client.renderer.GlStateManager.translate; import static net.minecraft.client.renderer.GlStateManager.translate;
/**
* TODO move this into constructor and make separate classes for the races.
*/
public abstract class AbstractPonyModel extends ModelPlayer { public abstract class AbstractPonyModel extends ModelPlayer {
protected float scale = 0.0625F; protected float scale = 0.0625F;
@ -40,7 +34,6 @@ public abstract class AbstractPonyModel extends ModelPlayer {
public PonyData metadata = new PonyData(); public PonyData metadata = new PonyData();
public float motionPitch; public float motionPitch;
protected List<IPonyPart> modelParts = Lists.newArrayList();
public AbstractPonyModel(boolean arms) { public AbstractPonyModel(boolean arms) {
super(0, arms); super(0, arms);
@ -50,12 +43,9 @@ public abstract class AbstractPonyModel extends ModelPlayer {
this.steveRightArmwear = this.bipedLeftArmwear; this.steveRightArmwear = this.bipedLeftArmwear;
} }
public final void init(float yOffset, float stretch) { public void init(float yOffset, float stretch) {
this.initTextures(); this.initTextures();
this.initPositions(yOffset, stretch); this.initPositions(yOffset, stretch);
for (IPonyPart part : modelParts) {
part.init(yOffset, stretch);
}
} }
protected void initTextures() { protected void initTextures() {
@ -64,46 +54,16 @@ public abstract class AbstractPonyModel extends ModelPlayer {
protected void initPositions(float yOffset, float stretch) { protected void initPositions(float yOffset, float stretch) {
} }
protected void animate(float move, float swing, float tick, float horz, float vert, Entity entityIn) {
}
protected void render() {
}
@Override @Override
public void render(Entity player, float Move, float Moveswing, float Loop, float Right, float Down, float Scale) { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
if (player instanceof AbstractClientPlayer) {
setModelVisibilities((AbstractClientPlayer) player);
}
if (!doCancelRender()) {
this.setRotationAngles(Move, Moveswing, Loop, Right, Down, Scale, player);
GlStateManager.pushMatrix();
this.render();
GlStateManager.popMatrix();
for (IPonyPart part : modelParts) {
GlStateManager.pushMatrix();
part.render(metadata, scale);
GlStateManager.popMatrix();
}
} else {
super.render(player, Move, Moveswing, Loop, Right, Down, Scale);
}
}
@Override
public void setRotationAngles(float Move, float Moveswing, float Loop, float Right, float Down, float Scale, Entity entityIn) {
if (doCancelRender()) { if (doCancelRender()) {
super.setRotationAngles(Move, Moveswing, Loop, Right, Down, Scale, entityIn); super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
return; return;
} }
this.animate(Move, Moveswing, Loop, Right, Down, entityIn); this.steveRightArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F + (float) Math.PI) * 2.0F * limbSwingAmount * 0.5F;
for (IPonyPart part : modelParts) {
part.animate(metadata, Move, Moveswing, Loop, Right, Down);
}
this.steveRightArm.rotateAngleX = MathHelper.cos(Move * 0.6662F + (float) Math.PI) * 2.0F * Moveswing * 0.5F;
this.steveRightArm.rotateAngleY = 0; this.steveRightArm.rotateAngleY = 0;
this.steveRightArm.rotateAngleZ = 0; this.steveRightArm.rotateAngleZ = 0;
this.steveLeftArm.rotateAngleX = MathHelper.cos(Move * 0.6662F) * 2.0F * Moveswing * 0.5F; this.steveLeftArm.rotateAngleX = MathHelper.cos(limbSwing * 0.6662F) * 2.0F * limbSwingAmount * 0.5F;
this.steveLeftArm.rotateAngleY = 0; this.steveLeftArm.rotateAngleY = 0;
this.steveLeftArm.rotateAngleZ = 0; this.steveLeftArm.rotateAngleZ = 0;
@ -111,69 +71,6 @@ public abstract class AbstractPonyModel extends ModelPlayer {
copyModelAngles(steveLeftArm, steveLeftArmwear); copyModelAngles(steveLeftArm, steveLeftArmwear);
} }
protected void setModelVisibilities(AbstractClientPlayer clientPlayer) {
ModelPlayer modelplayer = this;
if (clientPlayer.isSpectator()) {
modelplayer.setInvisible(false);
modelplayer.bipedHead.showModel = true;
modelplayer.bipedHeadwear.showModel = true;
} else {
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.isSneak = clientPlayer.isSneaking();
ItemStack main = clientPlayer.getHeldItemMainhand();
ArmPose mainPose;
if (main.isEmpty()) {
mainPose = ArmPose.EMPTY;
} else {
mainPose = ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 0) {
EnumAction enumaction = main.getItemUseAction();
if (enumaction == EnumAction.BLOCK) {
mainPose = ArmPose.BLOCK;
} else if (enumaction == EnumAction.BOW) {
mainPose = ArmPose.BOW_AND_ARROW;
}
}
}
ItemStack off = clientPlayer.getHeldItemOffhand();
ArmPose offPose;
if (off.isEmpty()) {
offPose = ArmPose.EMPTY;
} else {
offPose = ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 0) {
EnumAction enumaction = off.getItemUseAction();
if (enumaction == EnumAction.BLOCK) {
offPose = ArmPose.BLOCK;
} else if (enumaction == EnumAction.BOW) {
offPose = ArmPose.BOW_AND_ARROW;
}
}
}
if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) {
modelplayer.rightArmPose = mainPose;
modelplayer.leftArmPose = offPose;
} else {
modelplayer.leftArmPose = mainPose;
modelplayer.rightArmPose = offPose;
}
}
}
protected boolean doCancelRender() { protected boolean doCancelRender() {
return false; return false;
} }

View file

@ -1,13 +1,15 @@
package com.minelittlepony.model.part; package com.minelittlepony.model;
import com.minelittlepony.PonyData;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.PonyModelConstants;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
public class PegasusWings implements IPonyPart, PonyModelConstants { public class PegasusWings extends ModelBase implements PonyModelConstants {
private final AbstractPonyModel pony; private final AbstractPonyModel pony;
@ -17,12 +19,9 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
public ModelRenderer[] leftWingExt; public ModelRenderer[] leftWingExt;
public ModelRenderer[] rightWingExt; public ModelRenderer[] rightWingExt;
public PegasusWings(AbstractPonyModel pony) { public PegasusWings(AbstractPonyModel pony, float yOffset, float stretch) {
this.pony = pony; this.pony = pony;
}
@Override
public void init(float yOffset, float stretch) {
this.leftWing = new ModelRenderer[3]; this.leftWing = new ModelRenderer[3];
this.rightWing = new ModelRenderer[3]; this.rightWing = new ModelRenderer[3];
this.leftWingExt = new ModelRenderer[6]; this.leftWingExt = new ModelRenderer[6];
@ -47,10 +46,6 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
this.pony.boxList.remove(this.rightWingExt[i]); this.pony.boxList.remove(this.rightWingExt[i]);
} }
initPositions(yOffset, stretch);
}
private void initPositions(float yOffset, float stretch) {
this.leftWing[0].addBox(4.0F, 5.0F, 2.0F, 2, 6, 2, stretch); this.leftWing[0].addBox(4.0F, 5.0F, 2.0F, 2, 6, 2, stretch);
this.leftWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z); this.leftWing[0].setRotationPoint(HEAD_RP_X, WING_FOLDED_RP_Y + yOffset, WING_FOLDED_RP_Z);
this.leftWing[0].rotateAngleX = ROTATE_90; this.leftWing[0].rotateAngleX = ROTATE_90;
@ -96,10 +91,10 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
} }
@Override @Override
public void animate(PonyData metadata, float move, float swing, float tick, float horz, float vert) { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
float bodySwingRotation = 0.0F; float bodySwingRotation = 0.0F;
if (pony.swingProgress > -9990.0F && !metadata.hasMagic()) { if (pony.swingProgress > -9990.0F && !pony.metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F; bodySwingRotation = MathHelper.sin(MathHelper.sqrt(pony.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
} }
for (ModelRenderer aLeftWing : this.leftWing) { for (ModelRenderer aLeftWing : this.leftWing) {
@ -111,7 +106,7 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
if (pony.isSneak && !pony.isFlying) { if (pony.isSneak && !pony.isFlying) {
this.sneak(); this.sneak();
} else { } else {
this.unsneak(tick); this.unsneak(ageInTicks);
} }
@ -136,10 +131,12 @@ public class PegasusWings implements IPonyPart, PonyModelConstants {
} }
@Override @Override
public void render(PonyData data, float scale) { public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
pony.transform(BodyPart.BODY); pony.transform(BodyPart.BODY);
pony.bipedBody.postRender(scale); pony.bipedBody.postRender(scale);
if (data.getRace() != null && data.getRace().hasWings()) { if (pony.metadata.getRace() != null && pony.metadata.getRace().hasWings()) {
if (!pony.isFlying && !pony.isSneak) { if (!pony.isFlying && !pony.isSneak) {
for (ModelRenderer aLeftWing : this.leftWing) { for (ModelRenderer aLeftWing : this.leftWing) {

View file

@ -1,24 +1,21 @@
package com.minelittlepony.model.part; package com.minelittlepony.model;
import com.minelittlepony.PonyData;
import com.minelittlepony.PonyGender; import com.minelittlepony.PonyGender;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.renderer.PlaneRenderer; import com.minelittlepony.renderer.PlaneRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.Entity;
public class PonySnout extends AbstractHeadPart implements PonyModelConstants { public class PonySnout extends ModelBase implements PonyModelConstants {
private PonyGender gender;
private PlaneRenderer mare; private PlaneRenderer mare;
private PlaneRenderer stallion; private PlaneRenderer stallion;
public PonySnout(AbstractPonyModel pony) { public PonySnout(AbstractPonyModel pony, float yOffset, float stretch) {
super(pony); mare = new PlaneRenderer(pony);
}
@Override
public void init(float yOffset, float stretch) {
mare = new PlaneRenderer(this.pony);
mare.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); mare.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
mare.setTextureOffset(10, 14).addBackPlane(-2.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 2, 0, stretch); mare.setTextureOffset(10, 14).addBackPlane(-2.0F + HEAD_CENTRE_X, 2.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 2, 0, stretch);
@ -32,7 +29,9 @@ public class PonySnout extends AbstractHeadPart implements PonyModelConstants {
mare.setTextureOffset(11, 12).addWestPlane(-1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 1, 1, stretch); mare.setTextureOffset(11, 12).addWestPlane(-1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 1, 1, stretch);
mare.setTextureOffset(12, 12).addEastPlane(1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 1, 1, stretch); mare.setTextureOffset(12, 12).addEastPlane(1.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 1, 1, stretch);
stallion = new PlaneRenderer(this.pony); pony.bipedHead.addChild(mare);
stallion = new PlaneRenderer(pony);
stallion.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z); stallion.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
stallion.setTextureOffset(10, 13).addBackPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 3, 0, stretch); stallion.setTextureOffset(10, 13).addBackPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 3, 0, stretch);
@ -40,23 +39,17 @@ public class PonySnout extends AbstractHeadPart implements PonyModelConstants {
stallion.setTextureOffset(18, 7).addBottomPlane(-2.0F + HEAD_CENTRE_X, 4.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 0, 1, stretch); stallion.setTextureOffset(18, 7).addBottomPlane(-2.0F + HEAD_CENTRE_X, 4.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 4, 0, 1, stretch);
stallion.setTextureOffset(10, 13).addWestPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 3, 1, stretch); stallion.setTextureOffset(10, 13).addWestPlane(-2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 3, 1, stretch);
stallion.setTextureOffset(13, 13).addEastPlane(2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 3, 1, stretch); stallion.setTextureOffset(13, 13).addEastPlane(2.0F + HEAD_CENTRE_X, 1.0F + HEAD_CENTRE_Y, -5.0F + HEAD_CENTRE_Z, 0, 3, 1, stretch);
pony.bipedHead.addChild(stallion);
} }
@Override @Override
public void animate(PonyData metadata, float move, float swing, float tick, float horz, float vert) { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
mare.isHidden = metadata.getGender() != PonyGender.MARE; mare.isHidden = gender != PonyGender.MARE;
stallion.isHidden = metadata.getGender() != PonyGender.STALLION; stallion.isHidden = gender != PonyGender.STALLION;
} }
// @Override public void setGender(PonyGender gender) {
// public void render(PonyData data, float scale) { this.gender = gender;
// super.render(data, scale); }
// if (MineLittlePony.getConfig().snuzzles && data.getGender() != null) {
// PlaneRenderer[] muzzle = MUZZLES.get(data.getGender());
// for (int i = 0; i < muzzle.length; i++) {
// muzzle[i].render(scale);
// }
// }
// }
} }

View file

@ -1,26 +1,26 @@
package com.minelittlepony.model.part; package com.minelittlepony.model;
import com.minelittlepony.PonyData; import com.minelittlepony.PonyData;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.renderer.HornGlowRenderer; import com.minelittlepony.renderer.HornGlowRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.client.model.ModelBiped.ArmPose;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import static net.minecraft.client.renderer.GlStateManager.*; import static net.minecraft.client.renderer.GlStateManager.*;
public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants { public class UnicornHorn extends ModelBase implements PonyModelConstants {
protected final AbstractPonyModel pony;
private ModelRenderer horn; private ModelRenderer horn;
private HornGlowRenderer[] hornglow; private HornGlowRenderer[] hornglow;
public UnicornHorn(AbstractPonyModel pony) { public UnicornHorn(AbstractPonyModel pony, float yOffset, float stretch) {
super(pony); this.pony = pony;
}
@Override
public void init(float yOffset, float stretch) {
this.horn = new ModelRenderer(pony, 0, 3); this.horn = new ModelRenderer(pony, 0, 3);
this.hornglow = new HornGlowRenderer[2]; this.hornglow = new HornGlowRenderer[2];
for (int i = 0; i < hornglow.length; i++) { for (int i = 0; i < hornglow.length; i++) {
@ -36,8 +36,10 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants
} }
@Override @Override
public void render(PonyData data, float scale) { public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
super.render(data, scale);
PonyData data = pony.metadata;
if (data.getRace() != null && data.getRace().hasHorn()) { if (data.getRace() != null && data.getRace().hasHorn()) {
this.horn.render(scale); this.horn.render(scale);
if ((pony.leftArmPose != ArmPose.EMPTY || pony.rightArmPose != ArmPose.EMPTY) && data.hasMagic()) { if ((pony.leftArmPose != ArmPose.EMPTY || pony.rightArmPose != ArmPose.EMPTY) && data.hasMagic()) {

View file

@ -1,19 +0,0 @@
package com.minelittlepony.model.part;
import com.minelittlepony.PonyData;
import com.minelittlepony.model.AbstractPonyModel;
public abstract class AbstractHeadPart implements IPonyPart {
protected final AbstractPonyModel pony;
public AbstractHeadPart(AbstractPonyModel pony) {
this.pony = pony;
}
@Override
public void render(PonyData data, float scale) {}
@Override
public void animate(PonyData metadata, float move, float swing, float tick, float horz, float vert) {}
}

View file

@ -1,13 +0,0 @@
package com.minelittlepony.model.part;
import com.minelittlepony.PonyData;
public interface IPonyPart {
void init(float yOffset, float stretch);
void render(PonyData data, float scale);
void animate(PonyData metadata, float move, float swing, float tick, float horz, float vert);
}

View file

@ -1,22 +0,0 @@
package com.minelittlepony.model.part;
import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.PonyModelConstants;
public class PonyEars extends AbstractHeadPart implements PonyModelConstants {
public PonyEars(AbstractPonyModel pony) {
super(pony);
}
@Override
public void init(float yOffset, float stretch) {
this.pony.bipedHead.setTextureOffset(12, 16);
this.pony.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch);
this.pony.bipedHead.mirror = true;
this.pony.bipedHead.addBox(2.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch);
}
}

View file

@ -3,10 +3,9 @@ package com.minelittlepony.model.pony;
import com.minelittlepony.model.AbstractPonyModel; import com.minelittlepony.model.AbstractPonyModel;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.PonyModelConstants; import com.minelittlepony.model.PonyModelConstants;
import com.minelittlepony.model.part.PegasusWings; import com.minelittlepony.model.PegasusWings;
import com.minelittlepony.model.part.PonyEars; import com.minelittlepony.model.PonySnout;
import com.minelittlepony.model.part.PonySnout; import com.minelittlepony.model.UnicornHorn;
import com.minelittlepony.model.part.UnicornHorn;
import com.minelittlepony.renderer.PlaneRenderer; import com.minelittlepony.renderer.PlaneRenderer;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
@ -30,25 +29,29 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
public ModelRenderer unicornArmRight; public ModelRenderer unicornArmRight;
public ModelRenderer unicornArmLeft; public ModelRenderer unicornArmLeft;
public PlaneRenderer[] Tail; public PlaneRenderer[] Tail;
private PonySnout snout;
private UnicornHorn horn;
private PegasusWings wings;
public ModelPlayerPony(boolean smallArms) { public ModelPlayerPony(boolean smallArms) {
super(smallArms); super(smallArms);
this.smallArms = smallArms; this.smallArms = smallArms;
addParts();
} }
protected void addParts() { public void init(float yOffset, float stretch) {
modelParts.add(new PonyEars(this)); super.init(yOffset, stretch);
modelParts.add(new PonySnout(this)); snout = new PonySnout(this, yOffset, stretch);
modelParts.add(new UnicornHorn(this)); horn = new UnicornHorn(this, yOffset, stretch);
modelParts.add(new PegasusWings(this)); wings = new PegasusWings(this, yOffset, stretch);
} }
@Override @Override
public void animate(float move, float swing, float tick, float horz, float vert, Entity entity) { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
this.checkRainboom(entity, swing); super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
this.rotateHead(horz, vert);
this.swingTailZ(move, swing); this.checkRainboom(entityIn, limbSwingAmount);
this.rotateHead(netHeadYaw, headPitch);
this.swingTailZ(limbSwing, limbSwingAmount);
float bodySwingRotation = 0.0F; float bodySwingRotation = 0.0F;
if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
@ -78,9 +81,9 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
this.bipedHead.offsetZ = 0f; this.bipedHead.offsetZ = 0f;
this.bipedHeadwear.offsetY = 0f; this.bipedHeadwear.offsetY = 0f;
this.bipedHeadwear.offsetZ = 0f; this.bipedHeadwear.offsetZ = 0f;
this.setLegs(move, swing, tick, entity); this.setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn);
this.holdItem(swing); this.holdItem(limbSwingAmount);
this.swingItem(entity, this.swingProgress); this.swingItem(entityIn, this.swingProgress);
if (this.isSneak && !this.isFlying) { if (this.isSneak && !this.isFlying) {
this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
this.sneakLegs(); this.sneakLegs();
@ -114,20 +117,20 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
this.swingArms(tick); this.swingArms(ageInTicks);
this.setHead(0.0F, 0.0F, 0.0F); this.setHead(0.0F, 0.0F, 0.0F);
for (k1 = 0; k1 < tailstop; ++k1) { for (k1 = 0; k1 < tailstop; ++k1) {
setRotationPoint(this.Tail[k1], TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK); setRotationPoint(this.Tail[k1], TAIL_RP_X, TAIL_RP_Y, TAIL_RP_Z_NOTSNEAK);
if (this.rainboom) { if (this.rainboom) {
this.Tail[k1].rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(move); this.Tail[k1].rotateAngleX = ROTATE_90 + 0.1F * MathHelper.sin(limbSwing);
} else { } else {
this.Tail[k1].rotateAngleX = 0.5F * swing; this.Tail[k1].rotateAngleX = 0.5F * limbSwingAmount;
} }
} }
if (!this.rainboom) { if (!this.rainboom) {
this.swingTailX(tick); this.swingTailX(ageInTicks);
} }
} }
@ -143,14 +146,18 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
this.ponySleep(); this.ponySleep();
} }
this.aimBow(leftArmPose, rightArmPose, tick); this.aimBow(leftArmPose, rightArmPose, ageInTicks);
this.fixSpecialRotations(); this.fixSpecialRotations();
this.fixSpecialRotationPoints(move); this.fixSpecialRotationPoints(limbSwing);
animateWears(); animateWears();
this.bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0; this.bipedCape.rotationPointY = isSneak ? 2 : isRiding ? -4 : 0;
this.snout.setGender(this.metadata.getGender());
this.snout.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
this.wings.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
} }
private void animateWears() { private void animateWears() {
@ -569,11 +576,13 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
} }
@Override @Override
public void render() { public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
pushMatrix(); pushMatrix();
this.transform(BodyPart.HEAD); this.transform(BodyPart.HEAD);
this.renderHead(); this.renderHead();
this.horn.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
this.snout.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
popMatrix(); popMatrix();
pushMatrix(); pushMatrix();
@ -584,6 +593,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
pushMatrix(); pushMatrix();
this.transform(BodyPart.BODY); this.transform(BodyPart.BODY);
this.renderBody(); this.renderBody();
this.wings.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
this.renderTail(); this.renderTail();
popMatrix(); popMatrix();
@ -753,6 +763,12 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst
this.bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch); this.bipedCape.addBox(-5.0F, 0.0F, -1.0F, 10, 16, 1, stretch);
this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -4 + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch); this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -4 + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch);
this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2); this.bipedHead.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2);
// set ears
this.bipedHead.setTextureOffset(12, 16);
this.bipedHead.addBox(-4.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch);
this.bipedHead.mirror = true;
this.bipedHead.addBox(2.0F + HEAD_CENTRE_X, -6.0F + HEAD_CENTRE_Y, 1.0F + HEAD_CENTRE_Z, 2, 2, 2, stretch);
this.bipedHeadwear.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch + 0.5F); this.bipedHeadwear.addBox(-4.0F + HEAD_CENTRE_X, -4.0F + HEAD_CENTRE_Y, -4.0F + HEAD_CENTRE_Z, 8, 8, 8, stretch + 0.5F);
this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2); this.bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z - 2);
} }

View file

@ -17,8 +17,9 @@ public class ModelVillagerPony extends ModelPlayerPony {
} }
@Override @Override
public void animate(float move, float swing, float tick, float horz, float vert, Entity entity) { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
super.animate(move, swing, tick, horz, vert, entity); super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
float bodySwingRotation = 0.0F; float bodySwingRotation = 0.0F;
if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F;

View file

@ -1,7 +1,6 @@
package com.minelittlepony.model.pony.armor; package com.minelittlepony.model.pony.armor;
import com.minelittlepony.model.pony.ModelPlayerPony; import com.minelittlepony.model.pony.ModelPlayerPony;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
@ -19,14 +18,10 @@ public class ModelPonyArmor extends ModelPlayerPony {
} }
@Override @Override
protected void addParts() { public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn) {
// modelParts.add(new PonyEars());
}
@Override this.checkRainboom(entityIn, limbSwingAmount);
public void animate(float move, float swing, float tick, float horz, float vert, Entity entity) { this.rotateHead(netHeadYaw, headPitch);
this.checkRainboom(entity, swing);
this.rotateHead(horz, vert);
float bodySwingRotation = 0.0F; float bodySwingRotation = 0.0F;
if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) { if (this.swingProgress > -9990.0F && !this.metadata.hasMagic()) {
bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F; bodySwingRotation = MathHelper.sin(MathHelper.sqrt(this.swingProgress) * 3.1415927F * 2.0F) * 0.2F;
@ -40,9 +35,9 @@ public class ModelPonyArmor extends ModelPlayerPony {
this.extHead[0].offsetZ = 0f; this.extHead[0].offsetZ = 0f;
this.extHead[1].offsetY = 0f; this.extHead[1].offsetY = 0f;
this.extHead[1].offsetZ = 0f; this.extHead[1].offsetZ = 0f;
this.setLegs(move, swing, tick, entity); this.setLegs(limbSwing, limbSwingAmount, ageInTicks, entityIn);
this.holdItem(swing); this.holdItem(limbSwingAmount);
this.swingItem(entity, this.swingProgress); this.swingItem(entityIn, this.swingProgress);
if (this.isSneak && !this.isFlying) { if (this.isSneak && !this.isFlying) {
this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK); this.adjustBody(BODY_ROTATE_ANGLE_X_SNEAK, BODY_RP_Y_SNEAK, BODY_RP_Z_SNEAK);
this.sneakLegs(); this.sneakLegs();
@ -71,7 +66,7 @@ public class ModelPonyArmor extends ModelPlayerPony {
this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.bipedRightLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK; this.bipedLeftLeg.rotationPointY = FRONT_LEG_RP_Y_NOTSNEAK;
this.swingArms(tick); this.swingArms(ageInTicks);
this.setHead(0.0F, 0.0F, 0.0F); this.setHead(0.0F, 0.0F, 0.0F);
} }
@ -80,7 +75,7 @@ public class ModelPonyArmor extends ModelPlayerPony {
this.ponySleep(); this.ponySleep();
} }
this.aimBow(leftArmPose, rightArmPose, tick); this.aimBow(leftArmPose, rightArmPose, ageInTicks);
// this.fixSpecialRotationPoints(aniparams.move); // this.fixSpecialRotationPoints(aniparams.move);
} }
@ -284,10 +279,6 @@ public class ModelPonyArmor extends ModelPlayerPony {
this.syncLegs(); this.syncLegs();
} }
@Override
protected void setModelVisibilities(AbstractClientPlayer clientPlayer) {
}
@Override @Override
public void setInvisible(boolean invisible) { public void setInvisible(boolean invisible) {
super.setInvisible(invisible); super.setInvisible(invisible);