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

42 minutes ago, Kokkie said:

How can I remove or disable the color being darkened by idk what? Like, I set it to red but it is a dark color red instead of just bright red. Also, it becomes bright red when I don't look at the block and are a few blocks away from it.

That would be lighting.

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.

I tried a lot but could not replicate the issue. I do have an idea of where it could be coming from. The lightmap coordinates might be wrong. You will need to manualy set them to something like 240, 240 with OpenGlHelper::setLightmapTextureCoords to achieve full brightness. 

I do not really know if you 'need to' but you 'should' do it. You can get the current lightmap coordinates at OpenGlHelper.lastBrightnessX/OpenGlHelper.lastBrightnessY. Idealy you would just put you lightmap coordinates directly into the BufferBuilder by specifying a format that supports them though and using BufferBuilder::lightmap for each vertex.

  • Author

So this?

public class AMUtils {
	public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) {
		drawLine(start, end, x + 0.5, y + 0.5, z + 0.5);
	}

	public static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder bb = Tessellator.getInstance().getBuffer();
		bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		bb.pos(x, y, z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		bb.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}

	public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		double minX = x + posDiff.x - 0.01;
		double minY = y + posDiff.y - 0.01;
		double minZ = z + posDiff.z - 0.01;
		double maxX = x + posDiff.x + 1.01;
		double maxY = y + posDiff.y + 1.01;
		double maxZ = z + posDiff.z + 1.01;
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder bb = Tessellator.getInstance().getBuffer();
		bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		bb.lightmap(240, 240);
		RenderGlobal.drawBoundingBox(bb, minX, minY, minZ, maxX, maxY, maxZ, 1, 0, 0, 1);
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}

	public static void drawCross(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder bb = Tessellator.getInstance().getBuffer();
		bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();

		bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();

		bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();

		bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}
}

Because this isn't working...

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

2 minutes ago, Kokkie said:

bb.lightmap(240, 240);

lightmap is a vertex property. You can't just call it for a buffer as a whole and call it a day. This will not work.

 

3 minutes ago, Kokkie said:

POSITION_TEX_LMAP_COLOR

If you are specifying position, texture, lightmap and color you need to provide them. You are not providing the uvs.

 

2 minutes ago, Kokkie said:

bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);

RenderGlobal.drawBoundingBox(bb, minX, minY, minZ, maxX, maxY, maxZ, 1, 0, 0, 1);

RenderGlobal::drawBoundingBox is written to only handle position and color. You can start the drawing with any other format and it will not work bacause it is not coded to. You need to provide your own code for doing that. This is the reason I originaly suggested using OpenGlHelper::setLightmapTextureCoords.

  • Author

So like this?

public class AMUtils {
	public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) {
		drawLine(start, end, x + 0.5, y + 0.5, z + 0.5);
	}

	public static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder bb = Tessellator.getInstance().getBuffer();
		bb.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		bb.pos(x, y, z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();
		bb.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}

	public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		double minX = x + posDiff.x - 0.01;
		double minY = y + posDiff.y - 0.01;
		double minZ = z + posDiff.z - 0.01;
		double maxX = x + posDiff.x + 1.01;
		double maxY = y + posDiff.y + 1.01;
		double maxZ = z + posDiff.z + 1.01;
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder buffer = Tessellator.getInstance().getBuffer();
		buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		buffer.lightmap(240, 240);
        buffer.pos(minX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(maxX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(maxX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(minX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(minX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(minX, maxY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(maxX, maxY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(maxX, maxY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(minX, maxY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(minX, maxY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(minX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(maxX, minY, maxZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
        buffer.pos(maxX, minY, minZ).color(1, 0, 0, 1).lightmap(240, 240).tex(0, 0).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}

	public static void drawCross(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder bb = Tessellator.getInstance().getBuffer();
		bb.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();
		bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();

		bb.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();
		bb.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();

		bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();
		bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();

		bb.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();
		bb.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
    }
}

 

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

1 minute ago, Kokkie said:

buffer.lightmap(240, 240);

You still have this call. Remove it.

 

5 minutes ago, Kokkie said:

bb.pos(x, y, z).color(1, 0, 0, 1F).lightmap(240, 240).endVertex();

You are not specifying the uvs here.

 

5 minutes ago, Kokkie said:

POSITION_TEX_LMAP_COLOR

 

5 minutes ago, Kokkie said:

pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).color(1, 0, 0, 1F).lightmap(240, 240).tex(0, 0)

pos, color, lightmap, tex != pos, tex, lightmap, color. Ordering matters. Same applies to the code you've copied from RenderGlobal.

  • Author

This..?

public class AMUtils {
	public static void drawLineMiddle(BlockPos start, BlockPos end, double x, double y, double z) {
		drawLine(start, end, x + 0.5, y + 0.5, z + 0.5);
	}

	public static void drawLine(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder buffer = Tessellator.getInstance().getBuffer();
		buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		buffer.pos(x, y, z).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(x + posDiff.x, y + posDiff.y, z + posDiff.z).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}

	public static void drawBox(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		double minX = x + posDiff.x - 0.01;
		double minY = y + posDiff.y - 0.01;
		double minZ = z + posDiff.z - 0.01;
		double maxX = x + posDiff.x + 1.01;
		double maxY = y + posDiff.y + 1.01;
		double maxZ = z + posDiff.z + 1.01;
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder buffer = Tessellator.getInstance().getBuffer();
		buffer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		buffer.pos(minX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex();
		buffer.pos(minX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(minX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(minX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(minX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(minX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(minX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(minX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex();
		buffer.pos(minX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, maxY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex();
		buffer.pos(maxX, minY, maxZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, maxY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex();
		buffer.pos(maxX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(maxX, minY, minZ).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 0).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}

	public static void drawCross(BlockPos start, BlockPos end, double x, double y, double z) {
		Vec3d start1 = new Vec3d(start);
		Vec3d end1 = new Vec3d(end);
		Vec3d posDiff = end1.subtract(start1);
		GlStateManager.pushMatrix();
		GlStateManager.glLineWidth(2F);
		GlStateManager.disableTexture2D();
		GlStateManager.disableLighting();
		BufferBuilder buffer = Tessellator.getInstance().getBuffer();
		buffer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_TEX_LMAP_COLOR);
		buffer.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();

		buffer.pos(x + posDiff.x - 0.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(x + posDiff.x + 1.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();

		buffer.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();

		buffer.pos(x + posDiff.x - 0.01, y + posDiff.y + 1.01, z + posDiff.z - 0.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		buffer.pos(x + posDiff.x + 1.01, y + posDiff.y - 0.01, z + posDiff.z + 1.01).tex(0, 0).lightmap(240, 240).color(1, 0, 0, 1).endVertex();
		Tessellator.getInstance().draw();
		GlStateManager.enableLighting();
		GlStateManager.enableTexture2D();
		GlStateManager.popMatrix();
	}
}

 

Classes: 94

Lines of code: 12173

Other files: 206

Github repo: https://github.com/KokkieBeer/DeGeweldigeMod

Almost. This is correct for the most part but there is one small, illusive and obscure issue. The BufferBuilder::color method has 2 overloads - 1 that uses 4 floats of [0 - 1] ranges and 1 that uses 4 integers of [0 - 255] ranges. As integer is the default number in java when you pass in a number without specifying it's type(like you are doing everywhere with color(1, 0, 0, 1)) it is assumed to be an integer. So the method with integers as params gets invoked instead of the one with floats and... well, you are passing 1 as alpha which considering an integer range of that method is practicaly invisible. You need to specify at least one number as a float so the correct method is chosen.

 

In my original example I use

color(1, 0, 0, 1F)

Note the 1F at the end. By passing that number as a float I force the correct method to be chosen.

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.