Jump to content

[1.12.2] How could I color a block according to r, g, b & a values?


lyghtningwither

Recommended Posts

I am a precisionist. I must have everything colored the right way. So that's why I created the RGB block: for people like me who aren't satisfied with Minecraft's 14 or so default colors and want to be able to have all 4,294,967,296 possible RGBA colors. But I've run into a big problem. I can't figure out how to color it. It is, by default, black. I am using a TileEntitySpecialRenderer. I know my tile entity's R, G, B & A values are being set (I printed them out to the console). The way they are set is kind of like a sign, as when you place it a screen pops up prompting you to enter in the RGBA values. Then the TESR takes those values in, binds a white texture, renders the model, and calls GLStateManager.color, using the TileEntityRgb's R, G, B & A values divided by 255 (as they're 0-255), and then calls pop matrix and all that stuff. But for some reason, it's still only placing black. The lighting and everything is working, it just isn't setting the correct texture. Attached is a screenshot of a block that should've been a transparent, light blue.

Here is my code for the TESR:

private static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/blocks/rgb.png");
	private final ModelRgbBlock MODEL = new ModelRgbBlock();
	
	@Override
	public void render(TileEntityRgb te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
		
		GlStateManager.enableDepth();
        GlStateManager.depthFunc(515);
        GlStateManager.depthMask(true);
    	
    	ModelRgbBlock model = MODEL;
    	
    	if (destroyStage >= 0) {
    		
            this.bindTexture(DESTROY_STAGES[destroyStage]);
            GlStateManager.matrixMode(5890);
            GlStateManager.pushMatrix();
            GlStateManager.scale(4.0F, 4.0F, 1.0F);
            GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
            GlStateManager.matrixMode(5888);
        } else this.bindTexture(TEXTURE);
    	
    	GlStateManager.pushMatrix();
        GlStateManager.enableRescaleNormal();
        GlStateManager.translate((float)x, (float)y + 1.0F, (float)z + 1.0F);
        GlStateManager.scale(1.0F, -1.0F, -1.0F);
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
       
        model.renderAll();
        GlStateManager.color(te.r / 255, te.g / 255, te.b / 255, te.a / 255);
        GlStateManager.disableRescaleNormal();
        GlStateManager.popMatrix();

        if (destroyStage >= 0) {
        	
            GlStateManager.matrixMode(5890);
            GlStateManager.popMatrix();
            GlStateManager.matrixMode(5888);
        

By the way, renderAll() is just a function that renders without the need for entity variables and all that stuff that isn't needed just to render a cube.

I don't know what's going on with this code, so please, if you could, point me in the right direction on what I need to do. Thanks in advance!

2018-12-26_17.38.38.png

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Link to comment
Share on other sites

Are your RGB values actually being synced to the client? I suspect that they're always 0 on the client, so the block is being rendered black.

 

There's no need for a TESR here at all. If you register a standard JSON model with a tint index (see the wiki), you can then register an IBlockColor that reads the RGB value from the TileEntity and returns it.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

Huh. I never even knew there was a tint thingy. I want to stick to the TESR, though, as I eventually want you to be able to apply custom textures and rotations and stuff like that. How would I update this on the client side?

I like programming. I also have a lot of problems with programming. So I came here on this forum so that I could get my problems solved.

 

Thank you to everyone who has helped me on the forum! You will be appreciated.

Link to comment
Share on other sites

2 hours ago, lyghtningwither said:

Huh. I never even knew there was a tint thingy. I want to stick to the TESR, though, as I eventually want you to be able to apply custom textures and rotations and stuff like that. How would I update this on the client side?

 

See the Forge documentation.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • LAYANAN DAFTAR TRANSTOGEL ! WA : 082213952901 SEARCH GOOGLE > TRANSTOGEL  
    • If you’ve ever experienced the sinking feeling of losing funds online, you’re not alone. Enter recovery services like ADWARE RECOVERY SPECIALIST, the heroes of the digital age who help individuals track down and retrieve lost funds. These services act as modern-day sheriffs in the Wild West of the internet, bringing justice to those who have fallen victim to online scams and fraud. In a world where online transactions are as common as selfies, the need for recovery services is more pressing than ever. Individuals worldwide are vulnerable to various online schemes, from investment fraud to phishing scams. Recovery services provide a glimmer of hope for those who have lost money, offering a chance to recover what's rightfully theirs and restore faith in the digital realm. The beauty of recovery services like ADWARE RECOVERY SPECIALIST lies in their global reach. Email: Adwarerecoveryspecialist@auctioneer. net  Regardless of where individuals are located worldwide, these services extend their virtual arms to help victims of online fraud. From bustling metropolises to remote villages, no corner of the world is beyond the grasp of these modern-day Robin Hoods. Thanks to the wonders of globalization, recovery services have transcended geographical boundaries to serve individuals worldwide. The interconnected nature of the digital world means that help is just a click away, bridging gaps between nations and bringing relief to those in need. In a world where borders are becoming increasingly blurred, recovery services stand as beacons of accessibility and assistance. When a broker stole from me and withheld access from me for five months, I had no idea that I would be able to recover my trading money back. I'm relieved that I was able to get my money returned without any issues. The impact of recovery services like ADWARE RECOVERY SPECIALIST extends far beyond individual wallets. Communities worldwide have experienced a renewed sense of trust and security, knowing that there are dedicated professionals working tirelessly to recover their lost assets. These services not only bring financial relief but also restore faith in the integrity of the digital world. Trust is the cornerstone of any successful recovery service, and building credibility in a global market can pose unique challenges. ADWARE RECOVERY SPECIALIST strives to maintain transparency and reliability in all its interactions, earning the trust of clients worldwide. ADWARE RECOVERY SPECIALIST can be talked to through:  Website: www.adwarerecoveryspecialist.expert  Telegram: @ADWARE_RECOVERY_SPECIALIST
    • The game wont start and keeps crashing everytime I hit play "The game crashed whilst rendering overlay Error: java.lang.IllegalAccessError: failed to access class com.mojang.blaze3d.platform.GlStateManager$TextureState from class net.coderbot.iris.gl.IrisRenderSystem$DSAARB (com.mojang.blaze3d.platform.GlStateManager$TextureState is in module minecraft@1.18.2 of loader 'TRANSFORMER' @724b939e; net.coderbot.iris.gl.IrisRenderSystem$DSAARB is in module oculus@1.6.4 of loader 'TRANSFORMER' @724b939e)" How do I get it to stop? Log error here: https://pastebin.com/byv1dR54
    • In case anyone happens on this with the same issue, I was able to overcome it. After re-reading @Paint_Ninja's last post numerous time, it finally dawned on me that he was referring wholly to the forge installer, which has nothing to do with the packaged modpack installer. As such, I downloaded the new copy of the forge installer and copied it to my linux host, then opened a second ssh session and prepared a cp command to move the new (correct) installer over to the install directory where I was installing the modpack. After the modpack installer had just about finished retrieving files, I overwrote the installer.jar file with the correct one in a seperate ssh session. The modpack (packaged) installer then used that jar to install forge with the included files, and the install finished as I would have expected. Thanks all!
    • Just tried it again removed directory entirely, downloaded a brand new, fresh copy and did a fresh install, even going as far as running as root for the install to make sure I didn't hose something up permissions wise (I know its a terrible idea.), but same thing, failed install. This is making me feel mighty dumb, I must say... any help anyone could provide would be greatly appreciated.
  • Topics

×
×
  • Create New...

Important Information

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