diff --git a/src/main/java/com/lovetropics/minigames/client/render/GameRendering.java b/src/main/java/com/lovetropics/minigames/client/render/GameRendering.java index f78725865..a8c5944fc 100644 --- a/src/main/java/com/lovetropics/minigames/client/render/GameRendering.java +++ b/src/main/java/com/lovetropics/minigames/client/render/GameRendering.java @@ -35,6 +35,7 @@ import net.neoforged.neoforge.client.ClientHooks; import net.neoforged.neoforge.client.event.RenderLevelStageEvent; import net.neoforged.neoforge.client.event.RenderNameTagEvent; +import net.neoforged.neoforge.common.util.TriState; import java.util.List; @@ -190,6 +191,11 @@ public static void buildEastFacing(VertexConsumer buffer, PoseStack.Pose pose, f @SubscribeEvent public static void onRenderPlayerName(RenderNameTagEvent event) { if (event.getEntity() instanceof Player player) { + if (ClientGameStateManager.getOrNull(GameClientStateTypes.HIDE_NAME_TAGS) != null) { + event.setCanRender(TriState.FALSE); + return; + } + PointTagClientState state = ClientGameStateManager.getOrNull(GameClientStateTypes.POINT_TAGS); Component points = state != null ? state.getPointsTextFor(player.getUUID()) : null; if (points != null) { diff --git a/src/main/java/com/lovetropics/minigames/common/core/game/client_state/GameClientStateTypes.java b/src/main/java/com/lovetropics/minigames/common/core/game/client_state/GameClientStateTypes.java index 49ec439f6..7ee8770ee 100644 --- a/src/main/java/com/lovetropics/minigames/common/core/game/client_state/GameClientStateTypes.java +++ b/src/main/java/com/lovetropics/minigames/common/core/game/client_state/GameClientStateTypes.java @@ -7,6 +7,7 @@ import com.lovetropics.minigames.common.core.game.client_state.instance.FogClientState; import com.lovetropics.minigames.common.core.game.client_state.instance.GlowTeamMembersState; import com.lovetropics.minigames.common.core.game.client_state.instance.HealthTagClientState; +import com.lovetropics.minigames.common.core.game.client_state.instance.HideNameTagsState; import com.lovetropics.minigames.common.core.game.client_state.instance.HideRecipeBookClientState; import com.lovetropics.minigames.common.core.game.client_state.instance.InvertControlsClientState; import com.lovetropics.minigames.common.core.game.client_state.instance.PointTagClientState; @@ -48,13 +49,14 @@ public final class GameClientStateTypes { public static final GameClientTweakEntry BEACON = register("beacon", BeaconClientState.CODEC); public static final GameClientTweakEntry FOG = register("fog", FogClientState.CODEC); public static final GameClientTweakEntry TEAM_MEMBERS = register("team_members", TeamMembersClientState.CODEC); - public static final GameClientTweakEntry GLOW_TEAM_MEMBERS = register("glow_team_members", MapCodec.unit(GlowTeamMembersState.INSTANCE)); + public static final GameClientTweakEntry GLOW_TEAM_MEMBERS = register("glow_team_members", MapCodec.unit(GlowTeamMembersState.INSTANCE), StreamCodec.unit(GlowTeamMembersState.INSTANCE)); public static final GameClientTweakEntry POINT_TAGS = register("point_tags", PointTagClientState.CODEC); public static final GameClientTweakEntry HIDE_RECIPE_BOOK = register("hide_recipe_book", HideRecipeBookClientState.CODEC); public static final GameClientTweakEntry CRAFTING_BEE_CRAFTS = register("crafting_bee_crafts", CraftingBeeCraftsClientState.CODEC); public static final GameClientTweakEntry INVERT_CONTROLS = register("invert_controls", InvertControlsClientState.CODEC); public static final GameClientTweakEntry SWAP_MOVEMENT = register("swap_movement", SwapMovementClientState.CODEC); public static final GameClientTweakEntry COLLIDERS = register("colliders", CollidersClientState.CODEC, CollidersClientState.STREAM_CODEC); + public static final GameClientTweakEntry HIDE_NAME_TAGS = register("hide_name_tags", MapCodec.unit(HideNameTagsState.INSTANCE), StreamCodec.unit(HideNameTagsState.INSTANCE)); public static GameClientTweakEntry register(final String name, final MapCodec codec) { return REGISTRATE.object(name) diff --git a/src/main/java/com/lovetropics/minigames/common/core/game/client_state/instance/HideNameTagsState.java b/src/main/java/com/lovetropics/minigames/common/core/game/client_state/instance/HideNameTagsState.java new file mode 100644 index 000000000..5a934741d --- /dev/null +++ b/src/main/java/com/lovetropics/minigames/common/core/game/client_state/instance/HideNameTagsState.java @@ -0,0 +1,17 @@ +package com.lovetropics.minigames.common.core.game.client_state.instance; + +import com.lovetropics.minigames.common.core.game.client_state.GameClientState; +import com.lovetropics.minigames.common.core.game.client_state.GameClientStateType; +import com.lovetropics.minigames.common.core.game.client_state.GameClientStateTypes; + +public class HideNameTagsState implements GameClientState { + public static final HideNameTagsState INSTANCE = new HideNameTagsState(); + + private HideNameTagsState() { + } + + @Override + public GameClientStateType getType() { + return GameClientStateTypes.HIDE_NAME_TAGS.get(); + } +}