From 095aa12d0cf8170014f59d1e1646311989aaca58 Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Thu, 19 Mar 2026 14:32:46 +0100 Subject: Copy Molehunt and rename --- .../anhgelus/floodhunt/client/FloodhuntClient.java | 57 ++++++++++++++++++++++ .../client/mixin/NoCustomizableSkinOverlay.java | 18 +++++++ .../floodhunt/client/mixin/NoNametags.java | 24 +++++++++ .../floodhunt/client/mixin/NoPlayerListHud.java | 17 +++++++ .../anhgelus/floodhunt/client/mixin/NoSkin.java | 27 ++++++++++ 5 files changed, 143 insertions(+) create mode 100644 src/client/java/world/anhgelus/floodhunt/client/FloodhuntClient.java create mode 100644 src/client/java/world/anhgelus/floodhunt/client/mixin/NoCustomizableSkinOverlay.java create mode 100644 src/client/java/world/anhgelus/floodhunt/client/mixin/NoNametags.java create mode 100644 src/client/java/world/anhgelus/floodhunt/client/mixin/NoPlayerListHud.java create mode 100644 src/client/java/world/anhgelus/floodhunt/client/mixin/NoSkin.java (limited to 'src/client/java/world/anhgelus') 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 { + @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 cir) { + if (FloodhuntClient.showSkins() || !FloodhuntClient.gameStarted()) return; + cir.setReturnValue(SkinTextures.create( + new AssetInfo.TextureAssetInfo(Identifier.of(Floodhunt.MOD_ID, "skin")), + null, + null, + PlayerSkinType.WIDE + )); + } +} -- cgit v1.2.3