aboutsummaryrefslogtreecommitdiff
path: root/src/client/java/world/anhgelus
diff options
context:
space:
mode:
authorLéo Kosman <leo.kosman@proton.me>2024-08-24 12:55:01 +0200
committerGitHub <noreply@github.com>2024-08-24 12:55:01 +0200
commit34dc864a495699f1311651c92111884653b42806 (patch)
treefcfe59c6d292f4c52d3c81cd51dd019b0e72b388 /src/client/java/world/anhgelus
parent1973cd58deb902e6df6a152b38e6585a0bf61a5e (diff)
parentd1d56e097d1aaa90358069370f454e65fc9dbbd5 (diff)
Merge pull request #4 from anhgelus/feat/config
[Feat] Config file
Diffstat (limited to 'src/client/java/world/anhgelus')
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java33
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java3
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java2
-rw-r--r--src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java12
4 files changed, 35 insertions, 15 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
index e6de219..1f92573 100644
--- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
+++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java
@@ -1,20 +1,35 @@
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) -> {
+ context.client().execute(() -> {
+ SHOW_SKINS = payload.showSkins();
+ SHOW_NAMETAGS = payload.showNametags();
+ SHOW_TAB = payload.showTab();
+ });
+ });
+ }
+
+ 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/NoNametags.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java
index 7996c49..3482abb 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java
@@ -9,12 +9,13 @@ 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.molehunt.client.MolehuntClient;
@Mixin(EntityRenderer.class)
public class NoNametags<T extends Entity> {
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
private void renderLabelOrNot(T entity, float yaw, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
- if (!(entity instanceof PlayerEntity)) return;
+ if (!(entity instanceof PlayerEntity) || MolehuntClient.showNameTags()) return;
ci.cancel();
}
} \ No newline at end of file
diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java
index 8ef33fd..00308ea 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoPlayerListHud.java
@@ -5,11 +5,13 @@ 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.molehunt.client.MolehuntClient;
@Mixin(PlayerListHud.class)
public class NoPlayerListHud {
@Inject(at = @At("HEAD"), method = "render", cancellable = true)
public void render(CallbackInfo ci) {
+ if (MolehuntClient.showTab()) return;
ci.cancel();
}
}
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..775d789 100644
--- a/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java
+++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoSkin.java
@@ -7,18 +7,20 @@ 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.Molehunt;
import world.anhgelus.molehunt.client.MolehuntClient;
@Mixin(AbstractClientPlayerEntity.class)
public class NoSkin {
@Inject(at = @At("HEAD"), method = "getSkinTextures", cancellable = true)
public void getSkin(CallbackInfoReturnable<SkinTextures> cir) {
+ if (MolehuntClient.showSkins()) return;
cir.setReturnValue(new SkinTextures(
- Identifier.of(MolehuntClient.MOD_ID, "textures/skin.png"),
- null,
- null,
- null,
- SkinTextures.Model.WIDE, true)
+ Identifier.of(Molehunt.MOD_ID, "textures/skin.png"),
+ null,
+ null,
+ null,
+ SkinTextures.Model.WIDE, true)
);
}
}