Jump to content

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


Recommended Posts

Posted

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)

 

Posted

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

 

}

 

 

Posted

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

Posted

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

 

Posted

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;
        }
    }

Posted

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/

Posted

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

Posted

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/

  • 2 weeks later...
Posted

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

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Without Network protocol fix mod, I get kicked with a Network Protocol error when on LAN. Also, both of these issues are caused by a Null Pointer Exception/Screen cannot be null in a "Client Bound Player Combat Kill Packet".
    • You need a new "items" folder at  resources/assets/yourmodid/ there you add for every item model a .json file with the exact item/block name and fill it like this if it's an item: { "model": { "type": "minecraft:model", "model": "yourmodid:item/youritem" } } and so if its a block: { "model": { "type": "minecraft:model", "model": "yourmodid:block/youritem" } } There is also a generator for it you can do namy crazy things with it which replaces the previous hard coded Item Properties implementaion method (Bow pulling animation for example). https://misode.github.io/assets/item/
    • Hello! I'm playing a modpack (custom made) with some friends, and we have the server running on BisectHosting. We encountered a bug with an entity from The Box Of Horrors mod, that would crash the game whenever someone nearby it would log in. We tried to fix it by: 1) Editing the player.dat files to change the location of the affected players (something I had done successfully previously) 2) Updating the version of the mod we had (0.0.8.2) to the latest alpha version (0.0.8.3 However, after doing both of those, none of us are able to join the server, and we get the following errors: Server side: https://pastebin.com/J5sc3VQN Client side: Internal Server Error (that's basically all I've gotten) Please help! I've tried restoring the player data to how it was before I made the changes (Bisect allows you to restore deleted files) and deleting all of my player data files and I still get the same error. Deleting Box Of Horrors causes the error: Failed to load datapacks, cannot continue with server load.
    • Hey there! I'm trying to create a simple mod for Forge 1.21.1 that adds a few custom banner patterns that don't require any banner pattern items. To be completely honest, this is my first time modding for Minecraft, so after setting up the project in Intellij, I copied the parts of the source code from this mod on CurseForge that dealt with adding and registering banner patterns, including the lang and banner_pattern .json files. From what I understand, to add a banner pattern that doesn't require a banner pattern item, I only needed to create the registries for each pattern like in here and then register it in the main java class like here on Line 54. Additionally, in the lang/en_us.json file, add in the names for each respective banner color, and in the data/minecraft/tags/banner_pattern/no_items_required.json file, add each banner pattern that does not require a banner pattern item to make a banner. The project is able to compile when loading in Forge which makes me assume that the file structure I have is correct, but on loading a Minecraft world, this error appears in console and the loom is subsequently blank. [Worker-Main-1/ERROR] [minecraft/TagLoader]: Couldn't load tag minecraft:no_item_required as it is missing following references: *lists every added entry in no_item_required.json* The message clearly states something went wrong regarding when trying to load in the registries from the mod, but I have no clue what could be wrong with the code I have. Attached below are screenshots of what I currently have. Java Main Class Banner Registry Class File Structure Error in Console upon loading a Minecraft world What the loom shows without minecraft:no_item_required    The original mod I copied still functions completely, so if anyone can figure out why the registries for the mod I'm making isn't working, that would be greatly appreciated!    
    • Please someone help me to know how can I fix this generation error in the trees! I already uninstalled and reinstalled several mods in my modpack and can't figure out what is causing it.    
  • Topics

×
×
  • Create New...

Important Information

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