few changes to finish today

This commit is contained in:
2025-05-12 15:04:08 -05:00
parent a016fd72c6
commit 86b638afca
6 changed files with 57 additions and 31 deletions
@@ -15,7 +15,6 @@ public class ModManager {
public static Module[] MODS = { public static Module[] MODS = {
new Crosshair(), new Crosshair(),
new AutoSprint(), new AutoSprint(),
new AutoSprint(),
}; };
public static void init() { public static void init() {
@@ -12,11 +12,9 @@ import net.minecraft.client.render.RenderLayer;
public class Crosshair extends Module { public class Crosshair extends Module {
public static Property<Boolean> enabled = new Property<>(false); public static Property<Boolean> enabled = new Property<>(false);
public static Property<Boolean> range_indicator = new Property<>(false); public static Property<Boolean> range_indicator = new Property<>(false);
public static Property<Integer> idk = new Property<>(-1, Property.PropertyType.HEX);
public static Property<Integer> idk2 = new Property<>(-1, Property.PropertyType.INTEGER);
public Crosshair() { public Crosshair() {
super(new ModuleDetails("Crosshair", "crosshair").description("Changes the crosshair if you're aiming at a entity").tags("Visuals", "Utility"), enabled.named("Enabled"), range_indicator.named("Range Indicator"), idk.named("Color"), idk2.named("Integer")); super(new ModuleDetails("Crosshair", "crosshair").description("Changes the crosshair if you're aiming at a entity").tags("Visuals", "Utility"), enabled.named("Enabled"), range_indicator.named("Range Indicator"));
} }
@Override @Override
@@ -47,7 +47,7 @@ public class SaturnModule extends Element {
theme.setState("enabled"); theme.setState("enabled");
} }
if (ctx.isHovering(width - s - p, height - s - p, s, s)) { if (ctx.isHovering(width - s - p - 5, height - s - p - 5, s + 10, s + 10)) {
settingsHover = true; settingsHover = true;
} else if (ctx.isHovering()) { } else if (ctx.isHovering()) {
theme.applyState("hovering"); theme.applyState("hovering");
@@ -77,7 +77,7 @@ public class SaturnModule extends Element {
int p = 10; int p = 10;
int s = 14; int s = 14;
if (Utils.isHovering(mouseX - (width - s - p), mouseY - (height - s - p), s, s, 1.0f)) { if (Utils.isHovering(mouseX - (width - s - p - 5), mouseY - (height - s - p - 5), s + 10, s + 10, 1.0f)) {
SaturnClient.client.setScreen(new ConfigEditor(mod.getConfig())); SaturnClient.client.setScreen(new ConfigEditor(mod.getConfig()));
} else { } else {
mod.setEnabled(!mod.isEnabled()); mod.setEnabled(!mod.isEnabled());
@@ -4,13 +4,13 @@ import java.awt.Color;
import org.saturnclient.saturnclient.SaturnClient; import org.saturnclient.saturnclient.SaturnClient;
import org.saturnclient.saturnclient.config.Property; import org.saturnclient.saturnclient.config.Property;
import org.saturnclient.saturnclient.mixin.DrawContextAccessor;
import org.saturnclient.ui2.RenderScope;
import org.saturnclient.ui2.SaturnScreen; import org.saturnclient.ui2.SaturnScreen;
import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
public class ColorDialog extends Screen { public class ColorDialog extends SaturnScreen {
private Property<Integer> prop; private Property<Integer> prop;
private SaturnScreen parent; private SaturnScreen parent;
private static final int PICKER_WIDTH = 200; private static final int PICKER_WIDTH = 200;
@@ -25,7 +25,7 @@ public class ColorDialog extends Screen {
private boolean dragging = false; private boolean dragging = false;
public ColorDialog(Property<Integer> prop , SaturnScreen parent) { public ColorDialog(Property<Integer> prop , SaturnScreen parent) {
super(Text.literal("Color Dialog")); super("Color Dialog");
this.prop = prop; this.prop = prop;
this.parent = parent; this.parent = parent;
@@ -34,6 +34,9 @@ public class ColorDialog extends Screen {
this.opacity = alpha / 255.0f; this.opacity = alpha / 255.0f;
} }
@Override
public void ui() {}
@Override @Override
public void close() { public void close() {
SaturnClient.client.setScreen(parent); SaturnClient.client.setScreen(parent);
@@ -41,7 +44,13 @@ public class ColorDialog extends Screen {
@Override @Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) { public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context, mouseX, mouseY, delta); super.render(context, mouseX, mouseY, delta);
RenderScope renderScope = new RenderScope(context.getMatrices(),
((DrawContextAccessor) context).getVertexConsumers());
renderScope.matrices.push();
renderScope.matrices.scale(0.5f, 0.5f, 0.5f);
int xStart = (width - PICKER_WIDTH) / 2; int xStart = (width - PICKER_WIDTH) / 2;
int yStart = (height - PICKER_HEIGHT) / 2; int yStart = (height - PICKER_HEIGHT) / 2;
@@ -62,6 +71,8 @@ public class ColorDialog extends Screen {
context.drawBorder(x, y, 8, 8, 0xFFffffff); context.drawBorder(x, y, 8, 8, 0xFFffffff);
renderSlider(context, mouseX, mouseY, delta); renderSlider(context, mouseX, mouseY, delta);
renderScope.matrices.pop();
} }
public void renderSlider(DrawContext context, int mouseX, int mouseY, float delta) { public void renderSlider(DrawContext context, int mouseX, int mouseY, float delta) {
@@ -86,6 +97,9 @@ public class ColorDialog extends Screen {
@Override @Override
public boolean mouseClicked(double mouseX, double mouseY, int button) { public boolean mouseClicked(double mouseX, double mouseY, int button) {
mouseX *= 2;
mouseY *= 2;
int xStart = (width - PICKER_WIDTH) / 2; int xStart = (width - PICKER_WIDTH) / 2;
int yStart = (height - PICKER_HEIGHT) / 2; int yStart = (height - PICKER_HEIGHT) / 2;
@@ -121,6 +135,9 @@ public class ColorDialog extends Screen {
@Override @Override
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) { public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
mouseX *= 2;
mouseY *= 2;
if (dragging) { if (dragging) {
updateOpacity(mouseX); updateOpacity(mouseX);
return true; return true;
@@ -16,7 +16,7 @@ public class FloatInput extends Input {
@Override @Override
public void charTyped(char chr) { public void charTyped(char chr) {
if ((Character.isDigit(chr) || chr == '.') && text.length() < 10) { if ((Character.isDigit(chr) || chr == '.' || (chr == '-' && cursorPosition == 0)) && text.length() < 10) {
if (text.equals("0") && cursorPosition == 1) { if (text.equals("0") && cursorPosition == 1) {
text = "" + chr; text = "" + chr;
} else { } else {
@@ -24,22 +24,28 @@ public class FloatInput extends Input {
chr + chr +
text.substring(cursorPosition); text.substring(cursorPosition);
try {
prop.value = text.isEmpty() ? 0 : Float.parseFloat(text); prop.value = text.isEmpty() ? 0 : Float.parseFloat(text);
ConfigManager.save();
cursorPosition++; cursorPosition++;
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
} }
@Override @Override
public void backspace() { public void backspace() {
try {
if (text.length() == 0) { if (text.length() == 0) {
text = "0"; text = "0";
cursorPosition = 1; cursorPosition = 1;
} }
prop.value = Float.parseFloat(text); prop.value = Float.parseFloat(text);
ConfigManager.save(); ConfigManager.save();
} catch (Exception e) {
e.printStackTrace();
}
} }
@Override @Override
@@ -16,7 +16,7 @@ public class IntInput extends Input {
@Override @Override
public void charTyped(char chr) { public void charTyped(char chr) {
if ((Character.isDigit(chr) || chr == '.') && text.length() < 10) { if ((Character.isDigit(chr) || chr == '.' || (chr == '-' && cursorPosition == 0)) && text.length() < 10) {
if (text.equals("0") && cursorPosition == 1) { if (text.equals("0") && cursorPosition == 1) {
text = "" + chr; text = "" + chr;
} else { } else {
@@ -24,22 +24,28 @@ public class IntInput extends Input {
chr + chr +
text.substring(cursorPosition); text.substring(cursorPosition);
try {
prop.value = text.isEmpty() ? 0 : Integer.parseInt(text); prop.value = text.isEmpty() ? 0 : Integer.parseInt(text);
ConfigManager.save();
cursorPosition++; cursorPosition++;
} catch (Exception e) {
e.printStackTrace();
}
} }
} }
} }
@Override @Override
public void backspace() { public void backspace() {
try {
if (text.length() == 0) { if (text.length() == 0) {
text = "0"; text = "0";
cursorPosition = 1; cursorPosition = 1;
} }
prop.value = Integer.parseInt(text); prop.value = Integer.parseInt(text);
ConfigManager.save(); ConfigManager.save();
} catch (Exception e) {
e.printStackTrace();
}
} }
@Override @Override