This commit is contained in:
Patrick
2026-07-11 20:30:17 +02:00
parent 608760dc09
commit ab8797dd76
13 changed files with 20 additions and 113 deletions
@@ -30,9 +30,7 @@ public class Config {
public boolean coordsEnabled = true; public boolean coordsEnabled = true;
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static final Path PATH = FabricLoader.getInstance() private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("citrus-dev.json");
.getConfigDir()
.resolve("citrus-dev.json");
private static Config instance; private static Config instance;
public int fpsP = 4; public int fpsP = 4;
@@ -22,7 +22,6 @@ public class Module_Coords {
private static final Config CONFIG = Config.get(); private static final Config CONFIG = Config.get();
// Loaded from Config instead of hardcoded, so the toggle survives a restart.
static boolean toggle = CONFIG.coordsEnabled; static boolean toggle = CONFIG.coordsEnabled;
private static boolean shown = false; private static boolean shown = false;
@@ -18,7 +18,6 @@ public class Module_FPS {
private static final Config CONFIG = Config.get(); private static final Config CONFIG = Config.get();
// Loaded from Config instead of hardcoded, so the toggle survives a restart.
static boolean toggle = CONFIG.fpsEnabled; static boolean toggle = CONFIG.fpsEnabled;
private static boolean shown = false; private static boolean shown = false;
@@ -23,11 +23,10 @@ public class Module_KeyStrokes {
private static FlowLayout bottomRow; private static FlowLayout bottomRow;
private static FlowLayout wBox, aBox, sBox, dBox; private static FlowLayout wBox, aBox, sBox, dBox;
private static ScalableLabel wLabel, aLabel, sLabel, dLabel; // was LabelComponent private static ScalableLabel wLabel, aLabel, sLabel, dLabel;
private static final Config CONFIG = Config.get(); private static final Config CONFIG = Config.get();
// Loaded from Config instead of hardcoded, so the toggle survives a restart.
static boolean toggle = CONFIG.keyEnabled; static boolean toggle = CONFIG.keyEnabled;
private static boolean shown = false; private static boolean shown = false;
@@ -48,7 +47,7 @@ public class Module_KeyStrokes {
private static final Surface GLASS_PANEL = Surface.blur(5f, 15f) private static final Surface GLASS_PANEL = Surface.blur(5f, 15f)
.and(Surface.flat(0x40FFFFFF)); .and(Surface.flat(0x40FFFFFF));
private static int keySize = 16; // was: private static final int KEY_SIZE = 16; private static int keySize = 16;
private static FlowLayout leftSpacer, rightSpacer; private static FlowLayout leftSpacer, rightSpacer;
private static final int PRESSED_COLOR = 0x70FFFFFF; private static final int PRESSED_COLOR = 0x70FFFFFF;
private static final int IDLE_COLOR = 0x40FFFFFF; private static final int IDLE_COLOR = 0x40FFFFFF;
@@ -118,7 +117,7 @@ public class Module_KeyStrokes {
} }
private static float labelScaleFor(int size) { private static float labelScaleFor(int size) {
return size / 16f; // 16px box = 1.0x scale (matches the default keySize) return size / 16f;
} }
public static void setKeySize(int size) { public static void setKeySize(int size) {
@@ -144,8 +143,7 @@ public class Module_KeyStrokes {
if (keyContainer == null) return; if (keyContainer == null) return;
if (toggle && !shown) { if (toggle && !shown) {
keyContainer.clearChildren(); // <-- safety net against duplicate adds keyContainer.clearChildren();
// keyContainer.surface(GLASS_PANEL);
keyContainer.padding(Insets.of(4)); keyContainer.padding(Insets.of(4));
keyContainer.child(topRow); keyContainer.child(topRow);
keyContainer.child(bottomRow); keyContainer.child(bottomRow);
@@ -1,23 +0,0 @@
package de.fullrisk.citrusDev.UI;
import io.wispforest.owo.ui.base.BaseOwoScreen;
import io.wispforest.owo.ui.component.UIComponents;
import io.wispforest.owo.ui.container.FlowLayout;
import io.wispforest.owo.ui.container.UIContainers;
import io.wispforest.owo.ui.core.HorizontalAlignment;
import io.wispforest.owo.ui.core.OwoUIAdapter;
import io.wispforest.owo.ui.core.VerticalAlignment;
import net.minecraft.network.chat.Component;
import io.wispforest.owo.ui.core.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.network.chat.FontDescription;
import net.minecraft.resources.Identifier;
import net.minecraft.sounds.SoundEvents;
import de.fullrisk.citrusDev.UIHelper.ScalableLabel;
import de.fullrisk.citrusDev.UIHelper.ScalableButton;
import de.fullrisk.citrusDev.UIHelper.ScaleValue;
public class OverviewScreen{
}
@@ -18,7 +18,6 @@ public class QuestsPanel {
private static final int ACCENT = 0x64de4b; private static final int ACCENT = 0x64de4b;
// holds the currently open panel's Handle (if any) so tick() can refresh it
private static Handle activeHandle; private static Handle activeHandle;
private static int tickCounter = 0; private static int tickCounter = 0;
@@ -43,8 +42,6 @@ public class QuestsPanel {
this.barWidth = barWidth; this.barWidth = barWidth;
this.quests = quests; this.quests = quests;
// seed with whatever's already unlocked on open, so we don't spam
// toasts for quests the player unlocked before opening this screen
for (QuestData quest : quests) { for (QuestData quest : quests) {
if (quest.isUnlocked()) { if (quest.isUnlocked()) {
notifiedTitles.add(quest.title()); notifiedTitles.add(quest.title());
@@ -74,7 +74,6 @@ public class CitrusToast implements Toast {
int w = WIDTH; int w = WIDTH;
int h = HEIGHT; int h = HEIGHT;
// glass background, matching GLASS_PANEL style
owo.fill(RenderPipelines.GUI, x, y, x + w, y + h, 0x40FFFFFF); owo.fill(RenderPipelines.GUI, x, y, x + w, y + h, 0x40FFFFFF);
owo.drawRectOutline(RenderPipelines.GUI, x, y, w, h, 0x64de4b); owo.drawRectOutline(RenderPipelines.GUI, x, y, w, h, 0x64de4b);
@@ -13,7 +13,6 @@ import net.minecraft.sounds.SoundEvents;
public class ModuleRow { public class ModuleRow {
/** Bridge to whatever boolean field actually holds the module's on/off state. */
public interface ToggleState { public interface ToggleState {
boolean get(); boolean get();
void set(boolean value); void set(boolean value);
@@ -104,7 +104,6 @@ public class SettingsControls {
return button; return button;
} }
// keep the old call sites compiling; defaults to index 0
public static FlowLayout makeCyclingButton(Surface baseSurface, List<ButtonState> states) { public static FlowLayout makeCyclingButton(Surface baseSurface, List<ButtonState> states) {
return makeCyclingButton(baseSurface, states, 0); return makeCyclingButton(baseSurface, states, 0);
} }
@@ -48,9 +48,9 @@ public class CitrusDevClient implements ClientModInitializer {
while (openScreenKey.consumeClick()) { while (openScreenKey.consumeClick()) {
if (client.player != null && client.player.isShiftKeyDown()) { if (client.player != null && client.player.isShiftKeyDown()) {
String lastModule = Config.get().lastModule; String lastModule = Config.get().lastModule;
client.setScreen(new MyScreen(lastModule)); // sneak + RShift: last module client.setScreen(new MyScreen(lastModule));
} else { } else {
client.setScreen(new MyScreen(null)); // RShift alone: general tab client.setScreen(new MyScreen(null));
} }
} }
@@ -1,10 +1,3 @@
// PLACE THIS FILE AT:
// src/client/java/de/fullrisk/citrusDev/client/PlaytimeTracker.java
//
// NOT under src/main/java — MinecraftClient and client.player only exist
// on the client source set. That is the actual cause of the
// "Cannot resolve symbol" errors, not a mistake in this code.
package de.fullrisk.citrusDev.client; package de.fullrisk.citrusDev.client;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -19,15 +12,9 @@ import com.google.gson.JsonParser;
public class PlaytimeTracker { public class PlaytimeTracker {
//ticks zu backend schicken private static final String BACKEND_URL = "http://62.116.42.223:25501/api/heartbeat";
private static final String BACKEND_URL = private static final HttpClient HTTP = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
"http://62.116.42.223:25501/api/heartbeat";
private static final HttpClient HTTP =
HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();
private static int ticks = 0; private static int ticks = 0;
private static int currentPlaytimeSeconds = 0; private static int currentPlaytimeSeconds = 0;
@@ -42,16 +29,14 @@ public class PlaytimeTracker {
if (ticks >= 60) { if (ticks >= 60) {
ticks = 0; ticks = 0;
sendHeartbeat(); sendHeartbeat();
getPlaytime(); // <-- add this getPlaytime();
} }
} }
private static void sendHeartbeat() { private static void sendHeartbeat() {
Verifier.sendTokenForVerification(); Verifier.sendTokenForVerification();
Minecraft client = Minecraft client = Minecraft.getInstance();
Minecraft.getInstance();
if (client.player == null) { if (client.player == null) {
System.out.println("No player yet"); System.out.println("No player yet");
@@ -86,15 +71,9 @@ public class PlaytimeTracker {
} }
private static final String PLAYTIME_URL = "http://62.116.42.223:25501/api/player/%s/playtime";
//playtime vom server holen
private static final String PLAYTIME_URL =
"http://62.116.42.223:25501/api/player/%s/playtime";
public static void getPlaytime() { public static void getPlaytime() {
Minecraft client = Minecraft.getInstance(); Minecraft client = Minecraft.getInstance();
if (client.player == null) { if (client.player == null) {
@@ -103,57 +82,24 @@ public class PlaytimeTracker {
UUID uuid = client.player.getUUID(); UUID uuid = client.player.getUUID();
HttpRequest request = HttpRequest.newBuilder() HttpRequest request = HttpRequest.newBuilder().uri(URI.create(PLAYTIME_URL.formatted(uuid)))
.uri(URI.create(
PLAYTIME_URL.formatted(uuid)
))
.GET() .GET()
.build(); .build();
HTTP.sendAsync( HTTP.sendAsync(request, HttpResponse.BodyHandlers.ofString())
request,
HttpResponse.BodyHandlers.ofString()
)
.thenAccept(response -> { .thenAccept(response -> {
if (response.statusCode() == 200) { if (response.statusCode() == 200) {
String json = response.body(); String json = response.body();
JsonObject data = JsonObject data = JsonParser.parseString(json).getAsJsonObject();
JsonParser.parseString(json)
.getAsJsonObject();
currentPlaytimeSeconds = data.get("playtime_seconds").getAsInt();
currentPlaytimeSeconds =
data.get("playtime_seconds")
.getAsInt();
// Compare playtime here
if (currentPlaytimeSeconds >= 3600) {
System.out.println(
"Player has more than 1 hour!"
);
}
else {
System.out.println(
"Player needs more time"
);
}
System.out.println(
"Seconds played: " + currentPlaytimeSeconds
);
} else { } else {
System.out.println( System.err.println("Failed: " + response.statusCode());
"Failed: " + response.statusCode() throw new RuntimeException("Failed to get playtime: " + response.statusCode());
);
} }
}); });
} }
@@ -10,9 +10,7 @@ public class Verifier {
private static final String VERIFY_URL = "http://62.116.42.223:25501/api/verify"; private static final String VERIFY_URL = "http://62.116.42.223:25501/api/verify";
private static final HttpClient HTTP = HttpClient.newBuilder() private static final HttpClient HTTP = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
.connectTimeout(Duration.ofSeconds(10))
.build();
public static void sendTokenForVerification() { public static void sendTokenForVerification() {
String accessToken = Authentication.getAccessToken(); String accessToken = Authentication.getAccessToken();
@@ -27,10 +27,8 @@ public abstract class SliderComponentMixin {
OwoUIGraphics owo = OwoUIGraphics.of(graphics); OwoUIGraphics owo = OwoUIGraphics.of(graphics);
// glass track
owo.fill(RenderPipelines.GUI, x, y, x + w, y + h, 0x40FFFFFF); owo.fill(RenderPipelines.GUI, x, y, x + w, y + h, 0x40FFFFFF);
// handle
int handleWidth = 4; int handleWidth = 4;
int handleX = x + (int) (slider.value() * (w - handleWidth)); int handleX = x + (int) (slider.value() * (w - handleWidth));
owo.fill(RenderPipelines.GUI, handleX, y, handleX + handleWidth, y + h, 0xFFFFFFFF); owo.fill(RenderPipelines.GUI, handleX, y, handleX + handleWidth, y + h, 0xFFFFFFFF);