mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 06:24:43 +00:00
139 lines
7.0 KiB
Diff
139 lines
7.0 KiB
Diff
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderBiped.java
|
|
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderBiped.java
|
|
@@ -15,9 +15,15 @@
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemArmor;
|
|
import net.minecraft.item.ItemBlock;
|
|
+import net.minecraft.item.ItemBlock;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.util.ResourceLocation;
|
|
import org.lwjgl.opengl.GL11;
|
|
+import static net.minecraftforge.client.IItemRenderer.ItemRenderType.EQUIPPED;
|
|
+import static net.minecraftforge.client.IItemRenderer.ItemRendererHelper.BLOCK_3D;
|
|
+import net.minecraftforge.client.ForgeHooksClient;
|
|
+import net.minecraftforge.client.IItemRenderer;
|
|
+import net.minecraftforge.client.MinecraftForgeClient;
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
public class RenderBiped extends RenderLiving
|
|
@@ -49,11 +55,13 @@
|
|
this.field_82425_h = new ModelBiped(0.5F);
|
|
}
|
|
|
|
+ @Deprecated //Use the more sensitive version getArmorResource below
|
|
public static ResourceLocation func_110857_a(ItemArmor p_110857_0_, int p_110857_1_)
|
|
{
|
|
return func_110858_a(p_110857_0_, p_110857_1_, (String)null);
|
|
}
|
|
|
|
+ @Deprecated //Use the more sensitive version getArmorResource below
|
|
public static ResourceLocation func_110858_a(ItemArmor p_110858_0_, int p_110858_1_, String p_110858_2_)
|
|
{
|
|
String s1 = String.format("textures/models/armor/%s_layer_%d%s.png", new Object[] {field_82424_k[p_110858_0_.field_77880_c], Integer.valueOf(p_110858_1_ == 2 ? 2 : 1), p_110858_2_ == null ? "" : String.format("_%s", new Object[]{p_110858_2_})});
|
|
@@ -79,7 +87,7 @@
|
|
if (item instanceof ItemArmor)
|
|
{
|
|
ItemArmor itemarmor = (ItemArmor)item;
|
|
- this.func_110776_a(func_110857_a(itemarmor, p_130006_2_));
|
|
+ this.func_110776_a(getArmorResource(p_130006_1_, itemstack, p_130006_2_, null));
|
|
ModelBiped modelbiped = p_130006_2_ == 2 ? this.field_82425_h : this.field_82423_g;
|
|
modelbiped.field_78116_c.field_78806_j = p_130006_2_ == 0;
|
|
modelbiped.field_78114_d.field_78806_j = p_130006_2_ == 0;
|
|
@@ -88,14 +96,16 @@
|
|
modelbiped.field_78113_g.field_78806_j = p_130006_2_ == 1;
|
|
modelbiped.field_78123_h.field_78806_j = p_130006_2_ == 2 || p_130006_2_ == 3;
|
|
modelbiped.field_78124_i.field_78806_j = p_130006_2_ == 2 || p_130006_2_ == 3;
|
|
+ modelbiped = ForgeHooksClient.getArmorModel(p_130006_1_, itemstack, p_130006_2_, modelbiped);
|
|
this.func_77042_a(modelbiped);
|
|
modelbiped.field_78095_p = this.field_77045_g.field_78095_p;
|
|
modelbiped.field_78093_q = this.field_77045_g.field_78093_q;
|
|
modelbiped.field_78091_s = this.field_77045_g.field_78091_s;
|
|
|
|
- if (itemarmor.func_82812_d() == ItemArmor.ArmorMaterial.CLOTH)
|
|
+ //Move out of if to allow for more then just CLOTH to have color
|
|
+ int j = itemarmor.func_82814_b(itemstack);
|
|
+ if (j != -1)
|
|
{
|
|
- int j = itemarmor.func_82814_b(itemstack);
|
|
float f1 = (float)(j >> 16 & 255) / 255.0F;
|
|
float f2 = (float)(j >> 8 & 255) / 255.0F;
|
|
float f3 = (float)(j & 255) / 255.0F;
|
|
@@ -133,7 +143,7 @@
|
|
|
|
if (item instanceof ItemArmor)
|
|
{
|
|
- this.func_110776_a(func_110858_a((ItemArmor)item, p_82408_2_, "overlay"));
|
|
+ this.func_110776_a(getArmorResource(p_82408_1_, itemstack, p_82408_2_, "overlay"));
|
|
float f1 = 1.0F;
|
|
GL11.glColor3f(1.0F, 1.0F, 1.0F);
|
|
}
|
|
@@ -184,9 +194,12 @@
|
|
this.field_77071_a.field_78116_c.func_78794_c(0.0625F);
|
|
item = itemstack1.func_77973_b();
|
|
|
|
+ IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack1, EQUIPPED);
|
|
+ boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack1, BLOCK_3D));
|
|
+
|
|
if (item instanceof ItemBlock)
|
|
{
|
|
- if (RenderBlocks.func_147739_a(Block.func_149634_a(item).func_149645_b()))
|
|
+ if (is3D || RenderBlocks.func_147739_a(Block.func_149634_a(item).func_149645_b()))
|
|
{
|
|
f1 = 0.625F;
|
|
GL11.glTranslatef(0.0F, -0.25F, 0.0F);
|
|
@@ -229,7 +242,10 @@
|
|
this.field_77071_a.field_78112_f.func_78794_c(0.0625F);
|
|
GL11.glTranslatef(-0.0625F, 0.4375F, 0.0625F);
|
|
|
|
- if (item instanceof ItemBlock && RenderBlocks.func_147739_a(Block.func_149634_a(item).func_149645_b()))
|
|
+ IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemstack, EQUIPPED);
|
|
+ boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemstack, BLOCK_3D));
|
|
+
|
|
+ if (item instanceof ItemBlock && (is3D || RenderBlocks.func_147739_a(Block.func_149634_a(item).func_149645_b())))
|
|
{
|
|
f1 = 0.5F;
|
|
GL11.glTranslatef(0.0F, 0.1875F, -0.3125F);
|
|
@@ -278,7 +294,7 @@
|
|
|
|
if (itemstack.func_77973_b().func_77623_v())
|
|
{
|
|
- for (i = 0; i <= 1; ++i)
|
|
+ for (i = 0; i < itemstack.func_77973_b().getRenderPasses(itemstack.func_77960_j()); ++i)
|
|
{
|
|
int j = itemstack.func_77973_b().func_82790_a(itemstack, i);
|
|
f2 = (float)(j >> 16 & 255) / 255.0F;
|
|
@@ -336,4 +352,33 @@
|
|
{
|
|
this.func_76986_a((EntityLiving)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
|
}
|
|
+
|
|
+ /*=================================== FORGE START =========================================*/
|
|
+ /**
|
|
+ * 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 static ResourceLocation getArmorResource(Entity entity, ItemStack stack, int slot, String type)
|
|
+ {
|
|
+ ItemArmor item = (ItemArmor)stack.func_77973_b();
|
|
+ String s1 = String.format("textures/models/armor/%s_layer_%d%s.png",
|
|
+ field_82424_k[item.field_77880_c], (slot == 2 ? 2 : 1), type == null ? "" : String.format("_%s", type));
|
|
+
|
|
+ s1 = ForgeHooksClient.getArmorTexture(entity, stack, s1, slot, type);
|
|
+ ResourceLocation resourcelocation = (ResourceLocation)field_110859_k.get(s1);
|
|
+
|
|
+ if (resourcelocation == null)
|
|
+ {
|
|
+ resourcelocation = new ResourceLocation(s1);
|
|
+ field_110859_k.put(s1, resourcelocation);
|
|
+ }
|
|
+
|
|
+ return resourcelocation;
|
|
+ }
|
|
+ /*=================================== FORGE END ===========================================*/
|
|
}
|