diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-04 19:50:46 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-04 19:50:46 +0900 |
commit | 2b00bcf328cff74f1f5b19dfb98a2521694801ce (patch) | |
tree | 5512f79402cd6576a634bd43985f3207b1219c71 /mod/src/main/java/kr/syeyoung | |
parent | 8a74c1813b718aa6d8b1f4991c7838a555115d33 (diff) | |
download | Skyblock-Dungeons-Guide-2b00bcf328cff74f1f5b19dfb98a2521694801ce.tar.gz Skyblock-Dungeons-Guide-2b00bcf328cff74f1f5b19dfb98a2521694801ce.tar.bz2 Skyblock-Dungeons-Guide-2b00bcf328cff74f1f5b19dfb98a2521694801ce.zip |
- Fix operator precedence breaking unicode char rendering (and width calc)
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main/java/kr/syeyoung')
2 files changed, 6 insertions, 3 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java index f3310ff3..c48b9046 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/features/impl/dungeon/FeatureWarnLowHealth.java @@ -34,6 +34,7 @@ import kr.syeyoung.dungeonsguide.mod.utils.TextUtils; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; @@ -80,7 +81,7 @@ public class FeatureWarnLowHealth extends TextHUDFeature { String lowestHealthName = ""; int lowestHealth = 999999999; Objective objective = ScoreboardManager.INSTANCE.getSidebarObjective(); - + if (objective == null) return Collections.emptyList(); for (Score sc : objective.getScores()) { String line = sc.getVisibleName(); String stripped = TextUtils.keepScoreboardCharacters(TextUtils.stripColor(line)); diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/fonts/DefaultFontRenderer.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/fonts/DefaultFontRenderer.java index 85553740..935bf647 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/fonts/DefaultFontRenderer.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/richtext/fonts/DefaultFontRenderer.java @@ -129,6 +129,7 @@ public class DefaultFontRenderer implements FontRenderer { @Override public double getWidth(char text, ITextStyle textStyle) { double val; + if (text == '\n') return 0; if (text == ' ') { val = 4; } else { @@ -137,7 +138,7 @@ public class DefaultFontRenderer implements FontRenderer { val = this.charWidth[i]; } else if (this.glyphData[text] != 0) { int texStart = this.glyphData[text] >>> 4; - int texEnd = this.glyphData[text] & 15 + 1; + int texEnd = (this.glyphData[text] & 15) + 1; val = (texEnd - texStart) / 2.0 + 1; } else { val = 0; @@ -217,6 +218,7 @@ public class DefaultFontRenderer implements FontRenderer { private double renderChar(WorldRenderer worldRenderer, double x, double y, char ch, ITextStyle textStyle) { + if (ch == '\n') return 0; if (ch == ' ') { return 4.0F * textStyle.getSize() / 8.0; } else { @@ -286,7 +288,7 @@ public class DefaultFontRenderer implements FontRenderer { int i = ch / 256; bindTexture(worldRenderer, this.getUnicodePageLocation(i)); float xStart = (float)(this.glyphData[ch] >>> 4); - float xEnd = (float)(this.glyphData[ch] & 15 + 1); + float xEnd = (float)((this.glyphData[ch] & 15) + 1); float texX = (float)(ch % 16 * 16) + xStart; float texY = (float)((ch & 255) / 16 * 16); |