diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-25 21:44:31 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2022-05-25 21:44:31 +0700 |
commit | a651c8b71d2b30b0da3182de48a213ca94acae54 (patch) | |
tree | 1e7598f7c403a29b6218b676d8a815d171de0be7 /src/main | |
parent | 60b9f99d260361824424b3f3c866e95f4869c262 (diff) | |
download | OneConfig-a651c8b71d2b30b0da3182de48a213ca94acae54.tar.gz OneConfig-a651c8b71d2b30b0da3182de48a213ca94acae54.tar.bz2 OneConfig-a651c8b71d2b30b0da3182de48a213ca94acae54.zip |
TextHud
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java | 27 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/test/TestHud.java | 20 |
2 files changed, 31 insertions, 16 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java new file mode 100644 index 0000000..812ba50 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/hud/TextHud.java @@ -0,0 +1,27 @@ +package cc.polyfrost.oneconfig.hud; + +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.lwjgl.RenderManager; + +public abstract class TextHud extends BasicHud { + public TextHud(boolean enabled, int x, int y) { + super(enabled, x, y); + } + + @Override + public int getWidth(float scale) { + return (int) (UMinecraft.getFontRenderer().getStringWidth(getText()) * scale); + } + + @Override + public int getHeight(float scale) { + return (int) (9 * scale); + } + + @Override + public void draw(int x, int y, float scale) { + RenderManager.drawScaledString(getText(), x, y, 0xffffff, false, scale); + } + + public abstract String getText(); +} diff --git a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java index 7f1fb7f..d11340c 100644 --- a/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java +++ b/src/main/java/cc/polyfrost/oneconfig/test/TestHud.java @@ -1,27 +1,15 @@ package cc.polyfrost.oneconfig.test; -import cc.polyfrost.oneconfig.hud.BasicHud; -import cc.polyfrost.oneconfig.lwjgl.RenderManager; -import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import cc.polyfrost.oneconfig.hud.TextHud; import net.minecraft.client.Minecraft; -public class TestHud extends BasicHud { +public class TestHud extends TextHud { public TestHud(boolean enabled, int x, int y) { super(enabled, x, y); } @Override - public int getWidth(float scale) { - return (int) (UMinecraft.getFontRenderer().getStringWidth("FPS: " + Minecraft.getDebugFPS()) * scale); - } - - @Override - public int getHeight(float scale) { - return (int) (9 * scale); - } - - @Override - public void draw(int x, int y, float scale) { - RenderManager.drawScaledString("FPS: " + Minecraft.getDebugFPS(), x, y, 0xffffff, false, scale); + public String getText() { + return "FPS: " + Minecraft.getDebugFPS(); } } |