diff options
3 files changed, 48 insertions, 11 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index c8a4d95..75c927e 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -1,7 +1,9 @@ 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.entity.player.PlayerModelPart; import world.anhgelus.molehunt.config.ConfigPayload; import world.anhgelus.molehunt.game.GamePayload; @@ -15,18 +17,26 @@ public class MolehuntClient implements ClientModInitializer { @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(); - }); + 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.togglePlayerModelPart(PlayerModelPart.CAPE, true); + options.togglePlayerModelPart(PlayerModelPart.HAT, true); + options.togglePlayerModelPart(PlayerModelPart.JACKET, true); + options.togglePlayerModelPart(PlayerModelPart.LEFT_SLEEVE, true); + options.togglePlayerModelPart(PlayerModelPart.RIGHT_SLEEVE, true); + options.togglePlayerModelPart(PlayerModelPart.LEFT_PANTS_LEG, true); + options.togglePlayerModelPart(PlayerModelPart.RIGHT_PANTS_LEG, true); }); + } public static boolean showSkins() { diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java new file mode 100644 index 0000000..ff01075 --- /dev/null +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java @@ -0,0 +1,26 @@ +package world.anhgelus.molehunt.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.Shadow; +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.molehunt.client.MolehuntClient; + +@Mixin(GameOptions.class) +public abstract class NoCustomizableSkinOverlay { + @Shadow + private void setPlayerModelPart(PlayerModelPart part, boolean enabled) {} + + @Inject(at = @At("HEAD"), method = "togglePlayerModelPart", cancellable = true) + public void togglePlayerModelPart(PlayerModelPart part, boolean enabled, CallbackInfo ci) { + if (MolehuntClient.showSkins() && MolehuntClient.gameStarted()) { + setPlayerModelPart(part, true); + ((GameOptions) (Object) this).sendClientSettings(); + + ci.cancel(); + } + } +} diff --git a/src/client/resources/molehunt.client.mixins.json b/src/client/resources/molehunt.client.mixins.json index 2451258..7b9c0f4 100644 --- a/src/client/resources/molehunt.client.mixins.json +++ b/src/client/resources/molehunt.client.mixins.json @@ -4,6 +4,7 @@ "package": "world.anhgelus.molehunt.client.mixin", "compatibilityLevel": "JAVA_21", "client": [ + "NoCustomizableSkinOverlay", "NoNametags", "NoPlayerListHud", "NoSkin" |
