aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-03-19 14:32:46 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-03-19 14:32:46 +0100
commit095aa12d0cf8170014f59d1e1646311989aaca58 (patch)
tree3af7b4e08aaae82a5bdcf6fbd0bb14b519d1cb27 /src/client
Copy Molehunt and rename
Diffstat (limited to 'src/client')
-rw-r--r--src/client/java/world/anhgelus/floodhunt/client/FloodhuntClient.java57
-rw-r--r--src/client/java/world/anhgelus/floodhunt/client/mixin/NoCustomizableSkinOverlay.java18
-rw-r--r--src/client/java/world/anhgelus/floodhunt/client/mixin/NoNametags.java24
-rw-r--r--src/client/java/world/anhgelus/floodhunt/client/mixin/NoPlayerListHud.java17
-rw-r--r--src/client/java/world/anhgelus/floodhunt/client/mixin/NoSkin.java27
-rw-r--r--src/client/resources/assets/molehunt/lang/en_us.json28
-rw-r--r--src/client/resources/assets/molehunt/lang/fr_fr.json28
-rw-r--r--src/client/resources/assets/molehunt/textures/skin.pngbin0 -> 1347 bytes
-rw-r--r--src/client/resources/floodhunt.client.mixins.json15
9 files changed, 214 insertions, 0 deletions
diff --git a/src/client/java/world/anhgelus/floodhunt/client/FloodhuntClient.java b/src/client/java/world/anhgelus/floodhunt/client/FloodhuntClient.java
new file mode 100644
index 0000000..ab0139e
--- /dev/null
+++ b/src/client/java/world/anhgelus/floodhunt/client/FloodhuntClient.java
@@ -0,0 +1,57 @@
+package world.anhgelus.floodhunt.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.entity.player.PlayerModelPart;
+import world.anhgelus.floodhunt.config.ConfigPayload;
+import world.anhgelus.floodhunt.game.GamePayload;
+
+public class FloodhuntClient implements ClientModInitializer {
+
+ private static boolean SHOW_SKINS = false;
+ private static boolean SHOW_NAMETAGS = false;
+ private static boolean SHOW_TAB = false;
+
+ private static boolean GAME_STARTED = false;
+
+ public static boolean showSkins() {
+ return SHOW_SKINS;
+ }
+
+ public static boolean showNameTags() {
+ return SHOW_NAMETAGS;
+ }
+
+ public static boolean showTab() {
+ return SHOW_TAB;
+ }
+
+ public static boolean gameStarted() {
+ return GAME_STARTED;
+ }
+
+ @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.setPlayerModelPart(PlayerModelPart.CAPE, true);
+ options.setPlayerModelPart(PlayerModelPart.HAT, true);
+ options.setPlayerModelPart(PlayerModelPart.JACKET, true);
+ options.setPlayerModelPart(PlayerModelPart.LEFT_SLEEVE, true);
+ options.setPlayerModelPart(PlayerModelPart.RIGHT_SLEEVE, true);
+ options.setPlayerModelPart(PlayerModelPart.LEFT_PANTS_LEG, true);
+ options.setPlayerModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true);
+ });
+
+ }
+}
diff --git a/src/client/java/world/anhgelus/floodhunt/client/mixin/NoCustomizableSkinOverlay.java b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoCustomizableSkinOverlay.java
new file mode 100644
index 0000000..7220308
--- /dev/null
+++ b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoCustomizableSkinOverlay.java
@@ -0,0 +1,18 @@
+package world.anhgelus.floodhunt.client.mixin;
+
+import net.minecraft.client.option.GameOptions;
+import net.minecraft.entity.player.PlayerModelPart;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import world.anhgelus.floodhunt.client.FloodhuntClient;
+
+@Mixin(GameOptions.class)
+public abstract class NoCustomizableSkinOverlay {
+ @Inject(at = @At("HEAD"), method = "setPlayerModelPart", cancellable = true)
+ public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) {
+ if (FloodhuntClient.showSkins()) return;
+ ci.cancel();
+ }
+}
diff --git a/src/client/java/world/anhgelus/floodhunt/client/mixin/NoNametags.java b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoNametags.java
new file mode 100644
index 0000000..ca75fd8
--- /dev/null
+++ b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoNametags.java
@@ -0,0 +1,24 @@
+package world.anhgelus.floodhunt.client.mixin;
+
+import net.minecraft.client.render.command.OrderedRenderCommandQueue;
+import net.minecraft.client.render.entity.EntityRenderer;
+import net.minecraft.client.render.entity.state.EntityRenderState;
+import net.minecraft.client.render.state.CameraRenderState;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityType;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import world.anhgelus.floodhunt.client.FloodhuntClient;
+
+@Mixin(EntityRenderer.class)
+public class NoNametags<T extends Entity, S extends EntityRenderState> {
+ @Inject(at = @At("HEAD"), method = "render", cancellable = true)
+ private void renderLabelOrNot(S state, MatrixStack matrices, OrderedRenderCommandQueue queue, CameraRenderState cameraState, CallbackInfo ci) {
+ if (EntityType.PLAYER != state.entityType || FloodhuntClient.showNameTags() || !FloodhuntClient.gameStarted())
+ return;
+ ci.cancel();
+ }
+}
diff --git a/src/client/java/world/anhgelus/floodhunt/client/mixin/NoPlayerListHud.java b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoPlayerListHud.java
new file mode 100644
index 0000000..aa2f886
--- /dev/null
+++ b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoPlayerListHud.java
@@ -0,0 +1,17 @@
+package world.anhgelus.floodhunt.client.mixin;
+
+import net.minecraft.client.gui.hud.PlayerListHud;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import world.anhgelus.floodhunt.client.FloodhuntClient;
+
+@Mixin(PlayerListHud.class)
+public class NoPlayerListHud {
+ @Inject(at = @At("HEAD"), method = "render", cancellable = true)
+ public void render(CallbackInfo ci) {
+ if (FloodhuntClient.showTab() || !FloodhuntClient.gameStarted()) return;
+ ci.cancel();
+ }
+}
diff --git a/src/client/java/world/anhgelus/floodhunt/client/mixin/NoSkin.java b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoSkin.java
new file mode 100644
index 0000000..22d2337
--- /dev/null
+++ b/src/client/java/world/anhgelus/floodhunt/client/mixin/NoSkin.java
@@ -0,0 +1,27 @@
+package world.anhgelus.floodhunt.client.mixin;
+
+import net.minecraft.client.network.AbstractClientPlayerEntity;
+import net.minecraft.entity.player.PlayerSkinType;
+import net.minecraft.entity.player.SkinTextures;
+import net.minecraft.util.AssetInfo;
+import net.minecraft.util.Identifier;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import world.anhgelus.floodhunt.Floodhunt;
+import world.anhgelus.floodhunt.client.FloodhuntClient;
+
+@Mixin(AbstractClientPlayerEntity.class)
+public class NoSkin {
+ @Inject(at = @At("HEAD"), method = "getSkin", cancellable = true)
+ public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
+ if (FloodhuntClient.showSkins() || !FloodhuntClient.gameStarted()) return;
+ cir.setReturnValue(SkinTextures.create(
+ new AssetInfo.TextureAssetInfo(Identifier.of(Floodhunt.MOD_ID, "skin")),
+ null,
+ null,
+ PlayerSkinType.WIDE
+ ));
+ }
+}
diff --git a/src/client/resources/assets/molehunt/lang/en_us.json b/src/client/resources/assets/molehunt/lang/en_us.json
new file mode 100644
index 0000000..8d4bb70
--- /dev/null
+++ b/src/client/resources/assets/molehunt/lang/en_us.json
@@ -0,0 +1,28 @@
+{
+ "commands.floodhunt.error.game_not_started": "The Floodhunt game has not been started yet.",
+ "commands.floodhunt.timer.show": "Showing Floodhunt timer.",
+ "commands.floodhunt.timer.hide": "Hiding Floodhunt timer.",
+ "commands.floodhunt.role.mole": "§cYou are a Mole.\nKill all the survivors before the timer runs out.",
+ "commands.floodhunt.role.mole.list": "§eThe moles are: %s",
+ "commands.floodhunt.role.survivor": "§aYou are not the Mole. \nSurvive until the timer runs out, and try to discover who's the Mole.",
+ "commands.floodhunt.role.survivor.mole_count": "§eThere are %d §emoles among you.",
+ "commands.floodhunt.stop.success": "The Floodhunt game has been stopped.",
+ "floodhunt.game.end.suspense.title": "§eAnd the winners are...",
+ "floodhunt.game.end.winners.moles.title": "§cThe Moles!",
+ "floodhunt.game.end.winners.survivors.title": "§aNot the Moles!",
+ "floodhunt.game.end.winners.subtitle": "§6The Moles were %s",
+ "floodhunt.game.start.suspense": "§eYou are...",
+ "floodhunt.game.start.mole.title": "§cThe Mole!",
+ "floodhunt.game.start.mole.subtitle": "§eGet the list of moles with §6/floodhunt role§e.",
+ "floodhunt.game.start.survivor.title": "§aNot the Mole!",
+ "floodhunt.game.start.survivor.subtitle": "§eTry to survive and find out who's the mole!",
+ "gamerule.floodhunt:gameDuration": "Floodhunt: Duration of a game",
+ "gamerule.floodhunt:molePercentage": "Floodhunt: Percentage of Mole",
+ "gamerule.floodhunt:moleCount": "Floodhunt: Number of Mole",
+ "gamerule.floodhunt:showNametags": "Floodhunt: Show players' nametag",
+ "gamerule.floodhunt:showTab": "Floodhunt: Enable the tab",
+ "gamerule.floodhunt:showSkins": "Floodhunt: Show players' skin",
+ "gamerule.floodhunt:initialWorldSize": "Floodhunt: Initial world size",
+ "gamerule.floodhunt:finalWorldSize": "Floodhunt: Final world size",
+ "gamerule.floodhunt:borderMovingStartingTimeOffsetMinutes": "Floodhunt: Time before moving the borders"
+}
diff --git a/src/client/resources/assets/molehunt/lang/fr_fr.json b/src/client/resources/assets/molehunt/lang/fr_fr.json
new file mode 100644
index 0000000..77e8640
--- /dev/null
+++ b/src/client/resources/assets/molehunt/lang/fr_fr.json
@@ -0,0 +1,28 @@
+{
+ "commands.floodhunt.error.game_not_started": "La partie de Floodhunt n'a pas encore commencé.",
+ "commands.floodhunt.timer.show": "Le timer est maintenant affiché.",
+ "commands.floodhunt.timer.hide": "Le timer est maintenant caché.",
+ "commands.floodhunt.role.mole": "§cVous êtes une taupe.\nTuez tous les survivants avant la fin de la partie..",
+ "commands.floodhunt.role.mole.list": "§eLes taupes sont : %s",
+ "commands.floodhunt.role.survivor": "§aVous n'êtes pas la taupe. \nSurvivez jusqu'à la fin, et découvrez qui sont les moles.",
+ "commands.floodhunt.role.survivor.mole_count": "§eIl y a %d §etaupes parmi vous.",
+ "commands.floodhunt.stop.success": "La partie de Floodhunt a été arrêtée.",
+ "floodhunt.game.end.suspense.title": "§eEt les gagnants sont...",
+ "floodhunt.game.end.winners.moles.title": "§cLes Taupes !",
+ "floodhunt.game.end.winners.survivors.title": "§aPas les Taupes !",
+ "floodhunt.game.end.winners.subtitle": "§Les Taupes sont",
+ "floodhunt.game.start.suspense": "§eVous êtes...",
+ "floodhunt.game.start.mole.title": "§cLa Taupe !",
+ "floodhunt.game.start.mole.subtitle": "§eRécupérer la liste des taupes avec §6/floodhunt moles",
+ "floodhunt.game.start.survivor.title": "§aPas la taupe!",
+ "floodhunt.game.start.survivor.subtitle": "§eEssaye de survivre et de trouver qui est la taupe !",
+ "gamerule.floodhunt:gameDuration": "Floodhunt : Durée d'une partie",
+ "gamerule.floodhunt:molePercentage": "Floodhunt : Pourcentage de Taupes",
+ "gamerule.floodhunt:moleCount": "Floodhunt : Nombre de Taupes",
+ "gamerule.floodhunt:showNametags": "Floodhunt : Affiche les nametags des joueurs",
+ "gamerule.floodhunt:showTab": "Floodhunt : Active la liste des joueurs",
+ "gamerule.floodhunt:showSkins": "Floodhunt : Affiche les skins des joueurs",
+ "gamerule.floodhunt:initialWorldSize": "Floodhunt : Taille initiale du monde",
+ "gamerule.floodhunt:finalWorldSize": "Floodhunt : Taille finale du monde",
+ "gamerule.floodhunt:borderMovingStartingTimeOffsetMinutes": "Floodhunt : Temps avant de bouger les bordures du monde"
+}
diff --git a/src/client/resources/assets/molehunt/textures/skin.png b/src/client/resources/assets/molehunt/textures/skin.png
new file mode 100644
index 0000000..c1f728e
--- /dev/null
+++ b/src/client/resources/assets/molehunt/textures/skin.png
Binary files differ
diff --git a/src/client/resources/floodhunt.client.mixins.json b/src/client/resources/floodhunt.client.mixins.json
new file mode 100644
index 0000000..f14542e
--- /dev/null
+++ b/src/client/resources/floodhunt.client.mixins.json
@@ -0,0 +1,15 @@
+{
+ "required": true,
+ "minVersion": "0.8",
+ "package": "world.anhgelus.floodhunt.client.mixin",
+ "compatibilityLevel": "JAVA_21",
+ "client": [
+ "NoCustomizableSkinOverlay",
+ "NoNametags",
+ "NoPlayerListHud",
+ "NoSkin"
+ ],
+ "injectors": {
+ "defaultRequire": 1
+ }
+}