fps and freelook
This commit is contained in:
@@ -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();
|
||||||
|
|
||||||
|
}
|
||||||
+15
-4
@@ -4,35 +4,46 @@ import org.saturnclient.modules.HudMod;
|
|||||||
import org.saturnclient.modules.ModDimensions;
|
import org.saturnclient.modules.ModDimensions;
|
||||||
import org.saturnclient.modules.Module;
|
import org.saturnclient.modules.Module;
|
||||||
import org.saturnclient.modules.ModuleDetails;
|
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.config.manager.Property;
|
||||||
import org.saturnclient.ui.RenderScope;
|
import org.saturnclient.ui.RenderScope;
|
||||||
import org.saturnclient.ui.resources.Fonts;
|
import org.saturnclient.ui.resources.Fonts;
|
||||||
|
|
||||||
public class Fps extends Module implements HudMod {
|
public class Fps extends Module implements HudMod {
|
||||||
|
|
||||||
private static Property<Boolean> enabled = Property.bool(false);
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
private static ModDimensions dimensions = new ModDimensions(60, Fonts.getHeight());
|
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")
|
super(new ModuleDetails("FPS Display", "fps")
|
||||||
.description("Displays current FPS")
|
.description("Displays current FPS")
|
||||||
.version("v0.1.0")
|
.version("v0.1.0")
|
||||||
.tags("Utility"),
|
.tags("Utility"),
|
||||||
enabled.named("Enabled"),
|
enabled.named("Enabled"),
|
||||||
dimensions.prop());
|
dimensions.prop());
|
||||||
|
|
||||||
|
this.minecraft = minecraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderHud(RenderScope scope) {
|
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);
|
scope.drawText(text, 0, 0, dimensions.font.value, dimensions.fgColor.value);
|
||||||
|
|
||||||
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderDummy(RenderScope scope) {
|
public void renderDummy(RenderScope scope) {
|
||||||
String text = "369 FPS";
|
String text = "369 FPS";
|
||||||
|
|
||||||
scope.drawText(text, 0, 0, dimensions.font.value, dimensions.fgColor.value);
|
scope.drawText(text, 0, 0, dimensions.font.value, dimensions.fgColor.value);
|
||||||
|
|
||||||
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,4 +61,4 @@ public class Fps extends Module implements HudMod {
|
|||||||
public ModDimensions getDimensions() {
|
public ModDimensions getDimensions() {
|
||||||
return dimensions;
|
return dimensions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+28
-10
@@ -1,21 +1,24 @@
|
|||||||
package org.saturnclient.modules.mods;
|
package org.saturnclient.modules.mods;
|
||||||
|
|
||||||
import org.lwjgl.glfw.GLFW;
|
|
||||||
import org.saturnclient.modules.Module;
|
import org.saturnclient.modules.Module;
|
||||||
import org.saturnclient.modules.ModuleDetails;
|
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 org.saturnclient.config.manager.Property;
|
||||||
|
|
||||||
import net.minecraft.client.option.Perspective;
|
|
||||||
|
|
||||||
public class Freelook extends Module {
|
public class Freelook extends Module {
|
||||||
|
|
||||||
private static Property<Boolean> enabled = Property.bool(false);
|
private static Property<Boolean> enabled = Property.bool(false);
|
||||||
private static Property<Boolean> toggle = Property.bool(true);
|
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;
|
public static boolean isFreeLooking = false;
|
||||||
private static boolean was1stPerson = false;
|
private static boolean was1stPerson = false;
|
||||||
|
|
||||||
public Freelook() {
|
private final FreelookInterface minecraft;
|
||||||
|
|
||||||
|
public Freelook(FreelookInterface minecraft) {
|
||||||
super(
|
super(
|
||||||
new ModuleDetails("Freelook", "freelook")
|
new ModuleDetails("Freelook", "freelook")
|
||||||
.description("Allows you to look around freely without moving your character")
|
.description("Allows you to look around freely without moving your character")
|
||||||
@@ -24,37 +27,52 @@ public class Freelook extends Module {
|
|||||||
enabled.named("Enabled"),
|
enabled.named("Enabled"),
|
||||||
toggle.named("Toggle freelook"),
|
toggle.named("Toggle freelook"),
|
||||||
freelookKey.named("Freelook Keybinding"));
|
freelookKey.named("Freelook Keybinding"));
|
||||||
|
|
||||||
|
this.minecraft = minecraft;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
|
|
||||||
if (toggle.value) {
|
if (toggle.value) {
|
||||||
|
|
||||||
if (freelookKey.wasKeyPressed()) {
|
if (freelookKey.wasKeyPressed()) {
|
||||||
|
|
||||||
if (isFreeLooking) {
|
if (isFreeLooking) {
|
||||||
stopFreelook();
|
stopFreelook();
|
||||||
} else {
|
} else {
|
||||||
startFreelook();
|
startFreelook();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (freelookKey.isKeyPressed()) {
|
} else if (freelookKey.isKeyPressed()) {
|
||||||
|
|
||||||
if (!isFreeLooking) {
|
if (!isFreeLooking) {
|
||||||
startFreelook();
|
startFreelook();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (isFreeLooking) {
|
} else if (isFreeLooking) {
|
||||||
|
|
||||||
stopFreelook();
|
stopFreelook();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startFreelook() {
|
private void startFreelook() {
|
||||||
isFreeLooking = true;
|
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() {
|
private void stopFreelook() {
|
||||||
|
|
||||||
if (was1stPerson) {
|
if (was1stPerson) {
|
||||||
SaturnClient.client.options.setPerspective(Perspective.FIRST_PERSON);
|
minecraft.setFirstPerson();
|
||||||
}
|
}
|
||||||
|
|
||||||
isFreeLooking = false;
|
isFreeLooking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,4 +85,4 @@ public class Freelook extends Module {
|
|||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return enabled.value;
|
return enabled.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,14 @@ import org.saturnclient.modules.mods.*;
|
|||||||
import org.saturnclient.impl.modules.*;
|
import org.saturnclient.impl.modules.*;
|
||||||
|
|
||||||
public class FabricModuleProvider implements ModuleProvider {
|
public class FabricModuleProvider implements ModuleProvider {
|
||||||
public static Module[] MODS = {
|
public static final Module[] MODS = {
|
||||||
new ArmorDisplay(new ArmorDisplayFabric()),
|
new ArmorDisplay(new ArmorDisplayFabric()),
|
||||||
new AutoSprint(new AutoSprintFabric()),
|
new AutoSprint(new AutoSprintFabric()),
|
||||||
new Coordinates(new CoordinatesFabric()),
|
new Coordinates(new CoordinatesFabric()),
|
||||||
new Crosshair(new CrosshairFabric()),
|
new Crosshair(new CrosshairFabric()),
|
||||||
|
new DayCounter(new DayCounterFabric()),
|
||||||
|
new Fps(new FpsFabric()),
|
||||||
|
new Freelook(new FreelookFabric()),
|
||||||
new Clock(),
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user