mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-12-01 16:27: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;
|
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.
|
* 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);
|
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;
|
package com.minelittlepony.model.armour;
|
||||||
|
|
||||||
import net.minecraft.client.model.ModelBiped;
|
import net.minecraft.client.model.ModelBiped;
|
||||||
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
|
||||||
import com.minelittlepony.model.AbstractPonyModel;
|
import com.minelittlepony.model.AbstractPonyModel;
|
||||||
import com.minelittlepony.model.capabilities.IModel;
|
import com.minelittlepony.model.capabilities.IModel;
|
||||||
import com.minelittlepony.model.capabilities.IModelArmor;
|
import com.minelittlepony.model.capabilities.IModelArmor;
|
||||||
|
import com.minelittlepony.render.model.PlaneRenderer;
|
||||||
import com.minelittlepony.render.model.PonyRenderer;
|
import com.minelittlepony.render.model.PonyRenderer;
|
||||||
|
|
||||||
public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
|
|
||||||
public PonyRenderer chestPiece;
|
public PonyRenderer chestPiece;
|
||||||
|
|
||||||
|
public ModelRenderer steveRightLeg;
|
||||||
|
public ModelRenderer steveLeftLeg;
|
||||||
|
|
||||||
|
private ArmourVariant variant = ArmourVariant.NORMAL;
|
||||||
|
|
||||||
public ModelPonyArmor() {
|
public ModelPonyArmor() {
|
||||||
super(false);
|
super(false);
|
||||||
textureHeight = 32;
|
textureHeight = 32;
|
||||||
|
@ -28,8 +35,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
|
|
||||||
@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) {
|
||||||
|
if (variant == ArmourVariant.LEGACY) {
|
||||||
|
bipedBody.render(scale);
|
||||||
|
upperTorso.render(scale);
|
||||||
|
} else {
|
||||||
chestPiece.render(scale);
|
chestPiece.render(scale);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVariant(ArmourVariant variant) {
|
||||||
|
this.variant = variant;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends ModelBiped & IModel> void synchroniseLegs(T mainModel) {
|
public <T extends ModelBiped & IModel> void synchroniseLegs(T mainModel) {
|
||||||
|
@ -38,6 +55,8 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm);
|
copyModelAngles(mainModel.bipedLeftArm, bipedLeftArm);
|
||||||
copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg);
|
copyModelAngles(mainModel.bipedRightLeg, bipedRightLeg);
|
||||||
copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg);
|
copyModelAngles(mainModel.bipedLeftLeg, bipedLeftLeg);
|
||||||
|
copyModelAngles(mainModel.bipedLeftLeg, steveLeftLeg);
|
||||||
|
copyModelAngles(mainModel.bipedRightLeg, steveRightLeg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,6 +73,16 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
chestPiece = new PonyRenderer(this, 16, 8)
|
chestPiece = new PonyRenderer(this, 16, 8)
|
||||||
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
.around(HEAD_RP_X, HEAD_RP_Y + yOffset, HEAD_RP_Z)
|
||||||
.box(-4, 4, -2, 8, 8, 16, stretch);
|
.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
|
@Override
|
||||||
|
@ -63,8 +92,33 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
|
|
||||||
bipedLeftLeg = new PonyRenderer(this, 48, 8).flip();
|
bipedLeftLeg = new PonyRenderer(this, 48, 8).flip();
|
||||||
bipedRightLeg = new PonyRenderer(this, 48, 8);
|
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
|
@Override
|
||||||
public void setInVisible() {
|
public void setInVisible() {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
|
@ -75,14 +129,18 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
tail.setVisible(false);
|
tail.setVisible(false);
|
||||||
upperTorso.isHidden = true;
|
upperTorso.isHidden = true;
|
||||||
snout.isHidden = true;
|
snout.isHidden = true;
|
||||||
|
steveLeftLeg.showModel = false;
|
||||||
|
steveRightLeg.showModel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showBoots() {
|
public void showBoots() {
|
||||||
bipedRightArm.showModel = true;
|
bipedRightArm.showModel = true;
|
||||||
bipedLeftArm.showModel = true;
|
bipedLeftArm.showModel = true;
|
||||||
bipedRightLeg.showModel = true;
|
bipedRightLeg.showModel = variant == ArmourVariant.NORMAL;
|
||||||
bipedLeftLeg.showModel = true;
|
bipedLeftLeg.showModel = variant == ArmourVariant.NORMAL;
|
||||||
|
steveLeftLeg.showModel = variant == ArmourVariant.LEGACY;
|
||||||
|
steveRightLeg.showModel = variant == ArmourVariant.LEGACY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,6 +158,11 @@ public class ModelPonyArmor extends AbstractPonyModel implements IModelArmor {
|
||||||
public void showSaddle() {
|
public void showSaddle() {
|
||||||
chestPiece.showModel = true;
|
chestPiece.showModel = true;
|
||||||
neck.showModel = true;
|
neck.showModel = true;
|
||||||
|
|
||||||
|
if (variant == ArmourVariant.LEGACY) {
|
||||||
|
upperTorso.isHidden = false;
|
||||||
|
upperTorso.showModel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.model.capabilities;
|
||||||
import net.minecraft.client.model.ModelBiped;
|
import net.minecraft.client.model.ModelBiped;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
|
||||||
|
import com.minelittlepony.model.armour.ArmourVariant;
|
||||||
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
import com.minelittlepony.model.armour.IEquestrianArmor.ArmorLayer;
|
||||||
|
|
||||||
public interface IModelArmor {
|
public interface IModelArmor {
|
||||||
|
@ -18,6 +19,8 @@ public interface IModelArmor {
|
||||||
*/
|
*/
|
||||||
void setInVisible();
|
void setInVisible();
|
||||||
|
|
||||||
|
void setVariant(ArmourVariant variant);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares an armour model for rendering, first hiding all the pieces and then incrementally showing them as appropriate.
|
* 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;
|
IArmorTextureResolver<T> resolver = armour instanceof IArmorTextureResolver ? (IArmorTextureResolver<T>)armour : (IArmorTextureResolver<T>)textures;
|
||||||
|
|
||||||
ResourceLocation armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, null);
|
ResourceLocation armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, null);
|
||||||
|
armour.setVariant(resolver.getArmourVariant(layer, armourTexture));
|
||||||
|
|
||||||
getRenderer().bindTexture(armourTexture);
|
getRenderer().bindTexture(armourTexture);
|
||||||
|
|
||||||
|
@ -71,6 +72,8 @@ public class LayerPonyArmor<T extends EntityLivingBase> extends AbstractPonyLaye
|
||||||
Color.glColor(itemarmor.getColor(itemstack), 1);
|
Color.glColor(itemarmor.getColor(itemstack), 1);
|
||||||
armour.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
armour.render(entity, move, swing, ticks, headYaw, headPitch, scale);
|
||||||
armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, "overlay");
|
armourTexture = resolver.getArmorTexture(entity, itemstack, armorSlot, layer, "overlay");
|
||||||
|
armour.setVariant(resolver.getArmourVariant(layer, armourTexture));
|
||||||
|
|
||||||
getRenderer().bindTexture(armourTexture);
|
getRenderer().bindTexture(armourTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue