From b1152ddbbb44f22af0c18917ac64958df4f100b1 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Sat, 7 Mar 2026 00:30:02 +0100 Subject: [PATCH] nofog and tps and zoom --- .../saturnclient/modules/mods/Nametags.java | 4 - .../org/saturnclient/modules/mods/NoFog.java | 39 +++++++ .../org/saturnclient/modules/mods/Tps.java | 100 ++++++++++++++++++ .../org/saturnclient/modules/mods/Zoom.java | 59 +++++++++++ 4 files changed, 198 insertions(+), 4 deletions(-) create mode 100644 src/main/java/org/saturnclient/modules/mods/NoFog.java create mode 100644 src/main/java/org/saturnclient/modules/mods/Tps.java create mode 100644 src/main/java/org/saturnclient/modules/mods/Zoom.java diff --git a/src/main/java/org/saturnclient/modules/mods/Nametags.java b/src/main/java/org/saturnclient/modules/mods/Nametags.java index 41071f4..17b5de2 100644 --- a/src/main/java/org/saturnclient/modules/mods/Nametags.java +++ b/src/main/java/org/saturnclient/modules/mods/Nametags.java @@ -28,8 +28,6 @@ public class Nametags extends Module { "§8", "§9", "§a", "§b", "§c", "§d", "§e", "§f" }; - private final NametagsInterface minecraft; - public Nametags(NametagsInterface minecraft) { super(new ModuleDetails("Nametags", "nametags") .description("Allows you to modify entity nametags") @@ -46,8 +44,6 @@ public class Nametags extends Module { format.named("Format"), nameColor.named("Name color"), healthColor.named("Health color")); - - this.minecraft = minecraft; } @Override diff --git a/src/main/java/org/saturnclient/modules/mods/NoFog.java b/src/main/java/org/saturnclient/modules/mods/NoFog.java new file mode 100644 index 0000000..3b0ee88 --- /dev/null +++ b/src/main/java/org/saturnclient/modules/mods/NoFog.java @@ -0,0 +1,39 @@ +package org.saturnclient.modules.mods; + +import org.saturnclient.modules.Module; +import org.saturnclient.modules.ModuleDetails; +import org.saturnclient.config.manager.Property; + +public class NoFog extends Module { + private static Property enabled = Property.bool(false); + private static Property liquids = Property.bool(false); + + public NoFog() { + super( + new ModuleDetails("No Fog", "nofog") + .description("Stops fog from rendering") + .tags("Camera") + .version("v0.1.0"), + enabled.named("Enabled"), + liquids.named("See through liquids")); + } + + @Override + public boolean isEnabled() { + return enabled.value; + } + + @Override + public void onEnabled(boolean e) { + enabled.value = e; + } + + // static for the mixin + public static boolean isActive() { + return enabled.value; + } + + public static boolean liquids() { + return liquids.value; + } +} diff --git a/src/main/java/org/saturnclient/modules/mods/Tps.java b/src/main/java/org/saturnclient/modules/mods/Tps.java new file mode 100644 index 0000000..4f1acb4 --- /dev/null +++ b/src/main/java/org/saturnclient/modules/mods/Tps.java @@ -0,0 +1,100 @@ +package org.saturnclient.modules.mods; + +import org.saturnclient.modules.HudMod; +import org.saturnclient.modules.ModDimensions; +import org.saturnclient.modules.Module; +import org.saturnclient.modules.ModuleDetails; +import org.saturnclient.config.manager.Property; +import org.saturnclient.ui.RenderScope; +import org.saturnclient.ui.resources.Fonts; + +public class Tps extends Module implements HudMod { + private static Property enabled = Property.bool(false); + private static ModDimensions dimensions = new ModDimensions(60, Fonts.getHeight()); + + private static long lastWorldAge = -1; + private static long lastRealTime = -1; + private static double currentTps = 20.0; + + private static final int SAMPLE_COUNT = 2; + private static final double[] samples = new double[SAMPLE_COUNT]; + static { + java.util.Arrays.fill(samples, 20.0); + } + private static int sampleIndex = 0; + private static int samplesFilled = 0; + + public Tps() { + super(new ModuleDetails("TPS Display", "tps") + .description("Displays the TPS") + .version("v0.1.0") + .tags("Utility"), + enabled.named("Enabled"), + dimensions.prop()); + } + + public static void onTimePacket(long worldAge) { + long now = System.currentTimeMillis(); + + if (lastWorldAge != -1 && lastRealTime != -1) { + long tickDelta = worldAge - lastWorldAge; + long timeDelta = now - lastRealTime; + + if (timeDelta > 0 && tickDelta > 0) { + double sample = (tickDelta / (double) timeDelta) * 1000.0; + sample = Math.min(sample, 20.0); + + samples[sampleIndex % SAMPLE_COUNT] = sample; + sampleIndex++; + samplesFilled = Math.min(samplesFilled + 1, SAMPLE_COUNT); + + double sum = 0; + for (int i = 0; i < samplesFilled; i++) + sum += samples[i]; + currentTps = sum / samplesFilled; + } + } + + lastWorldAge = worldAge; + lastRealTime = now; + } + + public static void reset() { + lastWorldAge = -1; + lastRealTime = -1; + currentTps = 20.0; + sampleIndex = 0; + samplesFilled = SAMPLE_COUNT; + for (int i = 0; i < SAMPLE_COUNT; i++) + samples[i] = 20.0; + } + + @Override + public void renderHud(RenderScope scope) { + String text = String.format("%.1f TPS", currentTps); + scope.drawText(text, 0, 0, dimensions.font.value, dimensions.fgColor.value); + dimensions.width = Fonts.getWidth(text, dimensions.font.value); + } + + @Override + public void renderDummy(RenderScope scope) { + String text = "20.0 TPS"; + scope.drawText(text, 0, 0, dimensions.font.value, dimensions.fgColor.value); + dimensions.width = Fonts.getWidth(text, dimensions.font.value); + } + + @Override + public boolean isEnabled() { + return enabled.value; + } + + @Override + public void onEnabled(boolean e) { + enabled.value = e; + } + + @Override + public ModDimensions getDimensions() { + return dimensions; + } +} diff --git a/src/main/java/org/saturnclient/modules/mods/Zoom.java b/src/main/java/org/saturnclient/modules/mods/Zoom.java new file mode 100644 index 0000000..77240bc --- /dev/null +++ b/src/main/java/org/saturnclient/modules/mods/Zoom.java @@ -0,0 +1,59 @@ +package org.saturnclient.modules.mods; + +import org.saturnclient.modules.Module; +import org.saturnclient.modules.ModuleDetails; +import org.saturnclient.config.manager.Key; +import org.saturnclient.config.manager.Property; + +public class Zoom extends Module { + private static Property enabled = Property.bool(false); + private static Property toggle = Property.bool(false); + public static Property zoomKey = Property.keybinding(Key.GLFW_KEY_C); + public static Property zoomLevel = Property.floatProp(3.0f); + + public static boolean isZooming = false; + + public Zoom() { + super( + new ModuleDetails("Zoom", "zoom") + .description("Allows you to zoom in for a closer view") + .tags("Camera", "Utility") + .version("0.1.0"), + enabled.named("Enabled"), + toggle.named("Toggle zoom"), + zoomKey.named("Zoom Keybinding"), + zoomLevel.named("Zoom Level")); + } + + @Override + public void tick() { + if (toggle.value) { + if (zoomKey.wasKeyPressed()) { + isZooming = !isZooming; + } + } else { + isZooming = zoomKey.isKeyPressed(); + } + } + + public static float getZoomLevel() { + return zoomLevel.value; + } + + public static boolean shouldZoom() { + return enabled.value; + } + + @Override + public void onEnabled(boolean e) { + enabled.value = e; + if (!e) { + isZooming = false; + } + } + + @Override + public boolean isEnabled() { + return enabled.value; + } +}