Skip to content

Commit

Permalink
Fix colors
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Sep 26, 2014
1 parent 66c0b46 commit 1f0b88b
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/main/java/tconstruct/client/ToolCoreRenderer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tconstruct.client;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.texture.TextureUtil;
Expand Down Expand Up @@ -147,43 +148,39 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)
GL11.glPushMatrix();

// color
int color = item.getItem().getColorFromItemStack(item, 0);
float a = (float)(color >> 24 & 0xff) / 255F;
float r = (float)(color >> 16 & 0xff) / 255F;
float g = (float)(color >> 8 & 0xff) / 255F;
float b = (float)(color & 0xff) / 255F;
// no invisible
if(a < 0.01f)
a = 1.0f;
GL11.glColor4f(r, g, b, a);
int[] color = new int[iconParts];
for(int i = 0; i < iconParts; i++)
color[i] = item.getItem().getColorFromItemStack(item, i);


GL11.glEnable(GL12.GL_RESCALE_NORMAL);

if (type == ItemRenderType.INVENTORY)
{

TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
texturemanager.getResourceLocation(item.getItemSpriteNumber());
TextureUtil.func_152777_a(false, false, 1.0F);

GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);
GL11.glDisable(GL11.GL_BLEND);

tess.startDrawingQuads();
for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
tess.addVertexWithUV(0, 16, 0, xMin[i], yMax[i]);
tess.addVertexWithUV(16, 16, 0, xMax[i], yMax[i]);
tess.addVertexWithUV(16, 0, 0, xMax[i], yMin[i]);
tess.addVertexWithUV(0, 0, 0, xMin[i], yMin[i]);
}
tess.draw();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_ALPHA_TEST);

GL11.glDisable(GL12.GL_RESCALE_NORMAL);
//GL11.glDisable(GL12.GL_RESCALE_NORMAL);
texturemanager.bindTexture(texturemanager.getResourceLocation(item.getItemSpriteNumber()));
TextureUtil.func_147945_b();
}
Expand All @@ -208,6 +205,7 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)
tess.setNormal(0, 0, 1);
for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
tess.addVertexWithUV(0, 0, 0, xMax[i], yMax[i]);
tess.addVertexWithUV(1, 0, 0, xMin[i], yMax[i]);
tess.addVertexWithUV(1, 1, 0, xMin[i], yMin[i]);
Expand All @@ -220,6 +218,7 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)
tess.setNormal(0, 0, -1);
for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
tess.addVertexWithUV(0, 1, -depth, xMax[i], yMin[i]);
tess.addVertexWithUV(1, 1, -depth, xMin[i], yMin[i]);
tess.addVertexWithUV(1, 0, -depth, xMin[i], yMax[i]);
Expand All @@ -235,6 +234,7 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)

for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
float w = width[i], m = xMax[i], d = xDiff[i], s = xSub[i];
for (int k = 0, e = (int) w; k < e; ++k)
{
Expand All @@ -254,6 +254,7 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)

for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
float w = width[i], m = xMax[i], d = xDiff[i], s = xSub[i];
float d2 = 1f / w;
for (int k = 0, e = (int) w; k < e; ++k)
Expand All @@ -274,6 +275,7 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)

for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
float h = height[i], m = yMax[i], d = yDiff[i], s = ySub[i];
float d2 = 1f / h;
for (int k = 0, e = (int) h; k < e; ++k)
Expand All @@ -294,6 +296,7 @@ public void renderItem (ItemRenderType type, ItemStack item, Object... data)

for (int i = 0; i < iconParts; ++i)
{
tess.setColorOpaque_I(color[i]);
float h = height[i], m = yMax[i], d = yDiff[i], s = ySub[i];
for (int k = 0, e = (int) h; k < e; ++k)
{
Expand Down

0 comments on commit 1f0b88b

Please sign in to comment.