Advertisement
Guest User

Untitled

a guest
Dec 31st, 2015
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. /**
  2. * Renders a sprite from the spritesheet with depth, like a "builtin/generated" item model.
  3. * Adapted from ItemRenderer.renderItemIn2D, 1.7.10
  4. */
  5. public static void renderIconIn3D(Tessellator tess, float p_78439_1_, float p_78439_2_, float p_78439_3_, float p_78439_4_, int width, int height, float thickness) {
  6. WorldRenderer wr = tess.getWorldRenderer();
  7. wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
  8. wr.pos(0.0D, 0.0D, 0.0D).tex(p_78439_1_, p_78439_4_).normal(0, 0, 1).endVertex();
  9. wr.pos(1.0D, 0.0D, 0.0D).tex(p_78439_3_, p_78439_4_).normal(0, 0, 1).endVertex();
  10. wr.pos(1.0D, 1.0D, 0.0D).tex(p_78439_3_, p_78439_2_).normal(0, 0, 1).endVertex();
  11. wr.pos(0.0D, 1.0D, 0.0D).tex(p_78439_1_, p_78439_2_).normal(0, 0, 1).endVertex();
  12. tess.draw();
  13. wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
  14. wr.pos(0.0D, 1.0D, (0.0F - thickness)).tex(p_78439_1_, p_78439_2_).normal(0, 0, -1).endVertex();
  15. wr.pos(1.0D, 1.0D, (0.0F - thickness)).tex(p_78439_3_, p_78439_2_).normal(0, 0, -1).endVertex();
  16. wr.pos(1.0D, 0.0D, (0.0F - thickness)).tex(p_78439_3_, p_78439_4_).normal(0, 0, -1).endVertex();
  17. wr.pos(0.0D, 0.0D, (0.0F - thickness)).tex(p_78439_1_, p_78439_4_).normal(0, 0, -1).endVertex();
  18. tess.draw();
  19. float f5 = 0.5F * (p_78439_1_ - p_78439_3_) / (float)width;
  20. float f6 = 0.5F * (p_78439_4_ - p_78439_2_) / (float)height;
  21. wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
  22. int k;
  23. float f7;
  24. float f8;
  25.  
  26. for (k = 0; k < width; ++k)
  27. {
  28. f7 = (float)k / (float)width;
  29. f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
  30. wr.pos(f7, 0.0D, (0.0F - thickness)).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex();
  31. wr.pos(f7, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(-1, 0, 0).endVertex();
  32. wr.pos(f7, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex();
  33. wr.pos(f7, 1.0D, (0.0F - thickness)).tex(f8, p_78439_2_).normal(-1, 0, 0).endVertex();
  34. }
  35.  
  36. tess.draw();
  37. wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
  38. float f9;
  39.  
  40. for (k = 0; k < width; ++k)
  41. {
  42. f7 = (float)k / (float)width;
  43. f8 = p_78439_1_ + (p_78439_3_ - p_78439_1_) * f7 - f5;
  44. f9 = f7 + 1.0F / (float)width;
  45. wr.pos(f9, 1.0D, (0.0F - thickness)).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex();
  46. wr.pos(f9, 1.0D, 0.0D).tex(f8, p_78439_2_).normal(1, 0, 0).endVertex();
  47. wr.pos(f9, 0.0D, 0.0D).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex();
  48. wr.pos(f9, 0.0D, (0.0F - thickness)).tex(f8, p_78439_4_).normal(1, 0, 0).endVertex();
  49. }
  50.  
  51. tess.draw();
  52. wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
  53.  
  54. for (k = 0; k < height; ++k)
  55. {
  56. f7 = (float)k / (float)height;
  57. f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
  58. f9 = f7 + 1.0F / (float)height;
  59. wr.pos(0.0D, f9, 0.0D).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex();
  60. wr.pos(1.0D, f9, 0.0D).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex();
  61. wr.pos(1.0D, f9, (0.0F - thickness)).tex(p_78439_3_, f8).normal(0, 1, 0).endVertex();
  62. wr.pos(0.0D, f9, (0.0F - thickness)).tex(p_78439_1_, f8).normal(0, 1, 0).endVertex();
  63. }
  64.  
  65. tess.draw();
  66. wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_NORMAL);
  67.  
  68. for (k = 0; k < height; ++k)
  69. {
  70. f7 = (float)k / (float)height;
  71. f8 = p_78439_4_ + (p_78439_2_ - p_78439_4_) * f7 - f6;
  72. wr.pos(1.0D, f7, 0.0D).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex();
  73. wr.pos(0.0D, f7, 0.0D).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex();
  74. wr.pos(0.0D, f7, (0.0F - thickness)).tex(p_78439_1_, f8).normal(0, -1, 0).endVertex();
  75. wr.pos(1.0D, f7, (0.0F - thickness)).tex(p_78439_3_, f8).normal(0, -1, 0).endVertex();
  76. }
  77.  
  78. tess.draw();
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement