Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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();

 

  • Author
4 minutes ago, diesieben07 said:

Is that process continuous? Or does it happen once?

Once per lifetime of the block (which is destroyed after the process)

  • Author

The colors are dynamic though. So I'd have to define a state for every possible color combination that I want to implement, no?

  • Author
17 hours ago, diesieben07 said:

Ok, so. If you want a continuous color transition (which you still have not answered!) then you need to indeed stick with the TESR. Otherwise use IBlockColors. In your current TESR method the issue is that the model rendering method you are using already applies the block's "native" color modifier, overwriting yours.

Sorry! I thought I did! I do want it to be a continuous. Can you recommend an alternative method to look at for rendering? (I don't need examples, just a general gist will be enough)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.