aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/world/anhgelus
diff options
context:
space:
mode:
authorLéo Kosman <leo.kosman@proton.me>2024-08-31 22:44:07 +0200
committerLéo Kosman <leo.kosman@proton.me>2024-08-31 22:44:07 +0200
commitfdb9a0174c22499f545a0426d6d72148cf76411c (patch)
tree762f55dbd84d485fae87721456a8d23c56817135 /src/client/java/world/anhgelus
parent4394282521ae35c0b4a565f3d05bafe6f6c6f0fb (diff)
feat: no no skin overlay
Diffstat (limited to 'src/client/java/world/anhgelus')
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java32
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoCustomizableSkinOverlay.java26
2 files changed, 47 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();
+ }
+ }
+}