mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-29 23:48:00 +01:00
Cut all of the extra code from armour
This commit is contained in:
parent
76a9c23122
commit
28fce6ef5d
10 changed files with 121 additions and 325 deletions
|
@ -137,9 +137,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
||||||
|
|
||||||
animateWears();
|
animateWears();
|
||||||
|
|
||||||
if (snout != null) {
|
snout.setGender(metadata.getGender());
|
||||||
snout.setGender(metadata.getGender());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void adjustBodyRiding() {
|
protected void adjustBodyRiding() {
|
||||||
|
@ -629,25 +627,17 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
|
||||||
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
|
bipedLeftLeg .setRotationPoint( rarmX, yOffset, 0);
|
||||||
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
|
bipedRightLeg.setRotationPoint(-rarmX, yOffset, 0);
|
||||||
|
|
||||||
if (bipedLeftArmwear != null) {
|
bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
||||||
bipedLeftArmwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
bipedLeftArmwear.setRotationPoint(rarmX, yOffset + rarmY, 0);
|
||||||
bipedLeftArmwear.setRotationPoint(rarmX, yOffset + rarmY, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bipedRightArmwear != null) {
|
bipedRightArmwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
||||||
bipedRightArmwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
bipedRightArmwear.setRotationPoint(-rarmX, yOffset + rarmY, 0);
|
||||||
bipedRightArmwear.setRotationPoint(-rarmX, yOffset + rarmY, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bipedLeftLegwear != null) {
|
bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
||||||
bipedLeftLegwear.addBox(armX, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
bipedRightLegwear.setRotationPoint(rarmX, yOffset, 0);
|
||||||
bipedRightLegwear.setRotationPoint(rarmX, yOffset, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bipedRightLegwear != null) {
|
bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
||||||
bipedRightLegwear.addBox(armX - armWidth, armY, armZ, armWidth, 12, armDepth, stretch + 0.25f);
|
bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0);
|
||||||
bipedRightLegwear.setRotationPoint(-rarmX, yOffset, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArmPose getArmPoseForSide(EnumHandSide side) {
|
public ArmPose getArmPoseForSide(EnumHandSide side) {
|
||||||
|
|
|
@ -4,58 +4,23 @@ import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
import static com.minelittlepony.model.PonyModelConstants.*;
|
import static com.minelittlepony.model.PonyModelConstants.*;
|
||||||
|
|
||||||
import com.minelittlepony.model.ModelMobPony;
|
import com.minelittlepony.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.render.PonyRenderer;
|
import com.minelittlepony.render.PonyRenderer;
|
||||||
|
|
||||||
public class ModelPonyArmor extends ModelMobPony {
|
public class ModelPonyArmor extends AbstractPonyModel {
|
||||||
|
|
||||||
public PonyRenderer flankGuard;
|
public PonyRenderer flankGuard;
|
||||||
|
|
||||||
public PonyRenderer saddle;
|
public PonyRenderer saddle;
|
||||||
public PonyRenderer helmet;
|
|
||||||
|
|
||||||
public PonyRenderer leftLegging;
|
|
||||||
public PonyRenderer rightLegging;
|
|
||||||
|
|
||||||
public ModelPonyArmor() {
|
public ModelPonyArmor() {
|
||||||
super();
|
super(false);
|
||||||
textureHeight = 32;
|
textureHeight = 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setRotationAngles(float move, float swing, float ticks, float headYaw, float headPitch, float scale, Entity entity) {
|
protected void adjustBodyComponents(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
||||||
super.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
|
super.adjustBodyComponents(rotateAngleX, rotationPointY, rotationPointZ);
|
||||||
syncLegs();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void rotateLook(float move, float swing, float bodySwing, float ticks) {
|
|
||||||
bipedBody.rotateAngleY = bodySwing / 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void adjustBodyRiding() {
|
|
||||||
adjustBody(BODY_ROTATE_ANGLE_X_RIDING, BODY_RP_Y_RIDING, BODY_RP_Z_RIDING);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setHead(float posX, float posY, float posZ) {
|
|
||||||
super.setHead(posX, posY, posZ);
|
|
||||||
helmet.setRotationPoint(posX, posY, posZ);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateHeadRotation(float x, float y) {
|
|
||||||
super.updateHeadRotation(x, y);
|
|
||||||
helmet.rotateAngleX = x;
|
|
||||||
helmet.rotateAngleY = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void adjustBody(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
|
||||||
bipedBody.rotateAngleX = rotateAngleX;
|
|
||||||
bipedBody.rotationPointY = rotationPointY;
|
|
||||||
bipedBody.rotationPointZ = rotationPointZ;
|
|
||||||
|
|
||||||
flankGuard.rotateAngleX = rotateAngleX;
|
flankGuard.rotateAngleX = rotateAngleX;
|
||||||
flankGuard.rotationPointY = rotationPointY;
|
flankGuard.rotationPointY = rotationPointY;
|
||||||
|
@ -66,26 +31,8 @@ public class ModelPonyArmor extends ModelMobPony {
|
||||||
saddle.rotationPointZ = rotationPointZ;
|
saddle.rotationPointZ = rotationPointZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderHead(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
|
||||||
bipedHead.render(this.scale);
|
|
||||||
helmet.render(this.scale);
|
|
||||||
bipedHeadwear.render(this.scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void renderNeck() {
|
|
||||||
// TODO: Disabling the neck like this forces more complexity lower down
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void adjustNeck(float rotateAngleX, float rotationPointY, float rotationPointZ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
||||||
bipedBody.render(this.scale);
|
|
||||||
flankGuard.render(this.scale);
|
flankGuard.render(this.scale);
|
||||||
saddle.render(this.scale);
|
saddle.render(this.scale);
|
||||||
}
|
}
|
||||||
|
@ -98,101 +45,50 @@ public class ModelPonyArmor extends ModelMobPony {
|
||||||
saddle.postRender(scale);
|
saddle.postRender(scale);
|
||||||
saddle.showModel = isLegs;
|
saddle.showModel = isLegs;
|
||||||
}
|
}
|
||||||
bipedLeftArm.render(scale);
|
|
||||||
bipedRightArm.render(scale);
|
|
||||||
bipedLeftLeg.render(scale);
|
|
||||||
bipedRightLeg.render(scale);
|
|
||||||
rightLegging.render(scale);
|
|
||||||
leftLegging.render(scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
super.renderLegs();
|
||||||
protected void initTextures() {
|
|
||||||
initHeadTextures();
|
|
||||||
initBodyTextures();
|
|
||||||
initLegTextures();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initHeadTextures() {
|
|
||||||
bipedHead = new PonyRenderer(this, 0, 0);
|
|
||||||
bipedHeadwear = new PonyRenderer(this, 32, 0);
|
|
||||||
helmet = new PonyRenderer(this, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initBodyTextures() {
|
protected void initBodyTextures() {
|
||||||
bipedBody = new PonyRenderer(this, 16, 16);
|
super.initBodyTextures();
|
||||||
flankGuard = new PonyRenderer(this, 0, 0);
|
flankGuard = new PonyRenderer(this, 0, 0);
|
||||||
saddle = new PonyRenderer(this, 16, 8);
|
saddle = new PonyRenderer(this, 16, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initLegTextures() {
|
protected void initLegTextures() {
|
||||||
bipedRightArm = new PonyRenderer(this, 0, 16);
|
super.initLegTextures();
|
||||||
bipedRightLeg = new PonyRenderer(this, 0, 16);
|
|
||||||
|
|
||||||
bipedLeftArm = new PonyRenderer(this, 0, 16).flipX();
|
bipedLeftArm = new PonyRenderer(this, 0, 16).flipX();
|
||||||
|
bipedRightArm = new PonyRenderer(this, 0, 16);
|
||||||
|
|
||||||
bipedLeftLeg = new PonyRenderer(this, 0, 16).flipX();
|
bipedLeftLeg = new PonyRenderer(this, 0, 16).flipX();
|
||||||
|
bipedRightLeg = new PonyRenderer(this, 0, 16);
|
||||||
unicornArmRight = new PonyRenderer(this, 0, 16);
|
|
||||||
unicornArmLeft = new PonyRenderer(this, 0, 16);
|
|
||||||
|
|
||||||
leftLegging = new PonyRenderer(this, 48, 8);
|
|
||||||
rightLegging = new PonyRenderer(this, 48, 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void synchroniseLegs(AbstractPonyModel mainModel) {
|
||||||
protected void initTailPositions(float yOffset, float stretch) {
|
copyModelAngles(mainModel.bipedRightArm, bipedRightArm);
|
||||||
|
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm);
|
||||||
|
copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg);
|
||||||
|
copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initHeadPositions(float yOffset, float stretch) {
|
protected void initHeadPositions(float yOffset, float stretch) {
|
||||||
bipedHead .addBox(HEAD_CENTRE_X - 4, HEAD_CENTRE_Y - 4, HEAD_CENTRE_Z - 4, 8, 8, 8, stretch * 1.1F);
|
super.initHeadPositions(yOffset, stretch * 1.1F);
|
||||||
bipedHeadwear.addBox(HEAD_CENTRE_X - 4, HEAD_CENTRE_Y - 4, HEAD_CENTRE_Z - 4, 8, 8, 8, stretch * 1.1F + 0.5F);
|
((PonyRenderer)bipedHead).child()
|
||||||
|
.tex(0, 4).box(2, -6, 1, 2, 2, 2, stretch * 0.5F)
|
||||||
helmet.offset(HEAD_CENTRE_X, HEAD_CENTRE_Y, HEAD_CENTRE_Z)
|
.box(-4, -6, 1, 2, 2, 2, stretch * 0.5F);
|
||||||
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
|
||||||
.box(-4, -6, 1, 2, 2, 2, stretch * 0.5F)
|
|
||||||
.tex(0, 4).box( 2, -6, 1, 2, 2, 2, stretch * 0.5F);
|
|
||||||
|
|
||||||
bipedHead .setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
|
||||||
bipedHeadwear.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initBodyPositions(float yOffset, float stretch) {
|
protected void initBodyPositions(float yOffset, float stretch) {
|
||||||
bipedBody.setRotationPoint(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z);
|
super.initBodyPositions(yOffset, stretch);
|
||||||
bipedBody.addBox(-4.0F, 4.0F, -2.0F, 8, 8, 4, stretch);
|
|
||||||
|
|
||||||
flankGuard.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
flankGuard.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
||||||
.box(-4.0F, 4.0F, 6.0F, 8, 8, 8, stretch);
|
.box(-4, 4, 6, 8, 8, 8, stretch);
|
||||||
saddle.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
saddle.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
||||||
.box(-4.0F, 4.0F, -2.0F, 8, 8, 16, stretch);
|
.box(-4, 4, -2, 8, 8, 16, stretch);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initLegPositions(float yOffset, float stretch) {
|
|
||||||
super.initLegPositions(yOffset, stretch);
|
|
||||||
|
|
||||||
float rarmX = getLegRotationX();
|
|
||||||
|
|
||||||
float armX = THIRDP_ARM_CENTRE_X;
|
|
||||||
float armY = THIRDP_ARM_CENTRE_Y;
|
|
||||||
float armZ = THIRDP_ARM_CENTRE_Z;
|
|
||||||
|
|
||||||
leftLegging.offset(armX + 2, armY, armZ)
|
|
||||||
.around(rarmX, yOffset, 0)
|
|
||||||
.box(-2, -6, -2, 4, 12, 4, stretch);
|
|
||||||
rightLegging.offset(armX - 2, armY, armZ)
|
|
||||||
.around(-rarmX, yOffset, 0)
|
|
||||||
.flipX().box(-2, -6, -2, 4, 12, 4, stretch);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void syncLegs() {
|
|
||||||
rightLegging.rotateAt(bipedRightLeg).rotateTo(bipedRightLeg);
|
|
||||||
leftLegging.rotateAt(bipedLeftLeg).rotateTo(bipedLeftLeg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -200,8 +96,30 @@ public class ModelPonyArmor extends ModelMobPony {
|
||||||
super.setVisible(invisible);
|
super.setVisible(invisible);
|
||||||
flankGuard.showModel = invisible;
|
flankGuard.showModel = invisible;
|
||||||
saddle.showModel = invisible;
|
saddle.showModel = invisible;
|
||||||
helmet.showModel = invisible;
|
bipedHead.showModel = invisible;
|
||||||
leftLegging.showModel = invisible;
|
tail.isHidden = true;
|
||||||
rightLegging.showModel = invisible;
|
neck.isHidden = true;
|
||||||
|
upperTorso.isHidden = true;
|
||||||
|
snout.isHidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showFeet(boolean show) {
|
||||||
|
bipedRightArm.showModel = show;
|
||||||
|
bipedLeftArm.showModel = show;
|
||||||
|
bipedRightLeg.showModel = show;
|
||||||
|
bipedLeftLeg.showModel = show;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showLegs(boolean isPony) {
|
||||||
|
bipedBody.showModel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showSaddle(boolean isPony) {
|
||||||
|
flankGuard.showModel = !isPony;
|
||||||
|
saddle.showModel = isPony;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showHead(boolean show) {
|
||||||
|
bipedHead.showModel = show;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package com.minelittlepony.model.armour;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Armour for skeleton ponies.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ModelSkeletonPonyArmor extends ModelPonyArmor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fixSpecialRotationPoints(float move) {
|
|
||||||
if (rightArmPose != ArmPose.EMPTY && !canCast()) {
|
|
||||||
bipedRightArm.setRotationPoint(-1.5F, 9.5F, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package com.minelittlepony.model.armour;
|
|
||||||
|
|
||||||
import com.minelittlepony.render.AbstractPonyRenderer;
|
|
||||||
|
|
||||||
public class ModelZombiePonyArmor extends ModelPonyArmor {
|
|
||||||
// Copied from ModelZombiePony
|
|
||||||
@Override
|
|
||||||
protected void adjustLegs(float move, float swing, float ticks) {
|
|
||||||
super.adjustLegs(move, swing, ticks);
|
|
||||||
if (rightArmPose != ArmPose.EMPTY) return;
|
|
||||||
|
|
||||||
if (islookAngleRight(move)) {
|
|
||||||
rotateArmHolding(bipedRightArm, 1, swingProgress, ticks);
|
|
||||||
} else {
|
|
||||||
rotateArmHolding(bipedLeftArm, -1, swingProgress, ticks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void fixSpecialRotationPoints(float move) {
|
|
||||||
if (rightArmPose != ArmPose.EMPTY) return;
|
|
||||||
|
|
||||||
if (islookAngleRight(move)) {
|
|
||||||
AbstractPonyRenderer.shiftRotationPoint(bipedRightArm, 0.5F, 1.5F, 3);
|
|
||||||
} else {
|
|
||||||
AbstractPonyRenderer.shiftRotationPoint(bipedLeftArm, -0.5F, 1.5F, 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.minelittlepony.model.armour;
|
package com.minelittlepony.model.armour;
|
||||||
|
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
|
||||||
import com.minelittlepony.model.capabilities.IModelWrapper;
|
import com.minelittlepony.model.capabilities.IModelWrapper;
|
||||||
import com.minelittlepony.pony.data.IPonyData;
|
import com.minelittlepony.pony.data.IPonyData;
|
||||||
|
|
||||||
|
@ -8,10 +7,10 @@ import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
|
||||||
public class PonyArmor implements IModelWrapper {
|
public class PonyArmor implements IModelWrapper {
|
||||||
|
|
||||||
public final AbstractPonyModel chestplate;
|
public final ModelPonyArmor chestplate;
|
||||||
public final AbstractPonyModel leggings;
|
public final ModelPonyArmor leggings;
|
||||||
|
|
||||||
public PonyArmor(AbstractPonyModel chest, AbstractPonyModel body) {
|
public PonyArmor(ModelPonyArmor chest, ModelPonyArmor body) {
|
||||||
chestplate = chest;
|
chestplate = chest;
|
||||||
leggings = body;
|
leggings = body;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +25,7 @@ public class PonyArmor implements IModelWrapper {
|
||||||
leggings.init(0, 0.5f);
|
leggings.init(0, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractPonyModel getArmorForSlot(EntityEquipmentSlot slot) {
|
public ModelPonyArmor getArmorForSlot(EntityEquipmentSlot slot) {
|
||||||
if (slot == EntityEquipmentSlot.LEGS) {
|
if (slot == EntityEquipmentSlot.LEGS) {
|
||||||
return leggings;
|
return leggings;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import com.minelittlepony.model.AbstractPonyModel;
|
||||||
|
|
||||||
public class PonySnout {
|
public class PonySnout {
|
||||||
|
|
||||||
|
public boolean isHidden = false;
|
||||||
|
|
||||||
private PlaneRenderer mare;
|
private PlaneRenderer mare;
|
||||||
private PlaneRenderer stallion;
|
private PlaneRenderer stallion;
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ public class PonySnout {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGender(PonyGender gender) {
|
public void setGender(PonyGender gender) {
|
||||||
mare.isHidden = gender == PonyGender.STALLION;
|
mare.isHidden = !isHidden && gender == PonyGender.STALLION;
|
||||||
stallion.isHidden = !mare.isHidden;
|
stallion.isHidden = !isHidden && !mare.isHidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.minelittlepony.model.ponies;
|
package com.minelittlepony.model.ponies;
|
||||||
|
|
||||||
import com.minelittlepony.model.ModelMobPony;
|
import com.minelittlepony.model.ModelMobPony;
|
||||||
import com.minelittlepony.model.armour.ModelSkeletonPonyArmor;
|
|
||||||
import com.minelittlepony.model.armour.PonyArmor;
|
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.monster.AbstractSkeleton;
|
import net.minecraft.entity.monster.AbstractSkeleton;
|
||||||
|
@ -12,12 +10,6 @@ import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.EnumHandSide;
|
import net.minecraft.util.EnumHandSide;
|
||||||
|
|
||||||
public class ModelSkeletonPony extends ModelMobPony {
|
public class ModelSkeletonPony extends ModelMobPony {
|
||||||
|
|
||||||
@Override
|
|
||||||
public PonyArmor createArmour() {
|
|
||||||
return new PonyArmor(new ModelSkeletonPonyArmor(), new ModelSkeletonPonyArmor());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCasting() {
|
public boolean isCasting() {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
package com.minelittlepony.model.ponies;
|
package com.minelittlepony.model.ponies;
|
||||||
|
|
||||||
import com.minelittlepony.model.ModelMobPony;
|
import com.minelittlepony.model.ModelMobPony;
|
||||||
import com.minelittlepony.model.armour.ModelZombiePonyArmor;
|
|
||||||
import com.minelittlepony.model.armour.PonyArmor;
|
|
||||||
import com.minelittlepony.render.AbstractPonyRenderer;
|
import com.minelittlepony.render.AbstractPonyRenderer;
|
||||||
|
|
||||||
public class ModelZombiePony extends ModelMobPony {
|
public class ModelZombiePony extends ModelMobPony {
|
||||||
|
|
||||||
@Override
|
|
||||||
public PonyArmor createArmour() {
|
|
||||||
return new PonyArmor(new ModelZombiePonyArmor(), new ModelZombiePonyArmor());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void adjustLegs(float move, float swing, float ticks) {
|
protected void adjustLegs(float move, float swing, float ticks) {
|
||||||
super.adjustLegs(move, swing, ticks);
|
super.adjustLegs(move, swing, ticks);
|
||||||
|
|
|
@ -138,14 +138,22 @@ public abstract class AbstractPonyRenderer<T extends AbstractPonyRenderer<T>> ex
|
||||||
*/
|
*/
|
||||||
public T child(int index) {
|
public T child(int index) {
|
||||||
if (childModels == null || index >= childModels.size()) {
|
if (childModels == null || index >= childModels.size()) {
|
||||||
T copy = copySelf();
|
return child();
|
||||||
child(copy.offset(modelOffsetX, modelOffsetY, modelOffsetZ));
|
|
||||||
copy.textureHeight = textureHeight;
|
|
||||||
copy.textureWidth = textureWidth;
|
|
||||||
}
|
}
|
||||||
return (T)childModels.get(index);
|
return (T)childModels.get(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a brand new child under this renderer.
|
||||||
|
*/
|
||||||
|
public T child() {
|
||||||
|
T copy = copySelf();
|
||||||
|
child(copy.offset(modelOffsetX, modelOffsetY, modelOffsetZ));
|
||||||
|
copy.textureHeight = textureHeight;
|
||||||
|
copy.textureWidth = textureWidth;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a new child renderer and returns itself for chaining.
|
* Adds a new child renderer and returns itself for chaining.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.render.layer;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.minelittlepony.ForgeProxy;
|
import com.minelittlepony.ForgeProxy;
|
||||||
import com.minelittlepony.ducks.IRenderPony;
|
import com.minelittlepony.ducks.IRenderPony;
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
|
||||||
import com.minelittlepony.model.ModelWrapper;
|
import com.minelittlepony.model.ModelWrapper;
|
||||||
import com.minelittlepony.model.armour.ModelPonyArmor;
|
import com.minelittlepony.model.armour.ModelPonyArmor;
|
||||||
import com.minelittlepony.util.coordinates.Color;
|
import com.minelittlepony.util.coordinates.Color;
|
||||||
|
@ -12,6 +11,7 @@ import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.ModelBase;
|
import net.minecraft.client.model.ModelBase;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||||
|
import net.minecraft.client.renderer.entity.layers.LayerArmorBase;
|
||||||
import net.minecraft.client.resources.ResourcePackRepository;
|
import net.minecraft.client.resources.ResourcePackRepository;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
@ -24,17 +24,13 @@ import net.minecraft.util.Tuple;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLayer<T> {
|
public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLayer<T> {
|
||||||
|
|
||||||
private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png");
|
private static final Map<String, ResourceLocation> HUMAN_ARMOUR = Maps.newHashMap();
|
||||||
|
private static final Map<ResourceLocation, ResourceLocation> PONY_ARMOUR = Maps.newHashMap();
|
||||||
private static final Map<String, ResourceLocation> HUMAN_ARMORS = Maps.newHashMap();
|
|
||||||
private static final Map<ResourceLocation, ResourceLocation> PONY_ARMORS = Maps.newHashMap();
|
|
||||||
|
|
||||||
private ModelWrapper pony;
|
private ModelWrapper pony;
|
||||||
|
|
||||||
|
@ -60,26 +56,28 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
||||||
|
|
||||||
ItemArmor itemarmor = (ItemArmor) itemstack.getItem();
|
ItemArmor itemarmor = (ItemArmor) itemstack.getItem();
|
||||||
|
|
||||||
AbstractPonyModel modelbase = pony.getArmor().getArmorForSlot(armorSlot);
|
ModelPonyArmor armour = getArmorModel(entity, itemstack, armorSlot, pony.getArmor().getArmorForSlot(armorSlot));
|
||||||
modelbase = getArmorModel(entity, itemstack, armorSlot, modelbase);
|
armour.setModelAttributes(pony.getModel());
|
||||||
modelbase.setModelAttributes(pony.getModel());
|
armour.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
|
||||||
modelbase.setRotationAngles(move, swing, ticks, headYaw, headPitch, scale, entity);
|
armour.synchroniseLegs(pony.getModel());
|
||||||
|
|
||||||
Tuple<ResourceLocation, Boolean> armors = getArmorTexture(entity, itemstack, armorSlot, null);
|
Tuple<ResourceLocation, Boolean> armors = getArmorTexture(entity, itemstack, armorSlot, null);
|
||||||
prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond());
|
prepareToRender(armour, armorSlot, armors.getSecond());
|
||||||
|
|
||||||
getRenderer().bindTexture(armors.getFirst());
|
getRenderer().bindTexture(armors.getFirst());
|
||||||
|
|
||||||
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
|
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
|
||||||
Color.glColor(itemarmor.getColor(itemstack), 1);
|
Color.glColor(itemarmor.getColor(itemstack), 1);
|
||||||
modelbase.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
armour.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
||||||
armors = getArmorTexture(entity, itemstack, armorSlot, "overlay");
|
armors = getArmorTexture(entity, itemstack, armorSlot, "overlay");
|
||||||
getRenderer().bindTexture(armors.getFirst());
|
getRenderer().bindTexture(armors.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
GlStateManager.color(1, 1, 1, 1);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
modelbase.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
armour.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
||||||
|
|
||||||
if (itemstack.isItemEnchanted()) {
|
if (itemstack.isItemEnchanted()) {
|
||||||
renderEnchantment(entity, modelbase, move, swing, partialTicks, ticks, headYaw, headPitch, scale);
|
LayerArmorBase.renderEnchantedGlint(getRenderer(), entity, armour, move, swing, partialTicks, ticks, headYaw, headPitch, scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,16 +85,22 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
||||||
private Tuple<ResourceLocation, Boolean> getArmorTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, @Nullable String type) {
|
private Tuple<ResourceLocation, Boolean> getArmorTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, @Nullable String type) {
|
||||||
ItemArmor item = (ItemArmor) itemstack.getItem();
|
ItemArmor item = (ItemArmor) itemstack.getItem();
|
||||||
String texture = item.getArmorMaterial().getName();
|
String texture = item.getArmorMaterial().getName();
|
||||||
|
|
||||||
String domain = "minecraft";
|
String domain = "minecraft";
|
||||||
|
|
||||||
int idx = texture.indexOf(':');
|
int idx = texture.indexOf(':');
|
||||||
if (idx != -1) {
|
if (idx > -1) {
|
||||||
domain = texture.substring(0, idx);
|
domain = texture.substring(0, idx);
|
||||||
texture = texture.substring(idx + 1);
|
texture = texture.substring(idx + 1);
|
||||||
}
|
}
|
||||||
String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, slot == EntityEquipmentSlot.LEGS ? 2 : 1,
|
|
||||||
type == null ? "" : String.format("_%s", type));
|
type = type == null ? "" : String.format("_%s", type);
|
||||||
s1 = getArmorTexture(entity, itemstack, s1, slot, type);
|
|
||||||
ResourceLocation human = getHumanResource(s1);
|
String ponyRes = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, slot == EntityEquipmentSlot.LEGS ? 2 : 1, type);
|
||||||
|
|
||||||
|
ponyRes = getArmorTexture(entity, itemstack, ponyRes, slot, type);
|
||||||
|
|
||||||
|
ResourceLocation human = getHumanResource(ponyRes);
|
||||||
ResourceLocation pony = getPonyResource(human);
|
ResourceLocation pony = getPonyResource(human);
|
||||||
|
|
||||||
// check resource packs for either texture.
|
// check resource packs for either texture.
|
||||||
|
@ -118,113 +122,48 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
|
||||||
private void prepareToRender(ModelPonyArmor model, EntityEquipmentSlot slot, boolean isPony) {
|
private void prepareToRender(ModelPonyArmor model, EntityEquipmentSlot slot, boolean isPony) {
|
||||||
model.setVisible(false);
|
model.setVisible(false);
|
||||||
|
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
// feet
|
|
||||||
case FEET:
|
|
||||||
model.bipedRightArm.showModel = true;
|
|
||||||
model.bipedLeftArm.showModel = true;
|
|
||||||
model.bipedRightLeg.showModel = !isPony;
|
|
||||||
model.bipedLeftLeg.showModel = !isPony;
|
|
||||||
model.leftLegging.showModel = isPony;
|
|
||||||
model.rightLegging.showModel = isPony;
|
|
||||||
break;
|
|
||||||
// legs
|
|
||||||
case LEGS:
|
|
||||||
model.bipedRightLeg.showModel = !isPony;
|
|
||||||
model.bipedLeftLeg.showModel = !isPony;
|
|
||||||
model.bipedRightArm.showModel = true;
|
|
||||||
model.bipedLeftArm.showModel = true;
|
|
||||||
model.bipedBody.showModel = !isPony;
|
|
||||||
model.flankGuard.showModel = !isPony;
|
|
||||||
model.saddle.showModel = isPony;
|
|
||||||
model.leftLegging.showModel = isPony;
|
|
||||||
model.rightLegging.showModel = isPony;
|
|
||||||
break;
|
|
||||||
// chest
|
|
||||||
case CHEST:
|
|
||||||
model.saddle.showModel = isPony;
|
|
||||||
model.bipedBody.showModel = !isPony;
|
|
||||||
model.flankGuard.showModel = !isPony;
|
|
||||||
break;
|
|
||||||
// head
|
|
||||||
case HEAD:
|
case HEAD:
|
||||||
model.bipedHead.showModel = true;
|
model.showHead(isPony);
|
||||||
model.helmet.showModel = isPony;
|
break;
|
||||||
|
case FEET:
|
||||||
|
model.showFeet(true);
|
||||||
|
break;
|
||||||
|
case LEGS:
|
||||||
|
model.showFeet(true);
|
||||||
|
model.showLegs(isPony);
|
||||||
|
case CHEST:
|
||||||
|
model.showSaddle(isPony);
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderEnchantment(T entity, ModelBase model, float move, float swing, float partialTicks, float ticks, float headYaw, float headPitch, float scale) {
|
private static ResourceLocation getHumanResource(String resource) {
|
||||||
getRenderer().bindTexture(ENCHANTED_ITEM_GLINT_RES);
|
return HUMAN_ARMOUR.computeIfAbsent(resource, ResourceLocation::new);
|
||||||
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.depthFunc(GL11.GL_EQUAL);
|
|
||||||
GlStateManager.depthMask(false);
|
|
||||||
|
|
||||||
float brightness = 0.5F;
|
|
||||||
GlStateManager.color(brightness, brightness, brightness, 1);
|
|
||||||
|
|
||||||
float baseYOffset = entity.ticksExisted + partialTicks;
|
|
||||||
float glintBrightness = 0.76F;
|
|
||||||
float scaleFactor = 0.33333334F;
|
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
GlStateManager.disableLighting();
|
|
||||||
GlStateManager.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
|
|
||||||
|
|
||||||
GlStateManager.color(glintBrightness / 2, glintBrightness / 4, 0.8F * glintBrightness, 1);
|
|
||||||
|
|
||||||
GlStateManager.matrixMode(5890);
|
|
||||||
GlStateManager.loadIdentity();
|
|
||||||
|
|
||||||
|
|
||||||
GlStateManager.scale(scaleFactor, scaleFactor, scaleFactor);
|
|
||||||
GlStateManager.rotate(30 - i * 60, 0, 0, 1);
|
|
||||||
GlStateManager.translate(0, baseYOffset * (0.02F + i * 0.06F), 0);
|
|
||||||
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
|
|
||||||
|
|
||||||
model.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
GlStateManager.matrixMode(GL11.GL_TEXTURE);
|
|
||||||
GlStateManager.loadIdentity();
|
|
||||||
GlStateManager.matrixMode(GL11.GL_MODELVIEW);
|
|
||||||
GlStateManager.enableLighting();
|
|
||||||
GlStateManager.depthMask(true);
|
|
||||||
GlStateManager.depthFunc(GL11.GL_LEQUAL);
|
|
||||||
GlStateManager.disableBlend();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ResourceLocation getHumanResource(String s1) {
|
|
||||||
return HUMAN_ARMORS.computeIfAbsent(s1, ResourceLocation::new);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ResourceLocation getPonyResource(ResourceLocation human) {
|
private static ResourceLocation getPonyResource(ResourceLocation human) {
|
||||||
ResourceLocation pony = PONY_ARMORS.get(human);
|
return PONY_ARMOUR.computeIfAbsent(human, key -> {
|
||||||
if (pony == null) {
|
|
||||||
String domain = human.getResourceDomain();
|
String domain = human.getResourceDomain();
|
||||||
String path = human.getResourcePath();
|
if ("minecraft".equals(domain)) {
|
||||||
if (domain.equals("minecraft")) {
|
|
||||||
domain = "minelittlepony"; // it's a vanilla armor. I provide these.
|
domain = "minelittlepony"; // it's a vanilla armor. I provide these.
|
||||||
}
|
}
|
||||||
path = path.replace(".png", "_pony.png");
|
String path = human.getResourcePath().replace(".png", "_pony.png");
|
||||||
pony = new ResourceLocation(domain, path);
|
return new ResourceLocation(domain, path);
|
||||||
PONY_ARMORS.put(human, pony);
|
});
|
||||||
}
|
|
||||||
return pony;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) {
|
private static String getArmorTexture(EntityLivingBase entity, ItemStack item, String def, EntityEquipmentSlot slot, @Nullable String type) {
|
||||||
return ForgeProxy.getArmorTexture(entity, item, def, slot, type);
|
return ForgeProxy.getArmorTexture(entity, item, def, slot, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AbstractPonyModel getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, AbstractPonyModel def) {
|
private static ModelPonyArmor getArmorModel(EntityLivingBase entity, ItemStack itemstack, EntityEquipmentSlot slot, ModelPonyArmor def) {
|
||||||
ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def);
|
ModelBase model = ForgeProxy.getArmorModel(entity, itemstack, slot, def);
|
||||||
if (model instanceof ModelPonyArmor) {
|
if (model instanceof ModelPonyArmor) {
|
||||||
return (AbstractPonyModel) model;
|
return (ModelPonyArmor) model;
|
||||||
}
|
}
|
||||||
|
|
||||||
return def;
|
return def;
|
||||||
|
|
Loading…
Reference in a new issue