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 render a quad that always faces the player in the RenderWorldLastEvent. The code either fails to render completely or sometimes flickers in and out of view whenever the player moves. Can someone help?

Edited by Melonslise

7 hours ago, Melonslise said:

I'm trying to render a quad that always faces the player in the RenderWorldLastEvent. The code either fails to render completely or sometimes flickers in and out of view whenever the player moves. Can someone help?

Look at render snowball

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author
8 hours ago, Cadiboo said:

Look at render snowball

I tried adding and playing around with the code from RenderSnowball, but it gave really weird results. I also feel like the rotation code from RenderSnowball won't work with a long beam of sorts that I'm trying to make.

Here's my code:

 

 


public static void drawLine(double startX, double startY, double startZ, double endX, double endY, double endZ, int red, int green, int blue, int alpha, double width, float partialTick)
{
	Minecraft mc = Minecraft.getMinecraft();

	// TODO RenderPos from RenderManager
	double
	originX = mc.player.lastTickPosX + (mc.player.posX - mc.player.lastTickPosX) * (double) partialTick,
	originY = mc.player.lastTickPosY + (mc.player.posY - mc.player.lastTickPosY) * (double) partialTick,
	originZ = mc.player.lastTickPosZ + (mc.player.posZ - mc.player.lastTickPosZ) * (double) partialTick;

	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();

	GlStateManager.pushMatrix();
	GlStateManager.disableCull();
	GlStateManager.disableTexture2D();

	GlStateManager.rotate(-mc.getRenderManager().playerViewY, 0F, 1F, 0F);
	GlStateManager.rotate(mc.getRenderManager().options.thirdPersonView == 2 ? -1F : 1F * mc.getRenderManager().playerViewX, 1F, 0F, 0F);
	GlStateManager.rotate(180F, 0F, 1F, 0F);

	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
	buffer.pos(startX - originX, startY - originY - width / 2D, startZ - originZ).color(red, green, blue, alpha).endVertex();
	buffer.pos(endX - originX, endY - originY - width / 2D, endZ - originZ).color(red, green, blue, alpha).endVertex();
	buffer.pos(endX- originX, endY - originY + width / 2D, endZ - originZ).color(red, green, blue, alpha).endVertex();
	buffer.pos(startX - originX, startY - originY + width / 2D, startZ - originZ).color(red, green, blue, alpha).endVertex();
	tessellator.draw();

	GlStateManager.enableTexture2D();
	GlStateManager.enableCull();

	GlStateManager.popMatrix();
}

 

Edited by Melonslise

What exactly are you trying to do?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author
6 minutes ago, Cadiboo said:

What exactly are you trying to do?

I'm trying to render beam with a start and end point that faces the player's look vector.

  • Author

I got it!

Here's the code if anyone is interested:

 

public static void drawLine(Vec3d start, Vec3d end, int red, int green, int blue, int alpha, double width, float partialTick)
{
	Minecraft mc = Minecraft.getMinecraft();

	// TODO RenderPos from RenderManager?
	Vec3d origin = new Vec3d(mc.player.lastTickPosX + (mc.player.posX - mc.player.lastTickPosX) * (double) partialTick, mc.player.lastTickPosY + (mc.player.posY - mc.player.lastTickPosY) * (double) partialTick, mc.player.lastTickPosZ + (mc.player.posZ - mc.player.lastTickPosZ) * (double) partialTick);

	Vec3d camera = mc.player.getPositionEyes(partialTick);
	Vec3d direction = end.subtract(start).normalize();
	Vec3d startUp = direction.crossProduct(start.subtract(camera)).normalize().scale(width);
	Vec3d endUp = direction.crossProduct(end.subtract(camera)).normalize().scale(width);

	Tessellator tessellator = Tessellator.getInstance();
	BufferBuilder buffer = tessellator.getBuffer();

	GlStateManager.pushMatrix();
	GlStateManager.disableCull();
	GlStateManager.disableTexture2D();

	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
	buffer.pos(start.x + startUp.x - origin.x, start.y + startUp.y - origin.y, start.z + startUp.z - origin.z).color(red, green, blue, alpha).endVertex();
	buffer.pos(start.x - startUp.x - origin.x, start.y - startUp.y - origin.y, start.z - startUp.z - origin.z).color(red, green, blue, alpha).endVertex();
	buffer.pos(end.x - endUp.x - origin.x, end.y - endUp.y - origin.y, end.z - endUp.z - origin.z).color(red, green, blue, alpha).endVertex();
	buffer.pos(end.x + endUp.x - origin.x, end.y + endUp.y - origin.y, end.z + endUp.z - origin.z).color(red, green, blue, alpha).endVertex();
	tessellator.draw();

	GlStateManager.enableTexture2D();
	GlStateManager.enableCull();

	GlStateManager.popMatrix();
}

 

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.