This commit is contained in:
kirillsaint 2023-08-21 18:27:16 +06:00
parent c9abb0273e
commit a88c8a027a
11 changed files with 152 additions and 29 deletions

View File

@ -26,6 +26,7 @@ import net.silentclient.client.mixin.accessors.MinecraftAccessor;
import net.silentclient.client.mods.ModInstances;
import net.silentclient.client.mods.SettingsManager;
import net.silentclient.client.mods.settings.FPSBoostMod;
import net.silentclient.client.mods.settings.GeneralMod;
import net.silentclient.client.mods.util.PingSource;
import net.silentclient.client.mods.util.Utils;
import net.silentclient.client.premium.PremiumCosmeticsGui;
@ -443,7 +444,7 @@ public class Client {
banerror = true;
}
}
if(keyBindManager.CLICKGUI.isPressed()) {
if(Client.getInstance().getSettingsManager().getSettingByClass(GeneralMod.class, "Mod Menu Keybind").isKeyDown()) {
Minecraft.getMinecraft().displayGuiScreen(Client.getInstance().getGlobalSettings().isLite() ? new ClickGUI() : new ModMenu());
}

View File

@ -1,16 +1,5 @@
package net.silentclient.client.config;
import java.awt.Color;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import net.minecraft.client.Minecraft;
import net.silentclient.client.Client;
import net.silentclient.client.gui.hud.ScreenPosition;
@ -21,6 +10,12 @@ import net.silentclient.client.mods.Setting;
import net.silentclient.client.mods.player.AutoTextMod.AutoTextCommand;
import net.silentclient.client.utils.MenuBlurUtils;
import java.awt.*;
import java.io.*;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public final class ConfigManager {
public File configFile;
@ -175,6 +170,13 @@ public final class ConfigManager {
}
}
if(set.isKeybind()) {
try {
set.setKeybind(Integer.parseInt(args[3]));
} catch (Exception err) {
}
}
if (set.isCombo()) {
try {
if(set.getOptions().contains(args[3])) {
@ -259,6 +261,9 @@ public final class ConfigManager {
if(set.isInput()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getValString());
}
if(set.isKeybind()) {
writer.println("SET:" + set.getName() + ":" + set.getParentMod().getName() + ":" + set.getKeybind());
}
}
for(AutoTextCommand command : Client.getInstance().getModInstances().getAutoText().getCommands()) {

View File

@ -66,6 +66,10 @@ public class Input {
}
public void render(int mouseX, int mouseY, float x, float y, int width, boolean small, IInputTheme theme) {
this.render(mouseX, mouseY, x, y, width, small, theme, false);
}
public void render(int mouseX, int mouseY, float x, float y, int width, boolean small, IInputTheme theme, boolean center) {
int borderColor = theme.getBorderColor().getRGB();
if(MouseUtils.isInside(mouseX, mouseY, x, y, width, 20)) {
borderColor = theme.getHoveredBorderColor().getRGB();
@ -95,7 +99,11 @@ public class Input {
ColorUtils.setColor(theme.getFocusedBorderColor().getRGB());
}
}
Client.getInstance().getSilentFontRenderer().drawString(EnumChatFormatting.getTextWithoutFormattingCodes(renderText), x + 2, y + (small ? 1 : 3), small ? 12 : 14, SilentFontRenderer.FontType.TITLE);
float textX = x + 2;
if(center) {
textX = x + (width / 2) - (Client.getInstance().getSilentFontRenderer().getStringWidth(renderText, small ? 12 : 14, SilentFontRenderer.FontType.TITLE) / 2);
}
Client.getInstance().getSilentFontRenderer().drawString(EnumChatFormatting.getTextWithoutFormattingCodes(renderText), textX, y + (small ? 1 : 3), small ? 12 : 14, SilentFontRenderer.FontType.TITLE);
}
public boolean isHovered() {

View File

@ -17,6 +17,7 @@ import net.silentclient.client.gui.elements.*;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.hud.HUDConfigScreen;
import net.silentclient.client.gui.theme.Theme;
import net.silentclient.client.gui.theme.input.DefaultInputTheme;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
@ -63,6 +64,10 @@ public class ModSettings extends SilentScreen {
if(setting.isInput()) {
this.silentInputs.add(new Input(setting.getName(), setting.getValString()));
}
if(setting.isKeybind()) {
this.silentInputs.add(new Input(setting.getName(), setting.getKeybind()));
}
}
}
@ -80,6 +85,10 @@ public class ModSettings extends SilentScreen {
setting.setValString(this.silentInputs.get(inputIndex).getValue().length() != 0 ? this.silentInputs.get(inputIndex).getValue() : setting.defaultsval);
inputIndex++;
}
if (setting.isKeybind()) {
setting.setKeybind(this.silentInputs.get(inputIndex).getKey() != 0 ? this.silentInputs.get(inputIndex).getKey() : setting.defaultkval);
inputIndex++;
}
}
super.onGuiClosed();
}
@ -160,6 +169,14 @@ public class ModSettings extends SilentScreen {
inputIndex++;
}
if(setting.isKeybind()) {
Client.getInstance().getSilentFontRenderer().drawString(setting.getName() + ":", x + 100, settingY + 1, 12, SilentFontRenderer.FontType.TITLE);
this.silentInputs.get(inputIndex).render(mouseX, mouseY, x + width - 35 - 5, settingY, 35, true, new DefaultInputTheme(), true);
ColorUtils.setColor(-1);
settingY += 5;
inputIndex++;
}
if(setting.isCombo()) {
Select.render(mouseX, mouseY, x, settingY, width, setting.getName(), setting.getValString());
}
@ -309,6 +326,12 @@ public class ModSettings extends SilentScreen {
inputIndex++;
}
if(setting.isKeybind()) {
this.silentInputs.get(inputIndex).onClick(mouseX, mouseY, x + width - 35 - 5, settingY, 35, true);
settingY += 5;
inputIndex++;
}
if(setting.isCombo()) {
int index = 0;
String curr = setting.getValString();
@ -383,6 +406,11 @@ public class ModSettings extends SilentScreen {
setting.setValString(this.silentInputs.get(inputIndex).getValue());
inputIndex++;
}
if (setting.isKeybind()) {
this.silentInputs.get(inputIndex).onKeyTyped(typedChar, keyCode);
setting.setKeybind(this.silentInputs.get(inputIndex).getKey());
inputIndex++;
}
}
}

View File

@ -14,6 +14,7 @@ import net.silentclient.client.gui.elements.StaticButton;
import net.silentclient.client.gui.font.SilentFontRenderer;
import net.silentclient.client.gui.theme.button.DefaultButtonTheme;
import net.silentclient.client.gui.theme.button.SelectedButtonTheme;
import net.silentclient.client.gui.theme.input.DefaultInputTheme;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.Setting;
@ -64,6 +65,10 @@ public class ModSettings extends SilentScreen {
if(setting.isInput()) {
this.silentInputs.add(new Input(setting.getName(), setting.getValString()));
}
if(setting.isKeybind()) {
this.silentInputs.add(new Input(setting.getName(), setting.getKeybind()));
}
}
}
@ -105,6 +110,12 @@ public class ModSettings extends SilentScreen {
settingY += 5;
inputIndex++;
}
if(setting.isKeybind()) {
Client.getInstance().getSilentFontRenderer().drawString(setting.getName(), 3, settingY, 12, SilentFontRenderer.FontType.TITLE);
this.silentInputs.get(inputIndex).render(mouseX, mouseY, 150 - 35 - 3, settingY, 35, true, new DefaultInputTheme(), true);
settingY += 5;
inputIndex++;
}
if (setting.isColor()) {
RegularColorPicker.render(3, settingY, 144, setting.getName(), setting.getValColor().getRGB());
}
@ -216,6 +227,12 @@ public class ModSettings extends SilentScreen {
settingY += 5;
inputIndex++;
}
if(setting.isKeybind()) {
Client.getInstance().getSilentFontRenderer().drawString(setting.getName(), 3, settingY, 12, SilentFontRenderer.FontType.TITLE);
this.silentInputs.get(inputIndex).onClick(mouseX, mouseY, 150 - 35 - 3, (int) settingY, 35, true);
settingY += 5;
inputIndex++;
}
if (setting.isColor() && RegularColorPicker.isHovered(mouseX, mouseY, 3, (int) settingY, 144)) {
mc.displayGuiScreen(new ColorPicker(mod, setting.getName(), this));
}
@ -310,6 +327,12 @@ public class ModSettings extends SilentScreen {
setting.setValString(this.silentInputs.get(inputIndex).getValue());
inputIndex++;
}
if (setting.isKeybind()) {
this.silentInputs.get(inputIndex).onKeyTyped(typedChar, keyCode);
setting.setKeybind(this.silentInputs.get(inputIndex).getKey());
inputIndex++;
}
}
}
@ -326,6 +349,10 @@ public class ModSettings extends SilentScreen {
setting.setValString(this.silentInputs.get(inputIndex).getValue().length() != 0 ? this.silentInputs.get(inputIndex).getValue() : setting.defaultsval);
inputIndex++;
}
if (setting.isKeybind()) {
setting.setKeybind(this.silentInputs.get(inputIndex).getKey() != 0 ? this.silentInputs.get(inputIndex).getKey() : setting.defaultkval);
inputIndex++;
}
}
Client.getInstance().configManager.save();
MenuBlurUtils.unloadBlur();

View File

@ -5,14 +5,13 @@ import net.minecraft.client.settings.GameSettings;
import net.minecraft.client.settings.KeyBinding;
import net.silentclient.client.mixin.SilentClientTweaker;
import org.apache.commons.lang3.ArrayUtils;
import org.lwjgl.input.Keyboard;
import java.util.Arrays;
public class KeyBindManager {
public KeyBinding CLICKGUI = new KeyBinding("Silent Client - Mod Menu", Keyboard.KEY_RSHIFT, "Silent Client");
public KeyBinding PERSPECTIVE = new KeyBinding("Silent Client - Perspective", Keyboard.KEY_LMENU, "Silent Client");
public KeyBinding ZOOM = new KeyBinding("Silent Client - Zoom", Keyboard.KEY_C, "Silent Client");
// public KeyBinding CLICKGUI = new KeyBinding("Silent Client - Mod Menu", Keyboard.KEY_RSHIFT, "Silent Client");
// public KeyBinding PERSPECTIVE = new KeyBinding("Silent Client - Perspective", Keyboard.KEY_LMENU, "Silent Client");
// public KeyBinding ZOOM = new KeyBinding("Silent Client - Zoom", Keyboard.KEY_C, "Silent Client");
public KeyBindManager(GameSettings gameSettings) {
if(SilentClientTweaker.hasOptifine) {
@ -23,9 +22,9 @@ public class KeyBindManager {
}
}
this.registerKeyBind(gameSettings, CLICKGUI);
this.registerKeyBind(gameSettings, PERSPECTIVE);
this.registerKeyBind(gameSettings, ZOOM);
// this.registerKeyBind(gameSettings, CLICKGUI);
// this.registerKeyBind(gameSettings, PERSPECTIVE);
// this.registerKeyBind(gameSettings, ZOOM);
}
public void registerKeyBind(GameSettings gameSettings, KeyBinding key) {

View File

@ -89,6 +89,10 @@ public class Mod implements IMod {
setting.setValBoolean(setting.defaultbval);
}
if(setting.isKeybind()) {
setting.setKeybind(setting.defaultkval);
}
if(setting.isColor()) {
setting.setValColor(setting.defaultcval);
setting.setChroma(false);
@ -255,6 +259,13 @@ public class Mod implements IMod {
return setting;
}
public Setting addKeybindSetting(String name, Mod mod, int keybind) {
Setting setting;
Client.getInstance().getSettingsManager().addSetting(setting = new Setting(name, mod, keybind));
return setting;
}
public Setting addModeSetting(String name, Mod mod, String defaultMode, ArrayList<String> options) {
Setting setting;
Client.getInstance().getSettingsManager().addSetting(setting =new Setting(name, mod, defaultMode, options));

View File

@ -1,11 +1,13 @@
package net.silentclient.client.mods;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.silentclient.client.Client;
import net.silentclient.client.utils.ColorUtils;
import org.lwjgl.input.Keyboard;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
public class Setting implements Comparable<Setting> {
private final String name;
@ -25,6 +27,10 @@ public class Setting implements Comparable<Setting> {
private double max;
private boolean onlyint = false;
// For keybind setting
private int kval;
public int defaultkval;
// For color setting
private Color cval;
public Color defaultcval;
@ -56,6 +62,14 @@ public class Setting implements Comparable<Setting> {
this.mode = "Check";
}
public Setting(String name, Mod parent, int kval) {
this.name = name;
this.parent = parent;
this.kval = kval;
this.defaultkval = kval;
this.mode = "Keybind";
}
public Setting(String name, Mod parent, Color cval) {
this.name = name;
this.parent = parent;
@ -133,6 +147,26 @@ public class Setting implements Comparable<Setting> {
this.sval = in;
}
public int getKeybind() {
return kval;
}
public void setKeybind(int kval) {
this.kval = kval;
}
public boolean isKeybind() {
return this.mode.equalsIgnoreCase("Keybind");
}
public boolean isKeyDown() {
if(!isKeybind()) {
return false;
}
return Minecraft.getMinecraft().inGameHasFocus && Keyboard.isKeyDown(kval);
}
public List<String> getOptions() {
return this.options;
}

View File

@ -10,6 +10,7 @@ import net.silentclient.client.event.impl.EventPlayerHeadRotation;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.util.Server;
import org.lwjgl.input.Keyboard;
public class PerspectiveMod extends Mod {
@ -22,6 +23,12 @@ public class PerspectiveMod extends Mod {
super("Perspective", ModCategory.MODS, "silentclient/icons/mods/perspective.png");
}
@Override
public void setup() {
super.setup();
this.addKeybindSetting("Keybind", this, Keyboard.KEY_LMENU);
}
@Override
public boolean isForceDisabled() {
if(Client.getInstance().getAccount().isAdmin() || Client.getInstance().getAccount().isStaff() || Client.getInstance().getAccount().isTester()) {
@ -33,7 +40,7 @@ public class PerspectiveMod extends Mod {
@EventTarget
public void updateEvent(ClientTickEvent event) {
if(!isForceDisabled()) {
if(Client.getInstance().getKeyBindManager().PERSPECTIVE.isKeyDown()) {
if(Client.getInstance().getSettingsManager().getSettingByName(this, "Keybind").isKeyDown()) {
start();
mc.gameSettings.thirdPersonView = 3;
}

View File

@ -25,6 +25,7 @@ public class ZoomMod extends Mod {
@Override
public void setup() {
this.addKeybindSetting("Keybind", this, Keyboard.KEY_C);
this.addBooleanSetting("Scroll", this, false);
this.addBooleanSetting("Smooth Zoom", this, true);
this.addSliderSetting("Zoom Speed", this, 14, 5, 20, true);
@ -38,7 +39,7 @@ public class ZoomMod extends Mod {
@EventTarget
public void onTick(ClientTickEvent event) {
if(Keyboard.isKeyDown(Client.getInstance().getKeyBindManager().ZOOM.getKeyCode()) && mc.inGameHasFocus) {
if(Client.getInstance().getSettingsManager().getSettingByName(this, "Keybind").isKeyDown()) {
if(!active) {
active = true;
lastSensitivity = mc.gameSettings.mouseSensitivity;

View File

@ -1,7 +1,5 @@
package net.silentclient.client.mods.settings;
import java.util.ArrayList;
import net.silentclient.client.Client;
import net.silentclient.client.gui.lite.clickgui.ClickGUI;
import net.silentclient.client.mods.Mod;
@ -10,6 +8,9 @@ import net.silentclient.client.mods.Setting;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.OSUtil;
import net.silentclient.client.utils.RawInputHandler;
import org.lwjgl.input.Keyboard;
import java.util.ArrayList;
public class GeneralMod extends Mod {
@Override
@ -28,6 +29,7 @@ public class GeneralMod extends Mod {
this.addBooleanSetting("Hide mods in F3", this, true);
this.addBooleanSetting("Vanilla ESC Menu Layout", this, false);
this.addBooleanSetting("Menu Background Blur", this, true);
this.addKeybindSetting("Mod Menu Keybind", this, Keyboard.KEY_RSHIFT);
ArrayList<String> options = new ArrayList<>();
options.add("Bottom Right Corner");
options.add("Bottom Left Corner");