ForgePatch/patches/minecraft/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java.patch

89 lines
4.6 KiB
Diff

--- a/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java
+++ b/net/minecraft/client/renderer/entity/layers/LayerArmorBase.java
@@ -51,12 +51,13 @@
ItemArmor itemarmor = (ItemArmor)itemstack.func_77973_b();
if (itemarmor.func_185083_B_() == p_188361_9_) {
T t = this.func_188360_a(p_188361_9_);
+ t = getArmorModelHook(p_188361_1_, itemstack, p_188361_9_, t);
t.func_178686_a(this.field_177190_a.func_177087_b());
t.func_78086_a(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_4_);
this.func_188359_a(t, p_188361_9_);
boolean flag = this.func_188363_b(p_188361_9_);
- this.field_177190_a.func_110776_a(this.func_177181_a(itemarmor, flag));
- if (itemarmor instanceof ItemArmorDyeable) {
+ this.field_177190_a.func_110776_a(this.getArmorResource(p_188361_1_, itemstack, p_188361_9_, null));
+ if (itemarmor instanceof ItemArmorDyeable) { // Allow this for anything, not only cloth
int i = ((ItemArmorDyeable)itemarmor).func_200886_f(itemstack);
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
@@ -68,7 +69,7 @@
GlStateManager.func_179131_c(this.field_177184_f, this.field_177185_g, this.field_177192_h, this.field_177187_e);
t.func_78088_a(p_188361_1_, p_188361_2_, p_188361_3_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_);
- if (!this.field_177193_i && itemstack.func_77948_v()) {
+ if (!this.field_177193_i && itemstack.func_77962_s()) {
func_188364_a(this.field_177190_a, p_188361_1_, t, p_188361_2_, p_188361_3_, p_188361_4_, p_188361_5_, p_188361_6_, p_188361_7_, p_188361_8_);
}
@@ -120,10 +121,12 @@
Minecraft.func_71410_x().field_71460_t.func_191514_d(false);
}
+ @Deprecated //Use the more sensitive version getArmorResource below
private ResourceLocation func_177181_a(ItemArmor p_177181_1_, boolean p_177181_2_) {
return this.func_177178_a(p_177181_1_, p_177181_2_, (String)null);
}
+ @Deprecated //Use the more sensitive version getArmorResource below
private ResourceLocation func_177178_a(ItemArmor p_177178_1_, boolean p_177178_2_, @Nullable String p_177178_3_) {
String s = "textures/models/armor/" + p_177178_1_.func_200880_d().func_200897_d() + "_layer_" + (p_177178_2_ ? 2 : 1) + (p_177178_3_ == null ? "" : "_" + p_177178_3_) + ".png";
return field_177191_j.computeIfAbsent(s, ResourceLocation::new);
@@ -132,4 +135,47 @@
protected abstract void func_177177_a();
protected abstract void func_188359_a(T p_188359_1_, EntityEquipmentSlot p_188359_2_);
+
+ /*=================================== FORGE START =========================================*/
+
+ /**
+ * Hook to allow item-sensitive armor model. for LayerBipedArmor.
+ */
+ protected T getArmorModelHook(EntityLivingBase entity, ItemStack itemStack, EntityEquipmentSlot slot, T model) {
+ return model;
+ }
+
+ /**
+ * More generic ForgeHook version of the above function, it allows for Items to have more control over what texture they provide.
+ *
+ * @param entity Entity wearing the armor
+ * @param stack ItemStack for the armor
+ * @param slot Slot ID that the item is in
+ * @param type Subtype, can be null or "overlay"
+ * @return ResourceLocation pointing at the armor's texture
+ */
+ public ResourceLocation getArmorResource(net.minecraft.entity.Entity entity, ItemStack stack, EntityEquipmentSlot slot, @javax.annotation.Nullable String type) {
+ ItemArmor item = (ItemArmor)stack.func_77973_b();
+ String texture = item.func_200880_d().func_200897_d();
+ String domain = "minecraft";
+ int idx = texture.indexOf(':');
+ if (idx != -1)
+ {
+ domain = texture.substring(0, idx);
+ texture = texture.substring(idx + 1);
+ }
+ String s1 = String.format("%s:textures/models/armor/%s_layer_%d%s.png", domain, texture, (func_188363_b(slot) ? 2 : 1), type == null ? "" : String.format("_%s", type));
+
+ s1 = net.minecraftforge.client.ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
+ ResourceLocation resourcelocation = (ResourceLocation)field_177191_j.get(s1);
+
+ if (resourcelocation == null)
+ {
+ resourcelocation = new ResourceLocation(s1);
+ field_177191_j.put(s1, resourcelocation);
+ }
+
+ return resourcelocation;
+ }
+ /*=================================== FORGE END ===========================================*/
}