Posted August 13, 201510 yr Right now what I am trying to do is in my mod I have an element that gets rendered into the world and onto a Gui, instead of specifying the color of it, I would like to color it based on rgb values entered with a slider. right now I have the sliders working but it doesn't give the correct color. This is the code: public int red; public int green; public int blue; public Point(int red, int green, int blue) { this.red = red; this.green = green; this.blue = blue; } // Renders the element into the world public void drawIconInWorld(WorldRenderer worldrenderer, Tessellator tessellator) { int i = this.red >> 16 & 255; int i1 = this.green >> 8 & 255; int i2 = this.blue & 255; GlStateManager.disableTexture2D(); worldrenderer.startDrawingQuads(); worldrenderer.setColorRGBA(i, i1, i2, 120); worldrenderer.addVertex(-5.0D, -9.0D, 0.0D); worldrenderer.addVertex(-5.0D, 0.0D, 0.0D); worldrenderer.addVertex(4.0D, 0.0D, 0.0D); worldrenderer.addVertex(4.0D, -9.0D, 0.0D); tessellator.draw(); GlStateManager.enableTexture2D(); } // Renders the element onto the GUI public void drawIconOnGui(int drawX, int drawY) { int rectX2 = drawX + 9; int rectY2 = drawY + 9; Gui.drawRect(drawX, drawY, rectX2, rectY2, this.red >> 16 & 255 | this.green >> 8 & 255 | this.blue & 255); }
August 13, 201510 yr Author honestly I think that was me testing and not realizing I don't exactly have to do those, but still not 100% sure about the gui
August 13, 201510 yr Author I have changed it to Gui.drawRect(drawX, drawY, rectX2, rectY2, (this.red << 16 & 255 | this.green << 8 & 255 | this.blue & 255)); and now it just doesn't appear to draw the rectangle.
August 13, 201510 yr Or more accurately, because of math, it's 0 (you start with 0 and start adding things together, and none of the values added end up in the set of bits used by alpha, so its 0). Also, drop the & 255 bit. That's setting all of your color values to 0. red = 128; //red is 128 red = red << 16; //red is 8388608 red = red & 255; //red is 0 /* 100000000000000000000000 & 11111111 ========================== 000000000000000000000000 */ Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 13, 201510 yr Author I'm not exactly great with the colors, how would I add the alpha value to the: this.red << 16 | this.green << 8 | this.blue
August 13, 201510 yr Complete the next item in the series: 0, 8, 16... 24. this.alpha << 24 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 13, 201510 yr Author alright its working, thanks. Edit: actually noticing this, but when I change the blue value it changes the alpha...
August 13, 201510 yr Then the color might be oriented in RGBA instead of ARGB Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 13, 201510 yr Author tried int color = (this.red << 16 | this.green << 8 | this.blue); Gui.drawRect(drawX, drawY, rectX2, rectY2, color << 24 | color); and int color = (this.red << 16 | this.green << 8 | this.blue); Gui.drawRect(drawX, drawY, rectX2, rectY2, color | color << 24); but it made no difference.
August 14, 201510 yr tried int color = (this.red << 16 | this.green << 8 | this.blue); Gui.drawRect(drawX, drawY, rectX2, rectY2, color << 24 | color); and int color = (this.red << 16 | this.green << 8 | this.blue); Gui.drawRect(drawX, drawY, rectX2, rectY2, color | color << 24); but it made no difference. Holy smokes dude! If the bit shifting is causing you that much grief, perhaps try this class instead- Java.awt.Color Color myColour = new Color(red, green, blue); Gui.drawRect(drawX, drawY, rectX2, rectY2, myColour.getRGB()); -TGG
August 14, 201510 yr *facepalm* Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 14, 201510 yr I'm not exactly great with the colors, how would I add the alpha value to the: this.red << 16 | this.green << 8 | this.blue You do the same as with red, green and blue, with an alpha value of 255, and bitshifted 24 to the left. 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/
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.