(feat) Crosshair editor :3

This commit is contained in:
refactoring 2024-01-02 01:26:49 -05:00
parent 1e577ff52a
commit a87875e565
14 changed files with 180 additions and 13 deletions

View File

@ -5,7 +5,7 @@
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="zulu-1.8 (4)" />
<option name="gradleJvm" value="ibm-1.8" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

View File

@ -4,7 +4,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="zulu-1.8 (3)" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="zulu-1.8 (3)" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -22,7 +22,7 @@ import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.Mod;
import net.silentclient.client.mods.ModCategory;
import net.silentclient.client.mods.Setting;
import net.silentclient.client.mods.render.CrosshairMod;
import net.silentclient.client.mods.render.crosshair.CrosshairMod;
import net.silentclient.client.mods.world.TimeChangerMod;
import net.silentclient.client.utils.ColorUtils;
import net.silentclient.client.utils.MenuBlurUtils;

View File

@ -0,0 +1,38 @@
package net.silentclient.client.gui.modmenu;
import net.silentclient.client.gui.lite.clickgui.utils.MouseUtils;
import net.silentclient.client.gui.lite.clickgui.utils.RenderUtils;
import net.silentclient.client.gui.util.RenderUtil;
import net.silentclient.client.mods.Setting;
import org.lwjgl.input.Mouse;
import java.awt.*;
/**
* @author refactoring
*/
public class CellGrid {
public static void render(float mouseX, float mouseY, float x, float y, Setting grid) {
for (int row = 0; row < 11; row++) {
for (int col = 0; col < 11; col++) {
float rx = x + col * 11;
float ry = y + row * 11;
RenderUtil.drawRoundedOutline(rx, ry, 11, 11, 0f, 1f, new Color(255, 255, 255, 120).getRGB());
RenderUtils.drawRect(rx, ry, 11, 11,
grid.getCells()[row][col] ?
MouseUtils.isInside((int) mouseX, (int) mouseY, rx, ry, 11, 11) ? 0x70ffffff : 0x50ffffff :
MouseUtils.isInside((int) mouseX, (int) mouseY, rx, ry, 11, 11) ? 0x20ffffff : 0x00ffffff
);
if(MouseUtils.isInside((int) mouseX, (int) mouseY, rx, ry, 11, 11) && Mouse.isButtonDown(0)) {
grid.getCells()[row][col] = true;
}
if(MouseUtils.isInside((int) mouseX, (int) mouseY, rx, ry, 11, 11) && Mouse.isButtonDown(1)) {
grid.getCells()[row][col] = false;
}
}
}
}
}

View File

@ -19,7 +19,7 @@ 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;
import net.silentclient.client.mods.render.CrosshairMod;
import net.silentclient.client.mods.render.crosshair.CrosshairMod;
import net.silentclient.client.mods.world.TimeChangerMod;
import net.silentclient.client.utils.MenuBlurUtils;
import net.silentclient.client.utils.MouseCursorHandler;
@ -135,7 +135,10 @@ public class ModSettings extends SilentScreen {
cursorType = MouseCursorHandler.CursorType.POINTER;
}
}
if(setting.isCellGrid()) {
CellGrid.render(mouseX, mouseY, 3, settingY, setting);
settingY += 120;
}
if(setting.isSlider()) {
RegularSlider.render(3, settingY, 144, setting.getName(), setting.getMax(), setting.getValDouble());

View File

@ -15,7 +15,7 @@ import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
import net.silentclient.client.mods.hud.BossBarMod;
import net.silentclient.client.mods.hud.ScoreboardMod;
import net.silentclient.client.mods.render.AnimationsMod;
import net.silentclient.client.mods.render.CrosshairMod;
import net.silentclient.client.mods.render.crosshair.CrosshairMod;
import net.silentclient.client.mods.render.PackTweaksMod;
import net.silentclient.client.mods.render.TitlesMod;
import net.silentclient.client.mods.settings.RenderMod;

View File

@ -259,6 +259,10 @@ public class Mod implements IMod {
return setting;
}
public Setting addCellSetting(String name, Mod mod, boolean[][] cells) {
return Client.getInstance().getSettingsManager().addSetting(new Setting(name, mod, cells));
}
public Setting addKeybindSetting(String name, Mod mod, int keybind) {
Setting setting;

View File

@ -9,6 +9,7 @@ import net.silentclient.client.mods.hypixel.QuickPlayMod;
import net.silentclient.client.mods.hypixel.togglechat.ToggleChatMod;
import net.silentclient.client.mods.player.*;
import net.silentclient.client.mods.render.*;
import net.silentclient.client.mods.render.crosshair.CrosshairMod;
import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.mods.settings.FPSBoostMod;
import net.silentclient.client.mods.settings.GeneralMod;

View File

@ -35,9 +35,14 @@ public class Setting implements Comparable<Setting> {
private Color cval;
public Color defaultcval;
// for cell setting
private boolean[][] cells;
private int key;
// Settings category
private String category = "";
private int opacity = 255;
public int defaultopacity = 255;
private boolean chroma = false;
@ -80,6 +85,25 @@ public class Setting implements Comparable<Setting> {
this.defaultopacity = 255;
}
public Setting(String name, Mod parent, boolean[][] cells) {
this.mode = "CellGrid";
this.name = name;
this.parent = parent;
this.cells = new boolean[][]{
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, true, true, false, true, false, true, true, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false}
};;
}
public Setting(String name, Mod parent, Color cval, int opacity) {
this.name = name;
this.parent = parent;
@ -167,6 +191,10 @@ public class Setting implements Comparable<Setting> {
return Minecraft.getMinecraft().inGameHasFocus && Keyboard.isKeyDown(kval);
}
public boolean[][] getCells() {
return cells;
}
public List<String> getOptions() {
return this.options;
}
@ -261,6 +289,10 @@ public class Setting implements Comparable<Setting> {
return this.mode.equalsIgnoreCase("Input");
}
public boolean isCellGrid() {
return this.mode.equalsIgnoreCase("CellGrid");
}
public String getMode() {
return mode;
}

View File

@ -12,8 +12,9 @@ public class SettingsManager {
this.settings = new ArrayList<>();
}
public void addSetting(Setting in){
public Setting addSetting(Setting in){
this.settings.add(in);
return in;
}
public ArrayList<Setting> getSettingByMod(Mod mod){

View File

@ -2,6 +2,7 @@ package net.silentclient.client.mods.render;
import java.awt.Color;
import net.silentclient.client.mods.render.crosshair.CrosshairMod;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.renderer.GlStateManager;

View File

@ -0,0 +1,42 @@
package net.silentclient.client.mods.render.crosshair;
/**
* @author refactoring
*/
import java.util.ArrayList;
import java.util.List;
public class CLayoutManager {
private final List<boolean[][]> layouts = new ArrayList<>();
public CLayoutManager() {
init();
}
public void init() {
addLayout(cDefault);
}
public boolean[][] getLayout(int index) {
return layouts.get(index);
}
public void addLayout(boolean[][] layout) {
layouts.add(layout);
}
final boolean[][] cDefault = new boolean[][]{
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, true, true, false, true, false, true, true, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false}
};
}

View File

@ -1,7 +1,9 @@
package net.silentclient.client.mods.render;
package net.silentclient.client.mods.render.crosshair;
import com.sun.corba.se.impl.resolver.SplitLocalResolverImpl;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@ -24,6 +26,7 @@ import net.silentclient.client.mods.settings.RenderMod;
import net.silentclient.client.utils.DisplayUtil;
import net.silentclient.client.utils.MouseCursorHandler;
import net.silentclient.client.utils.Sounds;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import java.awt.*;
@ -32,9 +35,25 @@ import java.util.ArrayList;
public class CrosshairMod extends Mod {
private int componentWidth = 0;
private final CLayoutManager layoutManager;
boolean[][] cDefault = new boolean[][]{
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, true, true, false, true, false, true, true, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false, false, false}
};
public CrosshairMod() {
super("Crosshair", ModCategory.MODS, "silentclient/icons/mods/crosshair.png");
layoutManager = new CLayoutManager();
}
@Override
@ -91,6 +110,8 @@ public class CrosshairMod extends Mod {
options.add("Square");
options.add("None");
this.addBooleanSetting("Use custom shape", this, false);
this.addCellSetting("Shape", this, cDefault);
this.addModeSetting("Type", this, "Cross", options);
this.addColorSetting("Crosshair Color", this, new Color(255, 255, 255));
this.addColorSetting("Player Color", this, new Color(176,46,38));
@ -111,6 +132,10 @@ public class CrosshairMod extends Mod {
this.addBooleanSetting("Vanilla Blendering", this, true);
}
private boolean[][] getCells() {
return Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Shape").getCells();
}
@Override
public int customComponentHeight() {
boolean preset = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean();
@ -352,8 +377,28 @@ public class CrosshairMod extends Mod {
if(Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Preset Crosshair").getValBoolean()) {
return;
}
if(Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Use custom Shape").getValBoolean()) {
renderCustomShape();
} else {
renderCrosshair();
}
}
public void renderCustomShape() {
ScaledResolution res = new ScaledResolution(mc);
for (int row = 0; row < 11; row++) {
for (int col = 0; col < 11; col++) {
if (getCells()[row][col] && isToggled()) {
RenderUtils.drawRect(
(float) res.getScaledWidth() / 2 - 5 + col,
(float) res.getScaledHeight() / 2 - 5 + row,
1, 1, Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Crosshair Color").getValColor().getRGB()
);
}
}
}
}
public void renderCrosshair() {
String type = Client.getInstance().getSettingsManager().getSettingByClass(CrosshairMod.class, "Type").getValString();

View File

@ -19,7 +19,7 @@ import net.silentclient.client.Client;
import net.silentclient.client.event.EventTarget;
import net.silentclient.client.event.impl.ClientTickEvent;
import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
import net.silentclient.client.mods.render.CrosshairMod;
import net.silentclient.client.mods.render.crosshair.CrosshairMod;
import net.silentclient.client.mods.settings.FPSBoostMod;
import net.silentclient.client.mods.settings.RenderMod;