From ec6b3c2d8db90a4100ea493d4a2ef7722d7c064c Mon Sep 17 00:00:00 2001 From: anhgelus Date: Wed, 21 Aug 2024 18:01:50 +0000 Subject: feat(player): disable nametag --- .../anhgelus/molehunt/client/mixin/NoNametags.java | 21 +++++++++++++++++++++ src/client/resources/molehunt.client.mixins.json | 3 ++- src/main/resources/molehunt.mixins.json | 3 +-- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java (limited to 'src') diff --git a/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java new file mode 100644 index 0000000..d7795dd --- /dev/null +++ b/src/client/java/world/anhgelus/molehunt/client/mixin/NoNametags.java @@ -0,0 +1,21 @@ +package world.anhgelus.molehunt.client.mixin; + +import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.entity.EntityRenderer; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.PlayerEntity; +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; + +@Mixin(EntityRenderer.class) +public abstract class NoNametags { + @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; + + ci.cancel(); + } +} \ No newline at end of file diff --git a/src/client/resources/molehunt.client.mixins.json b/src/client/resources/molehunt.client.mixins.json index 149a39e..e6a9f8e 100644 --- a/src/client/resources/molehunt.client.mixins.json +++ b/src/client/resources/molehunt.client.mixins.json @@ -1,9 +1,10 @@ { "required": true, "minVersion": "0.8", - "package": "world.anhgelus.molehunt.mixin.client", + "package": "world.anhgelus.molehunt.client.mixin", "compatibilityLevel": "JAVA_21", "client": [ + "NoNametags" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/molehunt.mixins.json b/src/main/resources/molehunt.mixins.json index 5b76af8..8acee9a 100644 --- a/src/main/resources/molehunt.mixins.json +++ b/src/main/resources/molehunt.mixins.json @@ -3,8 +3,7 @@ "minVersion": "0.8", "package": "world.anhgelus.molehunt.mixin", "compatibilityLevel": "JAVA_21", - "mixins": [ - ], + "mixins": [], "injectors": { "defaultRequire": 1 } -- cgit v1.2.3