Guest User

Untitled

a guest
Jul 16th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 8.12 KB | None | 0 0
  1. diff --git a/src/minecraft/net/minecraft/src/FontRenderer.java b/src/minecraft/net/minecraft/src/FontRenderer.java
  2. index 70a5f3f..93033c1 100644
  3. --- a/src/minecraft/net/minecraft/src/FontRenderer.java
  4. +++ b/src/minecraft/net/minecraft/src/FontRenderer.java
  5. @@ -45,17 +45,7 @@ public class FontRenderer
  6.       */
  7.      private boolean bidiFlag;
  8.  
  9. -    /** Used to specify new red value for the current color. */
  10. -    private float red;
  11. -
  12. -    /** Used to specify new blue value for the current color. */
  13. -    private float blue;
  14. -
  15. -    /** Used to specify new green value for the current color. */
  16. -    private float green;
  17. -
  18. -    /** Used to speify new alpha value for the current color. */
  19. -    private float alpha;
  20. +    private int defaultColor;
  21.  
  22.      FontRenderer()
  23.      {
  24. @@ -180,7 +170,7 @@ public class FontRenderer
  25.      /**
  26.       * Pick how to render a single character and return the width used.
  27.       */
  28. -    private float renderCharAtPos(int par1, char par2, boolean par3)
  29. +    private float renderCharAtPos(int par1, char par2, boolean par3, int color)
  30.      {
  31.          if (par2 == ' ')
  32.          {
  33. @@ -189,18 +179,18 @@ public class FontRenderer
  34.  
  35.          if (par1 > 0 && !unicodeFlag)
  36.          {
  37. -            return renderDefaultChar(par1 + 32, par3);
  38. +            return renderDefaultChar(par1 + 32, par3, color);
  39.          }
  40.          else
  41.          {
  42. -            return renderUnicodeChar(par2, par3);
  43. +            return renderUnicodeChar(par2, par3, color);
  44.          }
  45.      }
  46.  
  47.      /**
  48.       * Render a single character with the default.png font at current (posX,posY) location...
  49.       */
  50. -    private float renderDefaultChar(int par1, boolean par2)
  51. +    private float renderDefaultChar(int par1, boolean par2, int color)
  52.      {
  53.          float f = (par1 % 16) * 8;
  54.          float f1 = (par1 / 16) * 8;
  55. @@ -213,16 +203,14 @@ public class FontRenderer
  56.          }
  57.  
  58.          float f3 = (float)charWidth[par1] - 0.01F;
  59. -        GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
  60. -        GL11.glTexCoord2f(f / 128F, f1 / 128F);
  61. -        GL11.glVertex3f(posX + f2, posY, 0.0F);
  62. -        GL11.glTexCoord2f(f / 128F, (f1 + 7.99F) / 128F);
  63. -        GL11.glVertex3f(posX - f2, posY + 7.99F, 0.0F);
  64. -        GL11.glTexCoord2f((f + f3) / 128F, f1 / 128F);
  65. -        GL11.glVertex3f(posX + f3 + f2, posY, 0.0F);
  66. -        GL11.glTexCoord2f((f + f3) / 128F, (f1 + 7.99F) / 128F);
  67. -        GL11.glVertex3f((posX + f3) - f2, posY + 7.99F, 0.0F);
  68. -        GL11.glEnd();
  69. +        Tessellator tess = Tessellator.instance;
  70. +        tess.startDrawing(GL11.GL_TRIANGLE_STRIP);
  71. +        tess.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff);
  72. +        tess.addVertexWithUV(posX + f2, posY, 0.0F, f / 128F, f1 / 128F);
  73. +        tess.addVertexWithUV(posX - f2, posY + 7.99F, 0.0F, f / 128F, (f1 + 7.99F) / 128F);
  74. +        tess.addVertexWithUV(posX + f3 + f2, posY, 0.0F, (f + f3) / 128F, f1 / 128F);
  75. +        tess.addVertexWithUV(posX + f3 - f2, posY + 7.99F, 0.0F, (f + f3) / 128F, (f1 + 7.99F) / 128F);
  76. +        tess.draw();
  77.          return (float)charWidth[par1];
  78.      }
  79.  
  80. @@ -253,7 +241,7 @@ public class FontRenderer
  81.      /**
  82.       * Render a single Unicode character at current (posX,posY) location using one of the /font/glyph_XX.png files...
  83.       */
  84. -    private float renderUnicodeChar(char par1, boolean par2)
  85. +    private float renderUnicodeChar(char par1, boolean par2, int color)
  86.      {
  87.          if (glyphWidth[par1] == 0)
  88.          {
  89. @@ -281,16 +269,14 @@ public class FontRenderer
  90.          float f3 = ((par1 & 0xff) / 16) * 16;
  91.          float f4 = f1 - f - 0.02F;
  92.          float f5 = par2 ? 1.0F : 0.0F;
  93. -        GL11.glBegin(GL11.GL_TRIANGLE_STRIP);
  94. -        GL11.glTexCoord2f(f2 / 256F, f3 / 256F);
  95. -        GL11.glVertex3f(posX + f5, posY, 0.0F);
  96. -        GL11.glTexCoord2f(f2 / 256F, (f3 + 15.98F) / 256F);
  97. -        GL11.glVertex3f(posX - f5, posY + 7.99F, 0.0F);
  98. -        GL11.glTexCoord2f((f2 + f4) / 256F, f3 / 256F);
  99. -        GL11.glVertex3f(posX + f4 / 2.0F + f5, posY, 0.0F);
  100. -        GL11.glTexCoord2f((f2 + f4) / 256F, (f3 + 15.98F) / 256F);
  101. -        GL11.glVertex3f((posX + f4 / 2.0F) - f5, posY + 7.99F, 0.0F);
  102. -        GL11.glEnd();
  103. +        Tessellator tess = Tessellator.instance;
  104. +        tess.startDrawing(GL11.GL_TRIANGLE_STRIP);
  105. +        tess.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff);
  106. +        tess.addVertexWithUV(posX + f5, posY, 0.0F, f2 / 256F, f3 / 256F);
  107. +        tess.addVertexWithUV(posX - f5, posY + 7.99F, 0.0F, f2 / 256F, (f3 + 15.98F) / 256F);
  108. +        tess.addVertexWithUV(posX + f5 + f4 / 2.0F, posY, 0.0F, (f2 + f4) / 256F, f3 / 256F);
  109. +        tess.addVertexWithUV(posX - f5 + f4 / 2.0F, posY + 7.99F, 0.0F, (f2 + f4) / 256F, (f3 + 15.98F) / 256F);
  110. +        tess.draw();
  111.          return (f1 - f) / 2.0F + 1.0F;
  112.      }
  113.  
  114. @@ -411,7 +397,7 @@ public class FontRenderer
  115.      /**
  116.       * Render a single line string at the current (posX,posY) and update posX
  117.       */
  118. -    private void renderStringAtPos(String par1Str, boolean par2)
  119. +    private void renderStringAtPos(String par1Str, int color, boolean par2)
  120.      {
  121.          boolean flag = false;
  122.          boolean flag1 = false;
  123. @@ -445,8 +431,7 @@ public class FontRenderer
  124.                          j += 16;
  125.                      }
  126.  
  127. -                    int l = colorCode[j];
  128. -                    GL11.glColor3f((float)(l >> 16) / 255F, (float)(l >> 8 & 0xff) / 255F, (float)(l & 0xff) / 255F);
  129. +                    color = colorCode[j] & 0xffffff | color & 0xff000000;
  130.                  }
  131.                  else if (j == 16)
  132.                  {
  133. @@ -475,7 +460,7 @@ public class FontRenderer
  134.                      flag4 = false;
  135.                      flag3 = false;
  136.                      flag2 = false;
  137. -                    GL11.glColor4f(red, blue, green, alpha);
  138. +                    color = defaultColor;
  139.                  }
  140.  
  141.                  i++;
  142. @@ -497,12 +482,12 @@ public class FontRenderer
  143.                  k = i1;
  144.              }
  145.  
  146. -            float f = renderCharAtPos(k, c, flag2);
  147. +            float f = renderCharAtPos(k, c, flag2, color);
  148.  
  149.              if (flag1)
  150.              {
  151.                  posX++;
  152. -                renderCharAtPos(k, c, flag2);
  153. +                renderCharAtPos(k, c, flag2, color);
  154.                  posX--;
  155.                  f++;
  156.              }
  157. @@ -512,6 +497,7 @@ public class FontRenderer
  158.                  Tessellator tessellator = Tessellator.instance;
  159.                  GL11.glDisable(GL11.GL_TEXTURE_2D);
  160.                  tessellator.startDrawingQuads();
  161. +                tessellator.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff);
  162.                  tessellator.addVertex(posX, posY + (float)(FONT_HEIGHT / 2), 0.0D);
  163.                  tessellator.addVertex(posX + f, posY + (float)(FONT_HEIGHT / 2), 0.0D);
  164.                  tessellator.addVertex(posX + f, (posY + (float)(FONT_HEIGHT / 2)) - 1.0F, 0.0D);
  165. @@ -525,6 +511,7 @@ public class FontRenderer
  166.                  Tessellator tessellator1 = Tessellator.instance;
  167.                  GL11.glDisable(GL11.GL_TEXTURE_2D);
  168.                  tessellator1.startDrawingQuads();
  169. +                tessellator1.setColorRGBA(color >> 16 & 0xff, color >> 8 & 0xff, color & 0xff, color >> 24 & 0xff);
  170.                  int j1 = flag3 ? -1 : 0;
  171.                  tessellator1.addVertex(posX + (float)j1, posY + (float)FONT_HEIGHT, 0.0D);
  172.                  tessellator1.addVertex(posX + f, posY + (float)FONT_HEIGHT, 0.0D);
  173. @@ -554,14 +541,10 @@ public class FontRenderer
  174.                  par4 = (par4 & 0xfcfcfc) >> 2 | par4 & 0xff000000;
  175.              }
  176.  
  177. -            red = (float)(par4 >> 16 & 0xff) / 255F;
  178. -            blue = (float)(par4 >> 8 & 0xff) / 255F;
  179. -            green = (float)(par4 & 0xff) / 255F;
  180. -            alpha = (float)(par4 >> 24 & 0xff) / 255F;
  181. -            GL11.glColor4f(red, blue, green, alpha);
  182. +            defaultColor = par4;
  183.              posX = par2;
  184.              posY = par3;
  185. -            renderStringAtPos(par1Str, par5);
  186. +            renderStringAtPos(par1Str, par4, par5);
  187.              return (int)posX;
  188.          }
  189.          else
Add Comment
Please, Sign In to add comment