From bc4cad3df145195eb731d0f346add5c28e64c57a Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 6 Sep 2023 22:47:11 +0600 Subject: [PATCH 1/3] Zoom Fix? --- .../silentclient/client/mixin/mixins/GameSettingsMixin.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java index 6a7c950..e2cdb9e 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java @@ -52,6 +52,9 @@ public class GameSettingsMixin implements GameSettingsExt { */ @Overwrite public static boolean isKeyDown(KeyBinding key) { + if(key.getKeyDescription().equalsIgnoreCase("of.key.zoom") && Client.getInstance().getModInstances().getZoomMod().isActive()) { + return false; + } int keyCode = key.getKeyCode(); if (keyCode != 0 && keyCode < 256) { return keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode); From 4a903509a874ed46fa1ffa840bcae7edb215abb9 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 6 Sep 2023 22:56:58 +0600 Subject: [PATCH 2/3] Update GameSettingsMixin.java --- .../silentclient/client/mixin/mixins/GameSettingsMixin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java index e2cdb9e..7a81c6b 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/GameSettingsMixin.java @@ -7,6 +7,7 @@ import net.minecraft.client.settings.KeyBinding; import net.silentclient.client.Client; import net.silentclient.client.keybinds.KeyBindManager; import net.silentclient.client.mixin.ducks.GameSettingsExt; +import net.silentclient.client.mods.player.ZoomMod; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.spongepowered.asm.mixin.Mixin; @@ -52,7 +53,7 @@ public class GameSettingsMixin implements GameSettingsExt { */ @Overwrite public static boolean isKeyDown(KeyBinding key) { - if(key.getKeyDescription().equalsIgnoreCase("of.key.zoom") && Client.getInstance().getModInstances().getZoomMod().isActive()) { + if(Client.getInstance().getModInstances().getZoomMod().isEnabled() && key.getKeyDescription().equalsIgnoreCase("of.key.zoom") && key.getKeyCode() == Client.getInstance().getSettingsManager().getSettingByClass(ZoomMod.class, "Keybind").getKeybind()) { return false; } int keyCode = key.getKeyCode(); From 2d936e53f28ce34cba612c71831bb99b34d17bfe Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 6 Sep 2023 23:08:33 +0600 Subject: [PATCH 3/3] Text Width Fix --- .../client/gui/font/SilentFontRenderer.java | 12 ++++++------ .../client/gui/modmenu/RegularSlider.java | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/silentclient/client/gui/font/SilentFontRenderer.java b/src/main/java/net/silentclient/client/gui/font/SilentFontRenderer.java index 25793d6..2f35c8d 100644 --- a/src/main/java/net/silentclient/client/gui/font/SilentFontRenderer.java +++ b/src/main/java/net/silentclient/client/gui/font/SilentFontRenderer.java @@ -1,10 +1,6 @@ package net.silentclient.client.gui.font; import com.google.gson.reflect.TypeToken; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.Map; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; @@ -12,10 +8,14 @@ import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; - import org.apache.commons.io.Charsets; import org.lwjgl.opengl.GL11; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.Map; + public class SilentFontRenderer { private static final ResourceLocation silentFontHeader = new ResourceLocation("silentclient/fonts/silent-font-0.png"); private static final ResourceLocation silentFontTitle = new ResourceLocation("silentclient/fonts/silent-font-1.png"); @@ -302,7 +302,7 @@ public class SilentFontRenderer { this.renderString(x, y, string, 128 / fontHeight, fontType, true); } - public void drawString(String string, int x, int y, int fontHeight, FontType fontType, int maxWidth) + public void drawString(String string, float x, float y, int fontHeight, FontType fontType, int maxWidth) { this.getClass(); if(this.getStringWidth(string, fontHeight, fontType) > maxWidth) { diff --git a/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java b/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java index 9bddea2..60f61e9 100644 --- a/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java +++ b/src/main/java/net/silentclient/client/gui/modmenu/RegularSlider.java @@ -11,14 +11,15 @@ import java.text.DecimalFormat; public class RegularSlider { public static void render(float x, float y, int width, String name, double max, double value) { - Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE); + int valueWidth = Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE); + Client.getInstance().getSilentFontRenderer().drawString(name, x, y, 12, SilentFontRenderer.FontType.TITLE, 142 - valueWidth); RenderUtil.drawRoundedRect(x, y + 15, width, 9, 3, Color.black.getRGB()); if(value != 0) { RenderUtil.drawRoundedRect(x, y + 15, width * (float) (value / max), 9, 3, -1); } - float textLeft = x + width - Client.getInstance().getSilentFontRenderer().getStringWidth(new DecimalFormat("0.00").format(value), 12, SilentFontRenderer.FontType.TITLE); + float textLeft = x + width - valueWidth; Client.getInstance().getSilentFontRenderer().drawString(new DecimalFormat("0.00").format(value), textLeft, y, 12, SilentFontRenderer.FontType.TITLE); }