fps and freelook

This commit is contained in:
2026-03-06 23:54:25 +01:00
parent afedec45ae
commit 9fee71154e
7 changed files with 107 additions and 15 deletions
@@ -0,0 +1,7 @@
package org.saturnclient.modules.interfaces;
public interface FpsInterface {
int getFps();
}
@@ -0,0 +1,11 @@
package org.saturnclient.modules.interfaces;
public interface FreelookInterface {
boolean isFirstPerson();
void setFirstPerson();
void setThirdPersonBack();
}
@@ -4,35 +4,46 @@ import org.saturnclient.modules.HudMod;
import org.saturnclient.modules.ModDimensions;
import org.saturnclient.modules.Module;
import org.saturnclient.modules.ModuleDetails;
import org.saturnclient.saturnclient.SaturnClient;
import org.saturnclient.modules.interfaces.FpsInterface;
import org.saturnclient.config.manager.Property;
import org.saturnclient.ui.RenderScope;
import org.saturnclient.ui.resources.Fonts;
public class Fps extends Module implements HudMod {
private static Property<Boolean> enabled = Property.bool(false);
private static ModDimensions dimensions = new ModDimensions(60, Fonts.getHeight());
public Fps() {
private final FpsInterface minecraft;
public Fps(FpsInterface minecraft) {
super(new ModuleDetails("FPS Display", "fps")
.description("Displays current FPS")
.version("v0.1.0")
.tags("Utility"),
enabled.named("Enabled"),
dimensions.prop());
this.minecraft = minecraft;
}
@Override
public void renderHud(RenderScope scope) {
String text = String.valueOf(SaturnClient.client.getCurrentFps()) + " FPS";
int fps = minecraft.getFps();
String text = fps + " FPS";
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 = "369 FPS";
scope.drawText(text, 0, 0, dimensions.font.value, dimensions.fgColor.value);
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
}
@@ -50,4 +61,4 @@ public class Fps extends Module implements HudMod {
public ModDimensions getDimensions() {
return dimensions;
}
}
}
@@ -1,21 +1,24 @@
package org.saturnclient.modules.mods;
import org.lwjgl.glfw.GLFW;
import org.saturnclient.modules.Module;
import org.saturnclient.modules.ModuleDetails;
import org.saturnclient.saturnclient.SaturnClient;
import org.saturnclient.modules.interfaces.FreelookInterface;
import org.saturnclient.config.manager.Key;
import org.saturnclient.config.manager.Property;
import net.minecraft.client.option.Perspective;
public class Freelook extends Module {
private static Property<Boolean> enabled = Property.bool(false);
private static Property<Boolean> toggle = Property.bool(true);
public static Property<Integer> freelookKey = Property.keybinding(GLFW.GLFW_KEY_H);
public static Property<Integer> freelookKey = Property.keybinding(Key.GLFW_KEY_H);
public static boolean isFreeLooking = false;
private static boolean was1stPerson = false;
public Freelook() {
private final FreelookInterface minecraft;
public Freelook(FreelookInterface minecraft) {
super(
new ModuleDetails("Freelook", "freelook")
.description("Allows you to look around freely without moving your character")
@@ -24,37 +27,52 @@ public class Freelook extends Module {
enabled.named("Enabled"),
toggle.named("Toggle freelook"),
freelookKey.named("Freelook Keybinding"));
this.minecraft = minecraft;
}
@Override
public void tick() {
if (toggle.value) {
if (freelookKey.wasKeyPressed()) {
if (isFreeLooking) {
stopFreelook();
} else {
startFreelook();
}
}
} else if (freelookKey.isKeyPressed()) {
if (!isFreeLooking) {
startFreelook();
}
} else if (isFreeLooking) {
stopFreelook();
}
}
private void startFreelook() {
isFreeLooking = true;
was1stPerson = SaturnClient.client.options.getPerspective() == Perspective.FIRST_PERSON;
SaturnClient.client.options.setPerspective(Perspective.THIRD_PERSON_BACK);
was1stPerson = minecraft.isFirstPerson();
minecraft.setThirdPersonBack();
}
private void stopFreelook() {
if (was1stPerson) {
SaturnClient.client.options.setPerspective(Perspective.FIRST_PERSON);
minecraft.setFirstPerson();
}
isFreeLooking = false;
}
@@ -67,4 +85,4 @@ public class Freelook extends Module {
public boolean isEnabled() {
return enabled.value;
}
}
}
@@ -6,11 +6,14 @@ import org.saturnclient.modules.mods.*;
import org.saturnclient.impl.modules.*;
public class FabricModuleProvider implements ModuleProvider {
public static Module[] MODS = {
public static final Module[] MODS = {
new ArmorDisplay(new ArmorDisplayFabric()),
new AutoSprint(new AutoSprintFabric()),
new Coordinates(new CoordinatesFabric()),
new Crosshair(new CrosshairFabric()),
new DayCounter(new DayCounterFabric()),
new Fps(new FpsFabric()),
new Freelook(new FreelookFabric()),
new Clock(),
};
@@ -0,0 +1,15 @@
package org.saturnclient.impl.modules;
import org.saturnclient.modules.interfaces.FpsInterface;
import net.minecraft.client.MinecraftClient;
public class FpsFabric implements FpsInterface {
private final MinecraftClient mc = MinecraftClient.getInstance();
@Override
public int getFps() {
return mc.getCurrentFps();
}
}
@@ -0,0 +1,27 @@
package org.saturnclient.impl.modules;
import org.saturnclient.modules.interfaces.FreelookInterface;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.Perspective;
public class FreelookFabric implements FreelookInterface {
private final MinecraftClient mc = MinecraftClient.getInstance();
@Override
public boolean isFirstPerson() {
return mc.options.getPerspective() == Perspective.FIRST_PERSON;
}
@Override
public void setFirstPerson() {
mc.options.setPerspective(Perspective.FIRST_PERSON);
}
@Override
public void setThirdPersonBack() {
mc.options.setPerspective(Perspective.THIRD_PERSON_BACK);
}
}