Files
CatServer/patches/net/minecraft/client/gui/FontRenderer.java.patch
2019-02-24 22:29:41 +08:00

153 lines
5.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/client/gui/FontRenderer.java
+++ ../src-work/minecraft/net/minecraft/client/gui/FontRenderer.java
@@ -57,7 +57,7 @@
this.locationFontTexture = location;
this.renderEngine = textureManagerIn;
this.unicodeFlag = unicode;
- textureManagerIn.bindTexture(this.locationFontTexture);
+ bindTexture(this.locationFontTexture);
for (int i = 0; i < 32; ++i)
{
@@ -107,7 +107,7 @@
try
{
- iresource = Minecraft.getMinecraft().getResourceManager().getResource(this.locationFontTexture);
+ iresource = getResource(this.locationFontTexture);
bufferedimage = TextureUtil.readBufferedImage(iresource.getInputStream());
}
catch (IOException ioexception)
@@ -172,7 +172,7 @@
try
{
- iresource = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("font/glyph_sizes.bin"));
+ iresource = getResource(new ResourceLocation("font/glyph_sizes.bin"));
iresource.getInputStream().read(this.glyphWidth);
}
catch (IOException ioexception)
@@ -187,6 +187,7 @@
private float renderChar(char ch, boolean italic)
{
+ if (ch == 160) return 4.0F; // forge: display nbsp as space. MC-2595
if (ch == ' ')
{
return 4.0F;
@@ -203,7 +204,7 @@
int i = ch % 16 * 8;
int j = ch / 16 * 8;
int k = italic ? 1 : 0;
- this.renderEngine.bindTexture(this.locationFontTexture);
+ bindTexture(this.locationFontTexture);
int l = this.charWidth[ch];
float f = (float)l - 0.01F;
GlStateManager.glBegin(5);
@@ -231,7 +232,7 @@
private void loadGlyphTexture(int page)
{
- this.renderEngine.bindTexture(this.getUnicodePageLocation(page));
+ bindTexture(this.getUnicodePageLocation(page));
}
protected float renderUnicodeChar(char ch, boolean italic)
@@ -280,7 +281,7 @@
public int drawString(String text, float x, float y, int color, boolean dropShadow)
{
- GlStateManager.enableAlpha();
+ enableAlpha();
this.resetStyles();
int i;
@@ -350,7 +351,7 @@
int j1 = this.colorCode[i1];
this.textColor = j1;
- GlStateManager.color((float)(j1 >> 16) / 255.0F, (float)(j1 >> 8 & 255) / 255.0F, (float)(j1 & 255) / 255.0F, this.alpha);
+ setColor((float)(j1 >> 16) / 255.0F, (float)(j1 >> 8 & 255) / 255.0F, (float)(j1 & 255) / 255.0F, this.alpha);
}
else if (i1 == 16)
{
@@ -379,7 +380,7 @@
this.strikethroughStyle = false;
this.underlineStyle = false;
this.italicStyle = false;
- GlStateManager.color(this.red, this.blue, this.green, this.alpha);
+ setColor(this.red, this.blue, this.green, this.alpha);
}
++i;
@@ -407,7 +408,7 @@
c0 = c1;
}
- float f1 = this.unicodeFlag ? 0.5F : 1.0F;
+ float f1 = j == -1 || this.unicodeFlag ? 0.5f : 1f;
boolean flag = (c0 == 0 || j == -1 || this.unicodeFlag) && shadow;
if (flag)
@@ -445,7 +446,16 @@
++f;
}
+ doDraw(f);
+ }
+ }
+ }
+ protected void doDraw(float f)
+ {
+ {
+ {
+
if (this.strikethroughStyle)
{
Tessellator tessellator = Tessellator.getInstance();
@@ -518,7 +528,7 @@
this.blue = (float)(color >> 8 & 255) / 255.0F;
this.green = (float)(color & 255) / 255.0F;
this.alpha = (float)(color >> 24 & 255) / 255.0F;
- GlStateManager.color(this.red, this.blue, this.green, this.alpha);
+ setColor(this.red, this.blue, this.green, this.alpha);
this.posX = x;
this.posY = y;
this.renderStringAtPos(text, dropShadow);
@@ -576,6 +586,7 @@
public int getCharWidth(char character)
{
+ if (character == 160) return 4; // forge: display nbsp as space. MC-2595
if (character == 167)
{
return -1;
@@ -849,6 +860,26 @@
return this.bidiFlag;
}
+ protected void setColor(float r, float g, float b, float a)
+ {
+ GlStateManager.color(r,g,b,a);
+ }
+
+ protected void enableAlpha()
+ {
+ GlStateManager.enableAlpha();
+ }
+
+ protected void bindTexture(ResourceLocation location)
+ {
+ renderEngine.bindTexture(location);
+ }
+
+ protected IResource getResource(ResourceLocation location) throws IOException
+ {
+ return Minecraft.getMinecraft().getResourceManager().getResource(location);
+ }
+
public int getColorCode(char character)
{
int i = "0123456789abcdef".indexOf(character);