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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
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.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());
|
||||
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnabled(boolean e) {
|
||||
enabled.value = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModDimensions getDimensions() {
|
||||
return dimensions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.saturnclient.modules.mods;
|
||||
|
||||
import org.saturnclient.modules.Module;
|
||||
import org.saturnclient.modules.ModuleDetails;
|
||||
import org.saturnclient.modules.interfaces.FreelookInterface;
|
||||
import org.saturnclient.config.manager.Key;
|
||||
import org.saturnclient.config.manager.Property;
|
||||
|
||||
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(Key.GLFW_KEY_H);
|
||||
|
||||
public static boolean isFreeLooking = false;
|
||||
private static boolean was1stPerson = false;
|
||||
|
||||
private final FreelookInterface minecraft;
|
||||
|
||||
public Freelook(FreelookInterface minecraft) {
|
||||
super(
|
||||
new ModuleDetails("Freelook", "freelook")
|
||||
.description("Allows you to look around freely without moving your character")
|
||||
.tags("Movement", "Camera")
|
||||
.version("0.1.0"),
|
||||
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 = minecraft.isFirstPerson();
|
||||
|
||||
minecraft.setThirdPersonBack();
|
||||
}
|
||||
|
||||
private void stopFreelook() {
|
||||
|
||||
if (was1stPerson) {
|
||||
minecraft.setFirstPerson();
|
||||
}
|
||||
|
||||
isFreeLooking = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnabled(boolean e) {
|
||||
enabled.value = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled.value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user