aboutsummaryrefslogtreecommitdiff
path: root/src/client/java
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-03-17 13:53:59 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-03-17 18:06:17 +0100
commit66856d971b331b3986a17306b9812ac52f0fa3bf (patch)
treef724cee44afde57681e824c5b56c6b6362ad7fcb /src/client/java
parent97be59a7b6b990e8a68b69424904ed465a1faabe (diff)
fix(game): invalid time set
Diffstat (limited to 'src/client/java')
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java55
1 files changed, 31 insertions, 24 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
index b0ef344..79ff436 100644
--- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
+++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
@@ -3,6 +3,7 @@ package world.anhgelus.molehunt.client;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
+import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.player.PlayerModelPart;
import world.anhgelus.molehunt.config.ConfigPayload;
import world.anhgelus.molehunt.game.GamePayload;
@@ -15,30 +16,6 @@ public class MolehuntClient implements ClientModInitializer {
private static boolean GAME_STARTED = false;
- @Override
- public void onInitializeClient() {
- ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> context.client().execute(() -> {
- SHOW_SKINS = payload.showSkins();
- SHOW_NAMETAGS = payload.showNametags();
- SHOW_TAB = payload.showTab();
- }));
- ClientPlayNetworking.registerGlobalReceiver(GamePayload.ID, (payload, context) -> context.client().execute(() -> GAME_STARTED = payload.gameLaunched()));
-
- // Needed because else `client.options` is null
- ClientLifecycleEvents.CLIENT_STARTED.register(client -> {
- var options = client.options;
-
- options.setModelPart(PlayerModelPart.CAPE, true);
- options.setModelPart(PlayerModelPart.HAT, true);
- options.setModelPart(PlayerModelPart.JACKET, true);
- options.setModelPart(PlayerModelPart.LEFT_SLEEVE, true);
- options.setModelPart(PlayerModelPart.RIGHT_SLEEVE, true);
- options.setModelPart(PlayerModelPart.LEFT_PANTS_LEG, true);
- options.setModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true);
- });
-
- }
-
public static boolean showSkins() {
return SHOW_SKINS;
}
@@ -54,4 +31,34 @@ public class MolehuntClient implements ClientModInitializer {
public static boolean gameStarted() {
return GAME_STARTED;
}
+
+ public static void updateClient(Minecraft client) {
+ if (SHOW_SKINS) return;
+ var options = client.options;
+
+ options.setModelPart(PlayerModelPart.CAPE, true);
+ options.setModelPart(PlayerModelPart.HAT, true);
+ options.setModelPart(PlayerModelPart.JACKET, true);
+ options.setModelPart(PlayerModelPart.LEFT_SLEEVE, true);
+ options.setModelPart(PlayerModelPart.RIGHT_SLEEVE, true);
+ options.setModelPart(PlayerModelPart.LEFT_PANTS_LEG, true);
+ options.setModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true);
+ }
+
+ @Override
+ public void onInitializeClient() {
+ ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> {
+ try (final var client = context.client()) {
+ SHOW_SKINS = payload.showSkins();
+ SHOW_NAMETAGS = payload.showNametags();
+ SHOW_TAB = payload.showTab();
+
+ updateClient(client);
+ }
+ });
+ ClientPlayNetworking.registerGlobalReceiver(GamePayload.ID, (payload, context) -> GAME_STARTED = payload.gameLaunched());
+
+ // Needed because else `client.options` is null
+ ClientLifecycleEvents.CLIENT_STARTED.register(MolehuntClient::updateClient);
+ }
}