Hello,
I'm attempting to change the color of a block (of leaves) dynamically based on how close they are to the end of a progress.
I get the model of the leaf to render, but it always renders in greyscale, no matter how I try to modify the color. I've attached my TileEntityRenderer's render function, along with a lot of the debug code I've attempted.
Color output looks like this: Color:-4665437 R:0.72156864 G:0.8117647 B:0.6392157
Any help is appreciated.
@Override
public void render(TileExplosiveLeaves te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
GlStateManager.pushMatrix();
GlStateManager.enableRescaleNormal();
RenderHelper.disableStandardItemLighting();
GlStateManager.enableColorMaterial();
int color = te.getColor().toInt();
float colorRed = (float) (color >> 16 & 255) / 255.0F;
float colorGreen = (float) (color >> 8 & 255) / 255.0F;
float colorBlue = (float) (color & 255) / 255.0F;
float colorAlpha = (float) (color >> 24 & 255) / 255.0F;
System.out.println("Color:" + color + " R:" + colorRed + " G:" + colorGreen + " B:" + colorBlue);
// GlStateManager.resetColor();
// GL11.glColor3f(color.r, color.g, color.b);
// GL11.
GlStateManager.enableBlend();
// GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
World world = te.getWorld();
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Tessellator tessellator = Tessellator.getInstance();
tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
tessellator.getBuffer().color(colorRed, colorGreen, colorBlue, colorAlpha);
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModel(
world,
Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(te.getLeafBlock()),
world.getBlockState(te.getPos()),
te.getPos(),
Tessellator.getInstance().getBuffer(), false);
tessellator.draw();
// RenderHelper.enableStandardItemLighting();
// GlStateManager.enableLighting();
GlStateManager.popMatrix();
GlStateManager.disableBlend();