mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-25 13:57:59 +01:00
Fix armors for non-pony textures.
This commit is contained in:
parent
d73f82173a
commit
886b12f157
1 changed files with 32 additions and 16 deletions
|
@ -21,6 +21,7 @@ import net.minecraft.item.ItemArmor;
|
||||||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.Tuple;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -62,15 +63,17 @@ public class LayerPonyArmor implements LayerRenderer<EntityLivingBase> {
|
||||||
if (itemstack != null && itemstack.getItem() instanceof ItemArmor) {
|
if (itemstack != null && itemstack.getItem() instanceof ItemArmor) {
|
||||||
|
|
||||||
ItemArmor itemarmor = (ItemArmor) itemstack.getItem();
|
ItemArmor itemarmor = (ItemArmor) itemstack.getItem();
|
||||||
boolean isLegs = armorSlot == EntityEquipmentSlot.CHEST;
|
boolean isLegs = armorSlot == EntityEquipmentSlot.LEGS;
|
||||||
|
|
||||||
AbstractPonyModel modelbase = isLegs ? pony.getArmor().modelArmor : pony.getArmor().modelArmorChestplate;
|
AbstractPonyModel modelbase = isLegs ? pony.getArmor().modelArmor : pony.getArmor().modelArmorChestplate;
|
||||||
modelbase = getArmorModel(entity, itemstack, isLegs ? 2 : 1, modelbase);
|
modelbase = getArmorModel(entity, itemstack, isLegs ? 2 : 1, modelbase);
|
||||||
modelbase.setModelAttributes(this.pony.getModel());
|
modelbase.setModelAttributes(this.pony.getModel());
|
||||||
modelbase.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
|
modelbase.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entity);
|
||||||
prepareToRender((ModelPonyArmor) modelbase, armorSlot);
|
|
||||||
|
|
||||||
this.renderer.bindTexture(getArmorTexture(entity, itemstack, isLegs ? 2 : 1, null));
|
Tuple<ResourceLocation, Boolean> armors = getArmorTexture(entity, itemstack, isLegs ? 2 : 1, null);
|
||||||
|
prepareToRender((ModelPonyArmor) modelbase, armorSlot, armors.getSecond());
|
||||||
|
|
||||||
|
this.renderer.bindTexture(armors.getFirst());
|
||||||
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
|
if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) {
|
||||||
int j = itemarmor.getColor(itemstack);
|
int j = itemarmor.getColor(itemstack);
|
||||||
float f7 = (j >> 16 & 255) / 255.0F;
|
float f7 = (j >> 16 & 255) / 255.0F;
|
||||||
|
@ -78,7 +81,8 @@ public class LayerPonyArmor implements LayerRenderer<EntityLivingBase> {
|
||||||
float f9 = (j & 255) / 255.0F;
|
float f9 = (j & 255) / 255.0F;
|
||||||
GlStateManager.color(f7, f8, f9, 1);
|
GlStateManager.color(f7, f8, f9, 1);
|
||||||
modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||||
this.renderer.bindTexture(getArmorTexture(entity, itemstack, isLegs ? 2 : 1, "overlay"));
|
armors = getArmorTexture(entity, itemstack, isLegs ? 2 : 1, "overlay");
|
||||||
|
this.renderer.bindTexture(armors.getFirst());
|
||||||
}
|
}
|
||||||
GlStateManager.color(1, 1, 1, 1);
|
GlStateManager.color(1, 1, 1, 1);
|
||||||
modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
|
||||||
|
@ -89,7 +93,7 @@ public class LayerPonyArmor implements LayerRenderer<EntityLivingBase> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResourceLocation getArmorTexture(EntityLivingBase entity, ItemStack itemstack, int slot, String type) {
|
private Tuple<ResourceLocation, Boolean> getArmorTexture(EntityLivingBase entity, ItemStack itemstack, int slot, 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";
|
||||||
|
@ -104,16 +108,17 @@ public class LayerPonyArmor implements LayerRenderer<EntityLivingBase> {
|
||||||
ResourceLocation human = getHumanResource(s1);
|
ResourceLocation human = getHumanResource(s1);
|
||||||
ResourceLocation pony = getPonyResource(human);
|
ResourceLocation pony = getPonyResource(human);
|
||||||
|
|
||||||
|
// TODO handle resource packs better
|
||||||
try {
|
try {
|
||||||
Minecraft.getMinecraft().getResourceManager().getResource(pony);
|
Minecraft.getMinecraft().getResourceManager().getResource(pony);
|
||||||
return pony;
|
return new Tuple<>(pony, true);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return human;
|
return new Tuple<>(human, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("incomplete-switch")
|
@SuppressWarnings("incomplete-switch")
|
||||||
private void prepareToRender(ModelPonyArmor model, EntityEquipmentSlot slot) {
|
private void prepareToRender(ModelPonyArmor model, EntityEquipmentSlot slot, boolean isPony) {
|
||||||
model.setInvisible(false);
|
model.setInvisible(false);
|
||||||
|
|
||||||
switch (slot) {
|
switch (slot) {
|
||||||
|
@ -121,26 +126,36 @@ public class LayerPonyArmor implements LayerRenderer<EntityLivingBase> {
|
||||||
case FEET:
|
case FEET:
|
||||||
model.bipedRightArm.showModel = true;
|
model.bipedRightArm.showModel = true;
|
||||||
model.bipedLeftArm.showModel = true;
|
model.bipedLeftArm.showModel = true;
|
||||||
model.bipedRightLeg.showModel = true;
|
model.bipedRightLeg.showModel = !isPony;
|
||||||
model.bipedLeftLeg.showModel = true;
|
model.bipedLeftLeg.showModel = !isPony;
|
||||||
|
for (ModelRenderer extLeg : model.extLegs) {
|
||||||
|
extLeg.showModel = isPony;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// legs
|
// legs
|
||||||
case LEGS:
|
case LEGS:
|
||||||
model.bipedRightLeg.showModel = true;
|
model.bipedRightLeg.showModel = !isPony;
|
||||||
model.bipedLeftLeg.showModel = true;
|
model.bipedLeftLeg.showModel = !isPony;
|
||||||
model.bipedRightArm.showModel = true;
|
model.bipedRightArm.showModel = true;
|
||||||
model.bipedLeftArm.showModel = true;
|
model.bipedLeftArm.showModel = true;
|
||||||
model.extBody.showModel = true;
|
model.bipedBody.showModel = !isPony;
|
||||||
|
model.Bodypiece.showModel = !isPony;
|
||||||
|
model.extBody.showModel = isPony;
|
||||||
|
for (ModelRenderer extLeg : model.extLegs) {
|
||||||
|
extLeg.showModel = isPony;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
// chest
|
// chest
|
||||||
case CHEST:
|
case CHEST:
|
||||||
model.extBody.showModel = true;
|
model.extBody.showModel = isPony;
|
||||||
|
model.bipedBody.showModel = !isPony;
|
||||||
|
model.Bodypiece.showModel = !isPony;
|
||||||
break;
|
break;
|
||||||
// head
|
// head
|
||||||
case HEAD:
|
case HEAD:
|
||||||
model.bipedHead.showModel = true;
|
model.bipedHead.showModel = true;
|
||||||
for (ModelRenderer m : model.extHead) {
|
for (ModelRenderer head : model.extHead) {
|
||||||
m.showModel = true;
|
head.showModel = isPony;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,4 +237,5 @@ public class LayerPonyArmor implements LayerRenderer<EntityLivingBase> {
|
||||||
}
|
}
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue