From 7f6043a230b83cff57126625cd8b19063c85a599 Mon Sep 17 00:00:00 2001 From: anhgelus Date: Fri, 23 Aug 2024 13:41:22 +0000 Subject: feat(config): packet sending config to client --- .../anhgelus/molehunt/client/MolehuntClient.java | 35 ++++++++++++++++------ .../anhgelus/molehunt/client/mixin/NoSkin.java | 4 +-- 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'src/client/java') diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index e6de219..5f6b735 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -1,20 +1,37 @@ package world.anhgelus.molehunt.client; -import com.mojang.authlib.GameProfile; import net.fabricmc.api.ClientModInitializer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.UUID; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; +import world.anhgelus.molehunt.config.ConfigPayload; public class MolehuntClient implements ClientModInitializer { - public static final String MOD_ID = "molehunt"; - public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - - public final static GameProfile ANONYMOUS_PROFILE = new GameProfile(UUID.fromString("015f3266-4e0a-412e-9b80-1ca76af79453"), "Molehunt"); + private static boolean SHOW_SKINS = false; + private static boolean SHOW_NAMETAGS = false; + private static boolean SHOW_TAB = false; @Override public void onInitializeClient() { + ClientPlayNetworking.registerGlobalReceiver(ConfigPayload.ID, (payload, context) -> { + try (final var client = context.client()) { + client.execute(() -> { + SHOW_SKINS = payload.showSkins(); + SHOW_NAMETAGS = payload.showNametag(); + SHOW_TAB = payload.showNametag(); + }); + } + }); + } + + public static boolean showSkins() { + return SHOW_SKINS; + } + + public static boolean showNameTags() { + return SHOW_NAMETAGS; + } + + public static boolean showTab() { + return SHOW_TAB; } } diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java index edbfd15..425ded7 100644 --- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java @@ -7,14 +7,14 @@ 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.molehunt.client.MolehuntClient; +import world.anhgelus.molehunt.Molehunt; @Mixin(AbstractClientPlayerEntity.class) public class NoSkin { @Inject(at = @At("HEAD"), method = "getSkinTextures", cancellable = true) public void getSkin(CallbackInfoReturnable cir) { cir.setReturnValue(new SkinTextures( - Identifier.of(MolehuntClient.MOD_ID, "textures/skin.png"), + Identifier.of(Molehunt.MOD_ID, "textures/skin.png"), null, null, null, -- cgit v1.2.3