RenderItem can now use baked quad color

This commit is contained in:
RainWarrior 2015-02-17 04:56:32 +03:00
parent 93cd9722b0
commit b14cfa45e5
5 changed files with 57 additions and 7 deletions

View file

@ -9,7 +9,17 @@
this.func_175041_b(); this.func_175041_b();
} }
@@ -302,6 +302,10 @@ @@ -212,6 +212,9 @@
private void func_175033_a(WorldRenderer p_175033_1_, BakedQuad p_175033_2_, int p_175033_3_)
{
p_175033_1_.func_178981_a(p_175033_2_.func_178209_a());
+ if(p_175033_2_ instanceof net.minecraftforge.client.model.IColoredBakedQuad)
+ net.minecraftforge.client.ForgeHooksClient.putQuadColor(p_175033_1_, p_175033_2_, p_175033_3_);
+ else
p_175033_1_.func_178968_d(p_175033_3_);
this.func_175038_a(p_175033_1_, p_175033_2_);
}
@@ -302,6 +305,10 @@
modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory"); modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory");
} }
} }
@ -20,7 +30,7 @@
if (modelresourcelocation != null) if (modelresourcelocation != null)
{ {
@@ -314,6 +318,11 @@ @@ -314,6 +321,11 @@
protected void func_175034_a(ItemTransformVec3f p_175034_1_) protected void func_175034_a(ItemTransformVec3f p_175034_1_)
{ {
@ -32,7 +42,7 @@
if (p_175034_1_ != ItemTransformVec3f.field_178366_a) if (p_175034_1_ != ItemTransformVec3f.field_178366_a)
{ {
GlStateManager.func_179109_b(p_175034_1_.field_178365_c.x + field_175055_b, p_175034_1_.field_178365_c.y + field_175056_c, p_175034_1_.field_178365_c.z + field_175053_d); GlStateManager.func_179109_b(p_175034_1_.field_178365_c.x + field_175055_b, p_175034_1_.field_178365_c.y + field_175056_c, p_175034_1_.field_178365_c.z + field_175053_d);
@@ -335,23 +344,7 @@ @@ -335,23 +347,7 @@
GlStateManager.func_179120_a(770, 771, 1, 0); GlStateManager.func_179120_a(770, 771, 1, 0);
GlStateManager.func_179094_E(); GlStateManager.func_179094_E();
@ -57,7 +67,7 @@
this.func_180454_a(p_175040_1_, p_175040_2_); this.func_180454_a(p_175040_1_, p_175040_2_);
GlStateManager.func_179121_F(); GlStateManager.func_179121_F();
@@ -485,10 +478,11 @@ @@ -485,10 +481,11 @@
GlStateManager.func_179126_j(); GlStateManager.func_179126_j();
} }
@ -72,7 +82,7 @@
GlStateManager.func_179140_f(); GlStateManager.func_179140_f();
GlStateManager.func_179097_i(); GlStateManager.func_179097_i();
GlStateManager.func_179090_x(); GlStateManager.func_179090_x();
@@ -501,7 +495,7 @@ @@ -501,7 +498,7 @@
this.func_175044_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, 13, 2, 0); this.func_175044_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, 13, 2, 0);
this.func_175044_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, 12, 1, i1); this.func_175044_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, 12, 1, i1);
this.func_175044_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, j1, 1, l); this.func_175044_a(worldrenderer, p_180453_3_ + 2, p_180453_4_ + 13, j1, 1, l);
@ -81,7 +91,7 @@
GlStateManager.func_179141_d(); GlStateManager.func_179141_d();
GlStateManager.func_179098_w(); GlStateManager.func_179098_w();
GlStateManager.func_179145_e(); GlStateManager.func_179145_e();
@@ -1072,12 +1066,26 @@ @@ -1072,12 +1069,26 @@
this.func_175029_a(Blocks.field_150420_aW, BlockHugeMushroom.EnumType.ALL_INSIDE.func_176896_a(), "brown_mushroom_block"); this.func_175029_a(Blocks.field_150420_aW, BlockHugeMushroom.EnumType.ALL_INSIDE.func_176896_a(), "brown_mushroom_block");
this.func_175029_a(Blocks.field_150419_aX, BlockHugeMushroom.EnumType.ALL_INSIDE.func_176896_a(), "red_mushroom_block"); this.func_175029_a(Blocks.field_150419_aX, BlockHugeMushroom.EnumType.ALL_INSIDE.func_176896_a(), "red_mushroom_block");
this.func_175031_a(Blocks.field_150380_bt, "dragon_egg"); this.func_175031_a(Blocks.field_150380_bt, "dragon_egg");

View file

@ -26,6 +26,8 @@ import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderGlobal; import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemTransformVec3f; import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.renderer.entity.RenderItem;
@ -656,4 +658,25 @@ public class ForgeHooksClient
ret.mul(tmp); ret.mul(tmp);
return ret; return ret;
} }
public static void putQuadColor(WorldRenderer renderer, BakedQuad quad, int color)
{
float cr = color & 0xFF;
float cg = (color >>> 8) & 0xFF;
float cb = (color >>> 16) & 0xFF;
float ca = (color >>> 24) & 0xFF;
for(int i = 0; i < 4; i++)
{
int vc = quad.getVertexData()[3 + 7 * i];
float vcr = vc & 0xFF;
float vcg = (vc >>> 8) & 0xFF;
float vcb = (vc >>> 16) & 0xFF;
float vca = (vc >>> 24) & 0xFF;
int ncr = Math.min(0xFF, (int)(cr * vcr / 0xFF));
int ncg = Math.min(0xFF, (int)(cg * vcg / 0xFF));
int ncb = Math.min(0xFF, (int)(cb * vcb / 0xFF));
int nca = Math.min(0xFF, (int)(ca * vca / 0xFF));
renderer.putColorRGBA(renderer.getColorIndex(i + 1), ncr, ncg, ncb, nca);
}
}
} }

View file

@ -0,0 +1,14 @@
package net.minecraftforge.client.model;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.util.EnumFacing;
public interface IColoredBakedQuad {
public static class ColoredBakedQuad extends BakedQuad implements IColoredBakedQuad
{
public ColoredBakedQuad(int[] data, int tintIndex, EnumFacing side)
{
super(data, tintIndex, side);
}
}
}

View file

@ -26,6 +26,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.Attributes; import net.minecraftforge.client.model.Attributes;
import net.minecraftforge.client.model.IColoredBakedQuad.ColoredBakedQuad;
import net.minecraftforge.client.model.ICustomModelLoader; import net.minecraftforge.client.model.ICustomModelLoader;
import net.minecraftforge.client.model.IFlexibleBakedModel; import net.minecraftforge.client.model.IFlexibleBakedModel;
import net.minecraftforge.client.model.IModel; import net.minecraftforge.client.model.IModel;
@ -465,7 +466,7 @@ public class B3DLoader implements ICustomModelLoader
buf.flip(); buf.flip();
int[] data = new int[VERTICES_IN_QUAD * format.getNextOffset() / BYTES_IN_INT]; int[] data = new int[VERTICES_IN_QUAD * format.getNextOffset() / BYTES_IN_INT];
buf.asIntBuffer().get(data); buf.asIntBuffer().get(data);
builder.add(new BakedQuad(data, -1, EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z))); builder.add(new ColoredBakedQuad(data, -1, EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z)));
} }
quads = builder.build(); quads = builder.build();
} }

View file

@ -152,3 +152,5 @@ public net.minecraft.client.resources.model.WeightedBakedModel field_177565_b #
# EnumFacing # EnumFacing
public net.minecraft.util.EnumFacing field_82609_l # VALUES public net.minecraft.util.EnumFacing field_82609_l # VALUES
public net.minecraft.util.EnumFacing field_176754_o # HORIZONTALS public net.minecraft.util.EnumFacing field_176754_o # HORIZONTALS
public net.minecraft.client.renderer.WorldRenderer func_78909_a(I)I # getColorIndex
public net.minecraft.client.renderer.WorldRenderer func_178972_a(IIIII)V # putColorRGBA