added coords

This commit is contained in:
2026-07-11 19:07:41 +02:00
parent a2d8780238
commit bf0fdb2b98
3 changed files with 32 additions and 3 deletions
@@ -18,6 +18,10 @@ public class QuestsPanel {
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 int tickCounter = 0;
private record QuestData(String title, String description, int requiredPlaytime) {
boolean isUnlocked() {
return PlaytimeTracker.getCurrentPlaytimeSeconds() >= requiredPlaytime;
@@ -134,7 +138,29 @@ public class QuestsPanel {
);
content.child(scrollArea);
return new Handle(playtimeLabel, percentLabel, barFill, barWidth, quests);
Handle handle = new Handle(playtimeLabel, percentLabel, barFill, barWidth, quests);
activeHandle = handle;
return handle;
}
/**
* Call this once per client tick (e.g. from ClientTickEvents.END_CLIENT_TICK)
* to keep the open panel's playtime/progress/quest state live.
* Throttled to once every 20 ticks (~1x/sec) since playtime itself only
* updates that often server-side.
*/
public static void tick() {
if (activeHandle != null && tickCounter++ % 20 == 0) {
activeHandle.refresh();
}
}
/**
* Call this from the screen's onClose() so a closed panel stops being
* refreshed and can be garbage collected.
*/
public static void clearActiveHandle() {
activeHandle = null;
}
private static String formatPlaytime(int seconds) {
@@ -21,6 +21,7 @@ public class CitrusDevClient implements ClientModInitializer {
Module_KeyStrokes.register();
Module_Coords.register();
KeyMapping.Category category = KeyMapping.Category.register(
Identifier.fromNamespaceAndPath("citrus-dev", "general"));
@@ -33,12 +34,14 @@ public class CitrusDevClient implements ClientModInitializer {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (client.player != null && !client.isPaused()) {
PlaytimeTracker.tick();
QuestsPanel.tick();
}
Module_FPS.tick();
Module_KeyStrokes.tick();
Module_Coords.tick();
while (openScreenKey.consumeClick()) {
if (client.player != null && client.player.isShiftKeyDown()) {
String lastModule = Config.get().lastModule;
@@ -22,7 +22,7 @@ public class PlaytimeTracker {
//ticks zu backend schicken
private static final String BACKEND_URL =
"http://127.0.0.1:5000/api/heartbeat";
"http://62.116.42.223:25501/api/heartbeat";
private static final HttpClient HTTP =
HttpClient.newBuilder()
@@ -87,7 +87,7 @@ public class PlaytimeTracker {
//playtime vom server holen
private static final String PLAYTIME_URL =
"http://localhost:5000/api/player/%s/playtime";
"http://62.116.42.223:25501/api/player/%s/playtime";
public static void getPlaytime() {