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

I'm trying to allow the user to set the color of the lines I'm rendering, but it behaves strangely. The color glitches between Black and the intended color, but mostly the lines are black. Here's the code I'm using to render the lines:

Spoiler

GL11.glPushMatrix();
GL11.glTranslated(-doubleX, -doubleY, -doubleZ);
GL11.glColor3ub((byte)r, (byte)g, (byte)b);
GL11.glLineWidth(ConfigOptions.LineWidth);
GL11.glBegin(GL11.GL_LINES);
for (BlockPos[] bp : lines) {
	BlockPos a1 = bp[0];
	BlockPos b2 = bp[1];
	GL11.glVertex3f(a1.getX(), height(a1), a1.getZ());
	GL11.glVertex3f(b2.getX(), height(b2), b2.getZ());
}
GL11.glEnd();
GL11.glPopMatrix();

 

Does anyone know how to make the lines stay the right color?

2 hours ago, _NIMJA said:

Does anyone know how to make the lines stay the right color?

Where are you setting the color based on payer input?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • Author

Here:

GL11.glColor3ub((byte)r, (byte)g, (byte)b);

r, g, and b are integers between 0 and 255.

2 hours ago, _NIMJA said:

Here:

I meant where are r, g, and b being set in code. Also where is this code being ran.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

First off, you should really be using GlStateManager rather than direct GL11.* calls.

 

Regarding your problem, a GlStateManager.disableTexture2d() call before you draw might help here (although I am speculating, admittedly).

  • Author

R, g, and b are set just above the GL11 stuff.

float r = ConfigOptions.LineColor.R;
float g = ConfigOptions.LineColor.G;
float b = ConfigOptions.LineColor.B;
GL11.glPushMatrix();
GL11.glTranslated(-doubleX, -doubleY, -doubleZ);

And here is the config rgb stuff:

@Name("Line Color")
@Comment("The color of the border line.")
public static ColorCat LineColor = new ColorCat();
public static class ColorCat{
		
	@RangeInt(min = 0, max = 255)
	@Comment("RGB red value.")
	public int R = 0;
		
	@RangeInt(min = 0, max = 255)
	@Comment("RGB green value.")
	public int G = 0;
		
	@RangeInt(min = 0, max = 255)
	@Comment("RGB blue value.")
	public int B = 255;
}

The code is being ran here:

@SubscribeEvent
public static void renderBlocks(DrawBlockHighlightEvent event){
}

Changing to GlStateManager and adding the Texture2D thing helped! However, the line is about 50% transparent.

Sounds like blending is enabled.  Try calling GlStateManager.disableBlend() before you do your line drawing.  Or ensuring an alpha value of 1.0 is passed in your call toGlStateManager.color(...)

 

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.