From b9992115828028d8341a15669589a217d2242e23 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 25 Oct 2023 11:26:45 +0600 Subject: [PATCH 1/4] Better Scroll in Multiplayer GUI --- .../client/gui/multiplayer/SilentMultiplayerGui.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java b/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java index 1c01220..71f59a9 100644 --- a/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java +++ b/src/main/java/net/silentclient/client/gui/multiplayer/SilentMultiplayerGui.java @@ -359,7 +359,7 @@ public class SilentMultiplayerGui extends SilentScreen { newScrollY += amountScrolled; else newScrollY = 0; - if((newScrollY < blockHeight && ((servers.size() + 1) * 38) > blockHeight - 39) || amountScrolled < 0) { + if((newScrollY < blockHeight && ((servers.size() + 1) * 38) > blockHeight - 43 - 41) || amountScrolled < 0) { this.scrollY = (float) newScrollY; if(this.scrollY < 0) { this.scrollY = 0; From c5eba78bf636efec43ff0e84effb2441cbb23fb9 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 25 Oct 2023 11:30:36 +0600 Subject: [PATCH 2/4] Better Image Positions --- .../client/gui/util/RenderUtil.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/silentclient/client/gui/util/RenderUtil.java b/src/main/java/net/silentclient/client/gui/util/RenderUtil.java index 2b2f68d..3606e0c 100644 --- a/src/main/java/net/silentclient/client/gui/util/RenderUtil.java +++ b/src/main/java/net/silentclient/client/gui/util/RenderUtil.java @@ -5,6 +5,9 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.util.ResourceLocation; import net.silentclient.client.Client; import net.silentclient.client.cosmetics.StaticResourceLocation; @@ -185,7 +188,7 @@ public class RenderUtil { } else { Minecraft.getMinecraft().getTextureManager().bindTexture(image); } - Gui.drawModalRectWithCustomSizedTexture((int) x, (int) y, (float) 0.0f, (float) 0.0f, (int) width, (int) height, (float) width, (float) height); + drawModalRectWithCustomSizedTexture(x, y, 0.0f, 0.0f, width, height, width, height); GL11.glDepthMask((boolean) true); GL11.glDisable((int) 3042); GL11.glEnable((int) 2929); @@ -194,6 +197,20 @@ public class RenderUtil { GL11.glColor4f((float) 1.0f, (float) 1.0f, (float) 1.0f, 1f); } + public static void drawModalRectWithCustomSizedTexture(float x, float y, float u, float v, float width, float height, float textureWidth, float textureHeight) + { + float f = 1.0F / textureWidth; + float f1 = 1.0F / textureHeight; + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); + worldrenderer.pos((double)x, (double)(y + height), 0.0D).tex((double)(u * f), (double)((v + (float)height) * f1)).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)((u + (float)width) * f), (double)((v + (float)height) * f1)).endVertex(); + worldrenderer.pos((double)(x + width), (double)y, 0.0D).tex((double)((u + (float)width) * f), (double)(v * f1)).endVertex(); + worldrenderer.pos((double)x, (double)y, 0.0D).tex((double)(u * f), (double)(v * f1)).endVertex(); + tessellator.draw(); + } + public static void drawImage(ResourceLocation image, float x, float y, float width, float height, boolean mip) { drawImage(image, x, y, width, height, mip, -1); } From 316e46f69796b4e096128a1ad9beea7dcbd86d6f Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 25 Oct 2023 12:37:18 +0600 Subject: [PATCH 3/4] Keystrokes CPS Mode --- .../java/net/silentclient/client/Client.java | 3 + .../client/mods/hud/KeystrokesMod.java | 63 +++++++++++---- .../silentclient/client/utils/TextUtils.java | 78 +++++++++++++++++++ 3 files changed, 128 insertions(+), 16 deletions(-) create mode 100644 src/main/java/net/silentclient/client/utils/TextUtils.java diff --git a/src/main/java/net/silentclient/client/Client.java b/src/main/java/net/silentclient/client/Client.java index b9677b2..4faaf3e 100644 --- a/src/main/java/net/silentclient/client/Client.java +++ b/src/main/java/net/silentclient/client/Client.java @@ -93,6 +93,7 @@ public class Client { private File globalSettingsFile; private AccountManager accountManager; public ServerData lastServerData; + public TextUtils textUtils; public static void memoryDebug(String paramString) { LogManager.getLogger().info("-- Start Memory Debug -- " + paramString); @@ -340,6 +341,8 @@ public class Client { logger.info("STARTING > ERROR: " + err.getMessage()); throw err; } + Client.logger.info("STARTING > text-utils"); + this.textUtils = new TextUtils(Minecraft.getMinecraft().fontRendererObj); logger.info("-------------------------------------------------"); memoryDebug("CLIENT_POST_INIT"); } diff --git a/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java b/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java index 45fa065..800a208 100644 --- a/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java @@ -1,23 +1,24 @@ package net.silentclient.client.mods.hud; -import java.awt.Color; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.settings.KeyBinding; import net.minecraft.util.EnumChatFormatting; import net.silentclient.client.Client; import net.silentclient.client.gui.animation.SimpleAnimation; +import net.silentclient.client.gui.font.SilentFontRenderer; +import net.silentclient.client.gui.hud.ScreenPosition; import net.silentclient.client.gui.lite.clickgui.utils.GlUtils; import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils; -import net.silentclient.client.gui.hud.ScreenPosition; import net.silentclient.client.mods.CustomFontRenderer; import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.ModDraggable; import net.silentclient.client.utils.ColorUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import java.awt.*; +import java.util.ArrayList; public class KeystrokesMod extends ModDraggable { @@ -28,16 +29,20 @@ public class KeystrokesMod extends ModDraggable { @Override public void setup() { super.setup(); + ArrayList cpsModes = new ArrayList<>(); + cpsModes.add("None"); + cpsModes.add("Small"); + cpsModes.add("Large"); this.addBooleanSetting("Font Shadow", this, true); this.addBooleanSetting("Fancy Font", this, false); this.addBooleanSetting("Background", this, true); + this.addModeSetting("CPS Mode", this, "Small", cpsModes); this.addColorSetting("Color", this, new Color(255, 255, 255)); this.addColorSetting("Background Color", this, new Color(0, 0, 0), 127); this.addColorSetting("Clicked Color", this, new Color(0, 0, 0)); this.addColorSetting("Clicked Background Color", this, new Color(255, 255, 255), 127); this.addSliderSetting("Fade Delay", this, 100, 0, 1000, true); this.addBooleanSetting("Show LMB/RMB", this, true); - this.addBooleanSetting("Show CPS", this, true); this.addBooleanSetting("Show Space", this, true); this.addBooleanSetting("Replace Names With Arrow", this, false); } @@ -166,14 +171,26 @@ public class KeystrokesMod extends ModDraggable { boolean background = Client.getInstance().getSettingsManager().getSettingByName(this, "background").getValBoolean(); Color backgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Background Color").getValColor(); Color clickedBackgroundColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Clicked Background Color").getValColor(); - boolean cps = Client.getInstance().getSettingsManager().getSettingByName(this, "Show CPS").getValBoolean(); + boolean smallCps = Client.getInstance().getSettingsManager().getSettingByName(this, "CPS Mode").getValString().equalsIgnoreCase("small"); + boolean largeCps = Client.getInstance().getSettingsManager().getSettingByName(this, "CPS Mode").getValString().equalsIgnoreCase("large"); boolean space = Client.getInstance().getSettingsManager().getSettingByName(this, "Show Space").getValBoolean(); Color color = Client.getInstance().getSettingsManager().getSettingByName(this, "Color").getValColor(); Color clickedColor = Client.getInstance().getSettingsManager().getSettingByName(this, "Clicked Color").getValColor(); int fadeDelay = Client.getInstance().getSettingsManager().getSettingByName(this, "Fade Delay").getValInt() != 0 ? 100000 / Client.getInstance().getSettingsManager().getSettingByName(this, "Fade Delay").getValInt() : 0; for(Key key : mode.getKeys()) { - int textWidth = font.getStringWidth(key.getName()); + String renderString = key.getName(); + + if(largeCps) { + if (key == Key.LMB && Client.getInstance().getCPSTracker().getLCPS() != 0) { + renderString = Client.getInstance().getCPSTracker().getLCPS() + " CPS"; + } + if (key == Key.RMB && Client.getInstance().getCPSTracker().getRCPS() != 0) { + renderString = "" + Client.getInstance().getCPSTracker().getRCPS() + " CPS"; + } + } + + int textWidth = font.getStringWidth(renderString); if(background) { setAnimation(key.red, key.isDown() ? clickedBackgroundColor.getRed() : backgroundColor.getRed(), fadeDelay); @@ -190,7 +207,7 @@ public class KeystrokesMod extends ModDraggable { ColorUtils.setColor(-1); } - if((key == Key.LMB || key == Key.RMB) && cps) { + if((key == Key.LMB || key == Key.RMB) && smallCps) { font.drawString( key.getName(), 0 + key.getX() + key.getWidth() / 2 - textWidth / 2 - (fancyFont && key == Key.LMB ? 1 : 0), @@ -237,13 +254,27 @@ public class KeystrokesMod extends ModDraggable { shadow ); } else { - font.drawString( - key.getName(), - 0 + key.getX() + key.getWidth() / 2 - textWidth / 2, - 0 + key.getY() + key.getHeight() / 2 - 4, - key.isDown() ? clickedColor.getRGB() : color.getRGB(), - shadow + boolean needResize = textWidth + 4 >= key.getWidth(); + if(!needResize) { + font.drawString( + renderString, + 0 + key.getX() + key.getWidth() / 2 - textWidth / 2, + 0 + key.getY() + key.getHeight() / 2 - 4, + key.isDown() ? clickedColor.getRGB() : color.getRGB(), + shadow ); + } else { + if(fancyFont) { + textWidth = font.getStringWidth(renderString, 11, SilentFontRenderer.FontType.TITLE); + font.drawString(renderString, + 0 + key.getX() + key.getWidth() / 2 - textWidth / 2, + 0 + key.getY() + key.getHeight() / 2 - 7, 11, SilentFontRenderer.FontType.TITLE, + key.isDown() ? clickedColor.getRGB() : color.getRGB(), + shadow); + } else { + Client.getInstance().textUtils.drawScaledString(renderString, 0 + key.getX() + key.getWidth() / 2 - textWidth / 2 + 3 + (key == Key.RMB ? 8 : 0) + (renderString.length() >= 6 ? -0.5F : 0), 0 + key.getY() + key.getHeight() / 2 + 8, key.isDown() ? clickedColor.getRGB() : color.getRGB(), 0.8F, shadow); + } + } } if(key.isDown() && clickedColor.getRGB() == -16777216) { font.drawString("", 0, 0, -1, shadow); diff --git a/src/main/java/net/silentclient/client/utils/TextUtils.java b/src/main/java/net/silentclient/client/utils/TextUtils.java new file mode 100644 index 0000000..45c316b --- /dev/null +++ b/src/main/java/net/silentclient/client/utils/TextUtils.java @@ -0,0 +1,78 @@ +package net.silentclient.client.utils; + + +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.gui.*; + +/** + * TextUtils for drawing scaled string + * + * + * I would like to get credited :) + * @author wcaleniekubaa#4196 + * If there is any problem write to me :) + * or to the Eric Golde discord server + * you can also create issue on github + * + * @see FontRenderer#drawString(String, float, float, int, boolean) + * You can also set the methods static lol + * + */ +public class TextUtils { + private final FontRenderer font; + + public TextUtils(FontRenderer font){ + this.font = font; + } + + /** + * Creates Scaled String + */ + public void drawScaledString(String text, float x,float y, int color, float scale, boolean shadow){ + GlStateManager.pushMatrix(); + GlStateManager.scale(scale,scale,scale); + font.drawString(text,x,y,color,shadow); + GlStateManager.popMatrix(); + } + /** + * Creates Centered Scaled String + */ + public void drawCenteredScaledString(String text, int x,int y, int color, float scale){ + this.drawCenteredScaledString(text, x, y, color, scale, false); + } + + public void drawCenteredScaledString(String text, int x,int y, int color, float scale, boolean shadow){ + GlStateManager.pushMatrix(); + GlStateManager.scale(scale,scale,scale); + /* make draw centered string static after it you can delete this comment*/ + this.drawCenteredString(text, (int) (x / scale), (int) (y / scale), color, shadow); + GlStateManager.popMatrix(); + } + + public void drawCenteredString(String text, int x, int y, int color, boolean shadow) + { + font.drawString(text, (float)(x - font.getStringWidth(text) / 2), (float)y, color, shadow); + } + + /** + * Creates Scaled String
+ * (you can desort it) + */ + public void drawScaledString(String text, int x,int y, int color, float scaleX, float scaleY, boolean shadow){ + GlStateManager.pushMatrix(); + GlStateManager.scale(scaleX,scaleY,scaleY); /* Text isn't 3d */ + font.drawString(text,x,y,color,shadow); + GlStateManager.popMatrix(); + } + /** + * Creates Centered Scaled String
+ * (you can disort it) :) + */ + public void drawCenteredScaledString(String text, int x,int y, int color, float scaleX, float scaleY){ + GlStateManager.pushMatrix(); + GlStateManager.scale(scaleX,scaleY,scaleY); /* Text isn't 3d */ + /* make draw centered string static after it you can delete this comment*/ + this.drawCenteredString(text, (int) (x / scaleX), (int) (y / scaleY), -1, false); + GlStateManager.popMatrix(); + } +} \ No newline at end of file From 21108dd843328bab4193a889999bc3a3a8aedaa7 Mon Sep 17 00:00:00 2001 From: kirillsaint Date: Wed, 25 Oct 2023 19:36:21 +0600 Subject: [PATCH 4/4] Set Updated true --- .../java/net/silentclient/client/mods/hud/KeystrokesMod.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java b/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java index 800a208..2f44c7c 100644 --- a/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java +++ b/src/main/java/net/silentclient/client/mods/hud/KeystrokesMod.java @@ -29,6 +29,7 @@ public class KeystrokesMod extends ModDraggable { @Override public void setup() { super.setup(); + setUpdated(true); ArrayList cpsModes = new ArrayList<>(); cpsModes.add("None"); cpsModes.add("Small");