Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 KB | None | 0 0
  1. @Override
  2. @SideOnly(Side.CLIENT)
  3. public void renderLightBetweenTwoPoints(double firstX, double firstY, double firstZ, double secondX, double secondY, double secondZ, int rotationTime, float alpha, double beamWidth, float[] firstColor, float[] secondColor){
  4. Tessellator tessy = Tessellator.getInstance();
  5. WorldRenderer render = tessy.getWorldRenderer();
  6. World world = ClientUtil.mc().theWorld;
  7.  
  8. GlStateManager.disableFog();
  9.  
  10. float r = firstColor[0];
  11. float g = firstColor[1];
  12. float b = firstColor[2];
  13.  
  14. float r2 = secondColor[0];
  15. float g2 = secondColor[1];
  16. float b2 = secondColor[2];
  17.  
  18. Vec3d vec1 = new Vec3d(firstX, firstY, firstZ);
  19. Vec3d vec2 = new Vec3d(secondX, secondY, secondZ);
  20. Vec3d combinedVec = new Vec3d(vec2);
  21. combinedVec.sub(vec1);
  22.  
  23. float rot = rotationTime > 0 ? (360F*((float)((world.getTotalWorldTime())%rotationTime)/(float)rotationTime)) : 0;
  24. double pitch = Math.atan2(combinedVec.y, Math.sqrt(combinedVec.x * combinedVec.x + combinedVec.z + combinedVec.z));
  25. double yaw = Math.atan2(-combinedVec.z, combinedVec.x);
  26.  
  27. double length = combinedVec.length();
  28.  
  29. GlStateManager.pushMatrix();
  30.  
  31. GlStateManager.disableLighting();
  32. GlStateManager.disableTexture2D();
  33. GlStateManager.enableBlend();
  34. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  35. GlStateManager.depthMask(false);
  36. GlStateManager.translate(firstX-TileEntityRendererDispatcher.staticPlayerX, firstY-TileEntityRendererDispatcher.staticPlayerY, firstZ-TileEntityRendererDispatcher.staticPlayerZ);
  37. GlStateManager.rotate((float)(180*yaw/Math.PI), 0, 1, 0);
  38. GlStateManager.rotate((float)(180*pitch/Math.PI), 0, 0, 1);
  39. GlStateManager.rotate(rot, 1, 0, 0);
  40.  
  41. render.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
  42. render.pos(length, beamWidth, beamWidth).color(r2, g2, b2, alpha).endVertex();
  43. render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex();
  44. render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex();
  45. render.pos(length, -beamWidth, beamWidth).color(r2, g2, b2, alpha).endVertex();
  46.  
  47. render.pos(length, -beamWidth, -beamWidth).color(r2, g2, b2, alpha).endVertex();
  48. render.pos(0, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex();
  49. render.pos(0, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex();
  50. render.pos(length, beamWidth, -beamWidth).color(r2, g2, b2, alpha).endVertex();
  51.  
  52. render.pos(length, beamWidth, -beamWidth).color(r2, g2, b2, alpha).endVertex();
  53. render.pos(0, beamWidth, -beamWidth).color(r, g, b, alpha).endVertex();
  54. render.pos(0, beamWidth, beamWidth).color(r, g, b, alpha).endVertex();
  55. render.pos(length, beamWidth, beamWidth).color(r2, g2, b2, alpha).endVertex();
  56.  
  57. render.pos(length, -beamWidth, beamWidth).color(r2, g2, b2, alpha).endVertex();
  58. render.pos(0, -beamWidth, beamWidth).color(r, g, b, alpha).endVertex();
  59. render.pos(0, -beamWidth, -beamWidth).color(r, g, b, alpha).endVertex();
  60. render.pos(length, -beamWidth, -beamWidth).color(r2, g2, b2, alpha).endVertex();
  61. tessy.draw();
  62.  
  63. GlStateManager.disableBlend();
  64. GlStateManager.enableLighting();
  65. GlStateManager.enableTexture2D();
  66. GlStateManager.depthMask(true);
  67. GlStateManager.popMatrix();
  68.  
  69. GlStateManager.enableFog();
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement