mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 22:07:59 +01:00
Backport: Reimplement legacy armour texture support
This commit is contained in:
parent
8d4ace9535
commit
41f5bf2845
6 changed files with 94 additions and 3 deletions
|
@ -0,0 +1,6 @@
|
|||
package com.minelittlepony.model.armour;
|
||||
|
||||
public enum ArmourVariant {
|
||||
NORMAL,
|
||||
LEGACY
|
||||
}
|
|
@ -107,6 +107,14 @@ public class DefaultPonyArmorTextureResolver<T extends EntityLivingBase> impleme
|
|||
return modId;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArmourVariant getArmourVariant(ArmorLayer layer, ResourceLocation resolvedTexture) {
|
||||
if (resolvedTexture.getPath().endsWith("_pony.png")) {
|
||||
return ArmourVariant.NORMAL;
|
||||
}
|
||||
return ArmourVariant.LEGACY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,4 +15,12 @@ public interface IArmorTextureResolver<T extends EntityLivingBase> {
|
|||
* Gets the armour texture to be used for the given entity, armour piece, slot, and render layer.
|
||||
*/
|
||||
ResourceLocation getArmorTexture(T entity, ItemStack itemstack, EntityEquipmentSlot slot, ArmorLayer layer, @Nullable String type);
|
||||
|
||||
/**
|
||||
* Gets the armour variant for the identified texture.
|
||||
* Either normal for pony-style textures, or legacy for other textures.
|
||||
*/
|
||||
default ArmourVariant getArmourVariant(ArmorLayer layer, ResourceLocation resolvedTexture) {
|
||||
return ArmourVariant.NORMAL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,24 @@
|
|||
package com.minelittlepony.model.armour;
|
||||
|
||||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
import com.minelittlepony.model.AbstractPonyModel;
|
||||
import com.minelittlepony.model.capabilities.IModel;
|
||||
import com.minelittlepony.model.capabilities.IModelArmor;
|
||||
import com.minelittlepony.render.model.PlaneRenderer;
|
||||
import com.minelittlepony.render.model.PonyRenderer;
|
||||
|
||||
public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||
|
||||
public PonyRenderer chestPiece;
|
||||
|
||||
public ModelRenderer steveRightLeg;
|
||||
public ModelRenderer steveLeftLeg;
|
||||
|
||||
private ArmourVariant variant = ArmourVariant.NORMAL;
|
||||
|
||||
public ModelPonyArmor() {
|
||||
super(false);
|
||||
textureHeight = 32;
|
||||
|
@ -28,7 +35,17 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
|||
|
||||
@Override
|
||||
protected void renderBody(Entity entity, float move, float swing, float ticks, float headYaw, float headPitch, float scale) {
|
||||
chestPiece.render(scale);
|
||||
if (variant == ArmourVariant.LEGACY) {
|
||||
bipedBody.render(scale);
|
||||
upperTorso.render(scale);
|
||||
} else {
|
||||
chestPiece.render(scale);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariant(ArmourVariant variant) {
|
||||
this.variant = variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,6 +55,8 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
|||
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm);
|
||||
copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg);
|
||||
copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg);
|
||||
copyModelAngles(mainModel.bipedLeftLeg, steveLeftLeg);
|
||||
copyModelAngles(mainModel.bipedRightLeg, steveRightLeg);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,6 +73,16 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
|||
chestPiece = new PonyRenderer(this, 16, 8)
|
||||
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
||||
.box(-4, 4, -2, 8, 8, 16, stretch);
|
||||
|
||||
// fits the legacy player's torso to our pony bod.
|
||||
upperTorso = new PlaneRenderer(this, 24, 0);
|
||||
upperTorso.offset(BODY_CENTRE_X, BODY_CENTRE_Y, BODY_CENTRE_Z)
|
||||
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
||||
.tex(32, 23).east( 4, -4, -4, 8, 8, stretch)
|
||||
.west(-4, -4, -4, 8, 8, stretch)
|
||||
.tex(32, 23).south(-4, -4, 4, 8, 8, stretch)
|
||||
.tex(32, 23).top(-4, -4, -8, 8, 12, stretch);
|
||||
// it's a little short, so the butt tends to show. :/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -63,8 +92,33 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
|||
|
||||
bipedLeftLeg = new PonyRenderer(this, 48, 8).flip();
|
||||
bipedRightLeg = new PonyRenderer(this, 48, 8);
|
||||
|
||||
steveLeftLeg = new PonyRenderer(this, 0, 16).flip();
|
||||
steveRightLeg = new PonyRenderer(this, 0, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initLegs(float yOffset, float stretch) {
|
||||
super.initLegs(yOffset, stretch);
|
||||
|
||||
int armLength = getArmLength();
|
||||
int armWidth = getArmWidth();
|
||||
int armDepth = getArmDepth();
|
||||
|
||||
float rarmX = getLegRotationX();
|
||||
|
||||
float armX = THIRDP_ARM_CENTRE_X;
|
||||
float armY = THIRDP_ARM_CENTRE_Y;
|
||||
float armZ = BODY_CENTRE_Z / 2 - 1 - armDepth;
|
||||
|
||||
steveLeftLeg .setRotationPoint( rarmX, yOffset, 0);
|
||||
steveRightLeg.setRotationPoint(-rarmX, yOffset, 0);
|
||||
|
||||
steveLeftLeg .addBox(armX, armY, armZ, armWidth, armLength, armDepth, stretch);
|
||||
steveRightLeg.addBox(armX - armWidth, armY, armZ, armWidth, armLength, armDepth, stretch);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setInVisible() {
|
||||
setVisible(false);
|
||||
|
@ -75,14 +129,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
|||
tail.setVisible(false);
|
||||
upperTorso.isHidden = true;
|
||||
snout.isHidden = true;
|
||||
steveLeftLeg.showModel = false;
|
||||
steveRightLeg.showModel = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBoots() {
|
||||
bipedRightArm.showModel = true;
|
||||
bipedLeftArm.showModel = true;
|
||||
bipedRightLeg.showModel = true;
|
||||
bipedLeftLeg.showModel = true;
|
||||
bipedRightLeg.showModel = variant == ArmourVariant.NORMAL;
|
||||
bipedLeftLeg.showModel = variant == ArmourVariant.NORMAL;
|
||||
steveLeftLeg.showModel = variant == ArmourVariant.LEGACY;
|
||||
steveRightLeg.showModel = variant == ArmourVariant.LEGACY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,6 +158,11 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
|||
public void showSaddle() {
|
||||
chestPiece.showModel = true;
|
||||
neck.showModel = true;
|
||||
|
||||
if (variant == ArmourVariant.LEGACY) {
|
||||
upperTorso.isHidden = false;
|
||||
upperTorso.showModel = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.model.capabilities;
|
|||
import net.minecraft.client.model.ModelBiped;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
|
||||
import com.minelittlepony.model.armour.ArmourVariant;
|
||||
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
||||
|
||||
public interface IModelArmor {
|
||||
|
@ -18,6 +19,8 @@ public interface IModelArmor {
|
|||
*/
|
||||
void setInVisible();
|
||||
|
||||
void setVariant(ArmourVariant variant);
|
||||
|
||||
/**
|
||||
* Prepares an armour model for rendering, first hiding all the pieces and then incrementally showing them as appropriate.
|
||||
*
|
||||
|
|
|
@ -62,6 +62,7 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
|||
IArmorTextureResolver<T> resolver = armour instanceof IArmorTextureResolver ? (IArmorTextureResolver<T>)armour : (IArmorTextureResolver<T>)textures;
|
||||
|
||||
ResourceLocation armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, null);
|
||||
armour.setVariant(resolver.getArmourVariant(layer, armourTexture));
|
||||
|
||||
getRenderer().bindTexture(armourTexture);
|
||||
|
||||
|
@ -71,6 +72,8 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
|||
Color.glColor(itemarmor.getColor(itemstack), 1);
|
||||
armour.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
||||
armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, "overlay");
|
||||
armour.setVariant(resolver.getArmourVariant(layer, armourTexture));
|
||||
|
||||
getRenderer().bindTexture(armourTexture);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue