auto Sprint and Clock

This commit is contained in:
2026-03-06 23:36:58 +01:00
parent 081bf9bfef
commit 991d9775f2
3 changed files with 152 additions and 0 deletions
@@ -0,0 +1,20 @@
package org.saturnclient.modules.interfaces;
public interface AutoSprintInterface {
boolean hasPlayer();
boolean hasNetwork();
boolean isForwardPressed();
boolean isBackPressed();
boolean isSneaking();
boolean hasHorizontalCollision();
boolean isUsingItem();
void setSprinting(boolean sprinting);
}
@@ -0,0 +1,50 @@
package org.saturnclient.modules.mods;
import org.saturnclient.modules.Module;
import org.saturnclient.modules.ModuleDetails;
import org.saturnclient.modules.interfaces.AutoSprintInterface;
import org.saturnclient.config.manager.Property;
public class AutoSprint extends Module {
private static Property<Boolean> enabled = Property.bool(false);
private final AutoSprintInterface minecraft;
public AutoSprint(AutoSprintInterface minecraft) {
super(
new ModuleDetails("Auto Sprint", "sprint")
.description("Makes the player always sprint")
.tags("Movement")
.version("v0.1.0"),
enabled.named("Enabled"));
this.minecraft = minecraft;
}
@Override
public void tick() {
if (!minecraft.hasPlayer() || !minecraft.hasNetwork()) {
return;
}
if (minecraft.isForwardPressed()
&& !minecraft.isBackPressed()
&& !minecraft.isSneaking()
&& !minecraft.hasHorizontalCollision()
&& !minecraft.isUsingItem()) {
minecraft.setSprinting(true);
}
}
@Override
public boolean isEnabled() {
return enabled.value;
}
@Override
public void onEnabled(boolean e) {
enabled.value = e;
}
}
@@ -0,0 +1,82 @@
package org.saturnclient.modules.mods;
import java.time.format.DateTimeFormatter;
import java.time.LocalTime;
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 Clock extends Module implements HudMod {
private static Property<Boolean> enabled = Property.bool(false);
private static Property<Integer> format = Property.select(0, "24 hour", "12 hour");
private static Property<Boolean> seconds = Property.bool(false);
private static ModDimensions dimensions = new ModDimensions(60, Fonts.getHeight());
public Clock() {
super(new ModuleDetails("Clock", "clock")
.description("Displays the current real-world time")
.version("v0.1.0")
.tags("Utility"),
enabled.named("Enabled"),
format.named("Format"),
seconds.named("Show seconds"),
dimensions.prop());
}
@Override
public void renderDummy(RenderScope scope) {
renderClock(scope);
}
@Override
public void renderHud(RenderScope scope) {
renderClock(scope);
}
public void renderClock(RenderScope scope) {
String text = "";
LocalTime currentTime = LocalTime.now();
switch (format.value) {
case 0:
if (seconds.value) {
text = currentTime.format(DateTimeFormatter.ofPattern("HH:mm:ss"));
} else {
text = currentTime.format(DateTimeFormatter.ofPattern("HH:mm"));
}
break;
case 1:
if (seconds.value) {
text = currentTime.format(DateTimeFormatter.ofPattern("hh:mm:ss a"));
} else {
text = currentTime.format(DateTimeFormatter.ofPattern("hh:mm a"));
}
break;
}
scope.drawText(text,
0, 0, dimensions.font.value, dimensions.fgColor.value);
dimensions.width = Fonts.getWidth(text, dimensions.font.value);
dimensions.height = 18 * text.split("\n").length;
}
@Override
public boolean isEnabled() {
return enabled.value;
}
@Override
public ModDimensions getDimensions() {
return dimensions;
}
@Override
public void onEnabled(boolean e) {
enabled.value = e;
}
}