Advertisement
Guest User

By Melonslise

a guest
Aug 19th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1.     public static void drawLine(Vec3d start, Vec3d end, int red, int green, int blue, int alpha, float width, float partialTick)
  2.     {
  3.         Vec3d camera = Minecraft.getMinecraft().player.getPositionEyes(partialTick);
  4.  
  5.         Vec3d direction = end.subtract(start).normalize();
  6.         Vec3d startUp = direction.crossProduct(start.subtract(camera)).normalize().scale(0.0625);
  7.         Vec3d endUp = direction.crossProduct(end.subtract(camera)).normalize().scale(0.0625);
  8.  
  9.         Tessellator tessellator = Tessellator.getInstance();
  10.         BufferBuilder buffer = tessellator.getBuffer();
  11.  
  12.         // Enable bit ?
  13.         GlStateManager.pushMatrix();
  14.  
  15.         GlStateManager.disableCull(); // Cullface
  16.         GlStateManager.enableBlend();
  17.         GlStateManager.depthMask(false);
  18.         GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  19.  
  20.         buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
  21.         buffer.pos(start.x + startUp.x, start.y + startUp.y, start.z + startUp.z).color(red, green, blue, alpha).endVertex();
  22.         buffer.pos(start.x - startUp.x, start.y - startUp.y, start.z - startUp.z).color(red, green, blue, alpha).endVertex();
  23.         buffer.pos(end.x - endUp.x, end.y - endUp.y, end.z - endUp.z).color(red, green, blue, alpha).endVertex();
  24.         buffer.pos(end.x + endUp.x, end.y + endUp.y, end.z + endUp.z).color(red, green, blue, alpha).endVertex();
  25.         tessellator.draw();
  26.  
  27.         GlStateManager.depthMask(true);
  28.         GlStateManager.disableBlend(); // Cullface
  29.         GlStateManager.enableCull(); // Blend
  30.  
  31.         GlStateManager.popMatrix();
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement