Jump to content

[1.7.10] GL11.color4f does not change color of rendered block...


Elix_x

Recommended Posts

Good day, so:

I used coremod to integrate code call before each block rendering and after, because i want to change color of certain blocks at certain positions, but using gl11.glolor4f does not do anything.

I know exactly that:

-Methods are getting called and code reaches color4f (known via console output)

-Gl11.color4f woks if applied on tileentit custom render in render code, even with same args

-Coloring is not working even on custom rendered tileentities

 

And also, i'm pushing new matrix before colored block is rendered and colored and popping after...

 

Nor block nor position are 'unknown' for me and are decided by user...

 

Thanks for help, and if you need anything - just ask! (i don't know if you need code, because i already wrote that i'm using GL11.glColor4f)

 

Link to comment
Share on other sites

Since minecraft uses his Tessellator to render stuff, glColor4f can not be used for that.

WHat you have to do is creating an instance variable of Tessellator and then calling the setColor-method like this:

 

public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

  Tessellator tessellator = Tessellator.instance;

  glPushMatrix();

      tessellator.setColorRGBA(ValueRed,ValueGreen,ValueBlue,ValueAlpha);

      //Rest of your rendercode here

  glPopMatrix();

 

}

 

 

Link to comment
Share on other sites

Since minecraft uses his Tessellator to render stuff, glColor4f can not be used for that.

WHat you have to do is creating an instance variable of Tessellator and then calling the setColor-method like this:

 

public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

  Tessellator tessellator = Tessellator.instance;

  glPushMatrix();

      tessellator.setColorRGBA(ValueRed,ValueGreen,ValueBlue,ValueAlpha);

      //Rest of your rendercode here

  glPopMatrix();

 

}

 

You have not understood what i mean, and color4f works on custom rendered tileentities...

1) i tried using tessellator.setColorRGBA too, same result...

2) if inserting gl11.color4f in custom tile entity renderer, it works

3) but doing this before block rendering (asm used for call), it does not...

Link to comment
Share on other sites

I'm not sure where in the block render path your coremod is working, but I don't believe any of the block render layers have color blending enabled. CUTOUT and TRANSLUCENT have 2 different alpha modes enabled, but they don't seem blend colors. You could try setting a blend mode in your coremod. I know it works in a TESR I use to color a grayscaled texture. I don't think it's a vertex format issue since the format used for blocks already has 4 color channels.

 

GlStateManager.color(...) could work for you as well. The world renderer and state manager make sure vertex modes are set correctly and other redundancies. Beyond tracing the path through the block and TESR render paths and digging out all the specific settings, I can't think of much else to try. I haven't done any core mods personally, so I can't say how tricky managing these settings might become. Here's the blend setup from my TESR:

 

GlStateManager.disableLighting();

GlStateManager.enableBlend();

GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);

 

Link to comment
Share on other sites

I'm not sure where in the block render path your coremod is working, but I don't believe any of the block render layers have color blending enabled. CUTOUT and TRANSLUCENT have 2 different alpha modes enabled, but they don't seem blend colors. You could try setting a blend mode in your coremod. I know it works in a TESR I use to color a grayscaled texture. I don't think it's a vertex format issue since the format used for blocks already has 4 color channels.

 

GlStateManager.color(...) could work for you as well. The world renderer and state manager make sure vertex modes are set correctly and other redundancies. Beyond tracing the path through the block and TESR render paths and digging out all the specific settings, I can't think of much else to try. I haven't done any core mods personally, so I can't say how tricky managing these settings might become. Here's the blend setup from my TESR:

 

GlStateManager.disableLighting();

GlStateManager.enableBlend();

GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);

GlStateManager? Where? I don't have one...

 

Ok, i guess i can replace it with that:

GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_BLEND);

 

But is not working too...

 

And also, here's modifed WorldRenderer's update renderer with method calls marked with //*****\\:

public void updateRenderer(EntityLivingBase p_147892_1_)
    {
        if (this.needsUpdate)
        {
            this.needsUpdate = false;
            int i = this.posX;
            int j = this.posY;
            int k = this.posZ;
            int l = this.posX + 16;
            int i1 = this.posY + 16;
            int j1 = this.posZ + 16;

            for (int k1 = 0; k1 < 2; ++k1)
            {
                this.skipRenderPass[k1] = true;
            }

            Chunk.isLit = false;
            HashSet hashset = new HashSet();
            hashset.addAll(this.tileEntityRenderers);
            this.tileEntityRenderers.clear();
            Minecraft minecraft = Minecraft.getMinecraft();
            EntityLivingBase entitylivingbase1 = minecraft.renderViewEntity;
            int l1 = MathHelper.floor_double(entitylivingbase1.posX);
            int i2 = MathHelper.floor_double(entitylivingbase1.posY);
            int j2 = MathHelper.floor_double(entitylivingbase1.posZ);
            byte b0 = 1;
            ChunkCache chunkcache = new ChunkCache(this.worldObj, i - b0, j - b0, k - b0, l + b0, i1 + b0, j1 + b0, b0);

            if (!chunkcache.extendedLevelsInChunkCache())
            {
                ++chunksUpdated;
                RenderBlocks renderblocks = new RenderBlocks(chunkcache);
                net.minecraftforge.client.ForgeHooksClient.setWorldRendererRB(renderblocks);
                this.bytesDrawn = 0;
                this.vertexState = null;

                for (int k2 = 0; k2 < 2; ++k2)
                {
                    boolean flag = false;
                    boolean flag1 = false;
                    boolean flag2 = false;

                    for (int l2 = j; l2 < i1; ++l2)
                    {
                        for (int i3 = k; i3 < j1; ++i3)
                        {
                            for (int j3 = i; j3 < l; ++j3)
                            {
                                Block block = chunkcache.getBlock(j3, l2, i3);
							//*************************\\
							ColourfullBlocksHooks.renderBlock(this, renderblocks, p_147892_1_, j3, l2, i3);
							//*************************\\
                                if (block.getMaterial() != Material.air)
                                {
                                    if (!flag2)
                                    {
                                        flag2 = true;
                                        this.preRenderBlocks(k2);
                                    }

                                    if (k2 == 0 && block.hasTileEntity(chunkcache.getBlockMetadata(j3, l2, i3)))
                                    {
                                        TileEntity tileentity = chunkcache.getTileEntity(j3, l2, i3);

                                        if (TileEntityRendererDispatcher.instance.hasSpecialRenderer(tileentity))
                                        {
                                            this.tileEntityRenderers.add(tileentity);
                                        }
                                    }

                                    int k3 = block.getRenderBlockPass();

                                    if (k3 > k2)
                                    {
                                        flag = true;
                                    }

                                    if (!block.canRenderInPass(k2)) continue;

                                    {
                                        flag1 |= renderblocks.renderBlockByRenderType(block, j3, l2, i3);

                                        if (block.getRenderType() == 0 && j3 == l1 && l2 == i2 && i3 == j2)
                                        {
                                            renderblocks.setRenderFromInside(true);
                                            renderblocks.setRenderAllFaces(true);
                                            renderblocks.renderBlockByRenderType(block, j3, l2, i3);
                                            renderblocks.setRenderFromInside(false);
                                            renderblocks.setRenderAllFaces(false);
                                        }
                                    }
                                }
							//*************************\\
							ColourfullBlocksHooks.postRenderBlock(this, renderblocks, p_147892_1_, j3, l2, i3);
							//*************************\\
                            }
                        }
                    }

                    if (flag1)
                    {
                        this.skipRenderPass[k2] = false;
                    }

                    if (flag2)
                    {
                        this.postRenderBlocks(k2, p_147892_1_);
                    }
                    else
                    {
                        flag1 = false;
                    }

                    if (!flag)
                    {
                        break;
                    }
                }
                net.minecraftforge.client.ForgeHooksClient.setWorldRendererRB(null);
            }

            HashSet hashset1 = new HashSet();
            hashset1.addAll(this.tileEntityRenderers);
            hashset1.removeAll(hashset);
            this.tileEntities.addAll(hashset1);
            hashset.removeAll(this.tileEntityRenderers);
            this.tileEntities.removeAll(hashset);
            this.isChunkLit = Chunk.isLit;
            this.isInitialized = true;
        }
    }

Link to comment
Share on other sites

I'm not sure where in the block render path your coremod is working, but I don't believe any of the block render layers have color blending enabled. CUTOUT and TRANSLUCENT have 2 different alpha modes enabled, but they don't seem blend colors. You could try setting a blend mode in your coremod. I know it works in a TESR I use to color a grayscaled texture. I don't think it's a vertex format issue since the format used for blocks already has 4 color channels.

 

GlStateManager.color(...) could work for you as well. The world renderer and state manager make sure vertex modes are set correctly and other redundancies. Beyond tracing the path through the block and TESR render paths and digging out all the specific settings, I can't think of much else to try. I haven't done any core mods personally, so I can't say how tricky managing these settings might become. Here's the blend setup from my TESR:

 

GlStateManager.disableLighting();

GlStateManager.enableBlend();

GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);

GlStateManager? Where? I don't have one...

That's because he hasn't looked at the title and doesn't know you are working with MC 1.7.10, so he gave code for MC 1.8.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

I'm not sure where in the block render path your coremod is working, but I don't believe any of the block render layers have color blending enabled. CUTOUT and TRANSLUCENT have 2 different alpha modes enabled, but they don't seem blend colors. You could try setting a blend mode in your coremod. I know it works in a TESR I use to color a grayscaled texture. I don't think it's a vertex format issue since the format used for blocks already has 4 color channels.

 

GlStateManager.color(...) could work for you as well. The world renderer and state manager make sure vertex modes are set correctly and other redundancies. Beyond tracing the path through the block and TESR render paths and digging out all the specific settings, I can't think of much else to try. I haven't done any core mods personally, so I can't say how tricky managing these settings might become. Here's the blend setup from my TESR:

 

GlStateManager.disableLighting();

GlStateManager.enableBlend();

GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);

GlStateManager? Where? I don't have one...

That's because he hasn't looked at the title and doesn't know you are working with MC 1.7.10, so he gave code for MC 1.8.

 

Ok, i guess i can replace first 2 with

			GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_BLEND);

But what is third one?

 

Anyways it didn't help... Any more ideas???

Link to comment
Share on other sites

I'm not sure where in the block render path your coremod is working, but I don't believe any of the block render layers have color blending enabled. CUTOUT and TRANSLUCENT have 2 different alpha modes enabled, but they don't seem blend colors. You could try setting a blend mode in your coremod. I know it works in a TESR I use to color a grayscaled texture. I don't think it's a vertex format issue since the format used for blocks already has 4 color channels.

 

GlStateManager.color(...) could work for you as well. The world renderer and state manager make sure vertex modes are set correctly and other redundancies. Beyond tracing the path through the block and TESR render paths and digging out all the specific settings, I can't think of much else to try. I haven't done any core mods personally, so I can't say how tricky managing these settings might become. Here's the blend setup from my TESR:

 

GlStateManager.disableLighting();

GlStateManager.enableBlend();

GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);

GlStateManager? Where? I don't have one...

That's because he hasn't looked at the title and doesn't know you are working with MC 1.7.10, so he gave code for MC 1.8.

 

Ok, i guess i can replace first 2 with

			GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_BLEND);

But what is third one?

 

Anyways it didn't help... Any more ideas???

The third one you can replace with
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

  • 2 weeks later...

I'm not sure where in the block render path your coremod is working, but I don't believe any of the block render layers have color blending enabled. CUTOUT and TRANSLUCENT have 2 different alpha modes enabled, but they don't seem blend colors. You could try setting a blend mode in your coremod. I know it works in a TESR I use to color a grayscaled texture. I don't think it's a vertex format issue since the format used for blocks already has 4 color channels.

 

GlStateManager.color(...) could work for you as well. The world renderer and state manager make sure vertex modes are set correctly and other redundancies. Beyond tracing the path through the block and TESR render paths and digging out all the specific settings, I can't think of much else to try. I haven't done any core mods personally, so I can't say how tricky managing these settings might become. Here's the blend setup from my TESR:

 

GlStateManager.disableLighting();

GlStateManager.enableBlend();

GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);

GlStateManager? Where? I don't have one...

That's because he hasn't looked at the title and doesn't know you are working with MC 1.7.10, so he gave code for MC 1.8.

 

Ok, i guess i can replace first 2 with

			GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_BLEND);

But what is third one?

 

Anyways it didn't help... Any more ideas???

The third one you can replace with
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

.

Well, it didn't hlp... Anything would not help... Because of another recoloring happenning after and overriding previous one... Only integrating code in another place helped...

Link to comment
Share on other sites

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

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