Keystrokes CPS Mode

This commit is contained in:
kirillsaint 2023-10-25 12:37:18 +06:00
parent c5eba78bf6
commit 316e46f697
3 changed files with 128 additions and 16 deletions

View File

@ -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");
}

View File

@ -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<String> 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 {
boolean needResize = textWidth + 4 >= key.getWidth();
if(!needResize) {
font.drawString(
key.getName(),
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);

View File

@ -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 <br>
* (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 <br>
* (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();
}
}