From b914902b8e3843ff746c6dd75f0f430b4a607257 Mon Sep 17 00:00:00 2001 From: HappyRespawnanchor <80967824+HappyRespawnanchor@users.noreply.github.com> Date: Fri, 22 Nov 2024 22:59:25 +0800 Subject: [PATCH] tooltip done --- .../ayamemc/ayame/client/handler/ClientEventHandler.java | 7 +++++-- .../ayame/fabric/mixin/client/TooltipRenderUtilMixin.java | 8 ++++---- .../neoforge/client/event/NeoForgeClientEventHandler.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java b/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java index 16b784d..3a6e0c0 100644 --- a/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java +++ b/common/src/main/java/org/ayamemc/ayame/client/handler/ClientEventHandler.java @@ -29,13 +29,16 @@ import org.ayamemc.ayame.client.gui.screen.ModelSelectMenuScreen; public class ClientEventHandler { + private final static Minecraft minecraft = Minecraft.getInstance(); + public static final int TOOLTIP_BACKGROUND_COLOR = 0xCC_5f5f5f; public static final int TOOLTIP_BORDER_TOP_COLOR = 0xCC_fdc7f5; public static final int TOOLTIP_BORDER_BOTTOM_COLOR = 0xCC_fde8f5; - private final static Minecraft minecraft = Minecraft.getInstance(); - public static boolean useAyameTooltipColor = minecraft.screen instanceof ModelSelectMenuScreen; + public static boolean shouldUseAyameTooltipColor() { + return minecraft.screen instanceof AyameScreen; + } public static void renderCustomHandEventHandler( InteractionHand hand, PoseStack poseStack, diff --git a/fabric/src/main/java/org/ayamemc/ayame/fabric/mixin/client/TooltipRenderUtilMixin.java b/fabric/src/main/java/org/ayamemc/ayame/fabric/mixin/client/TooltipRenderUtilMixin.java index fedb9c9..48bd126 100644 --- a/fabric/src/main/java/org/ayamemc/ayame/fabric/mixin/client/TooltipRenderUtilMixin.java +++ b/fabric/src/main/java/org/ayamemc/ayame/fabric/mixin/client/TooltipRenderUtilMixin.java @@ -43,7 +43,7 @@ private static int renderHorizontalLineAyameBackgroundColor(int backgroundColor) index = 6 ) private static int renderRectangleAyameBackgroundColor(int backgroundColor) { - return ClientEventHandler.useAyameTooltipColor ? ClientEventHandler.TOOLTIP_BACKGROUND_COLOR : backgroundColor; + return ClientEventHandler.shouldUseAyameTooltipColor() ? ClientEventHandler.TOOLTIP_BACKGROUND_COLOR : backgroundColor; } @ModifyArg( method = "renderTooltipBackground", @@ -51,7 +51,7 @@ private static int renderRectangleAyameBackgroundColor(int backgroundColor) { index = 5 ) private static int renderVerticalLineAyameBackgroundColor(int backgroundColor) { - return ClientEventHandler.useAyameTooltipColor ? ClientEventHandler.TOOLTIP_BACKGROUND_COLOR : backgroundColor; + return ClientEventHandler.shouldUseAyameTooltipColor() ? ClientEventHandler.TOOLTIP_BACKGROUND_COLOR : backgroundColor; } @ModifyArg( @@ -60,7 +60,7 @@ private static int renderVerticalLineAyameBackgroundColor(int backgroundColor) { index = 6 ) private static int renderFrameGradientAyameTopColor(int topColor) { - return ClientEventHandler.useAyameTooltipColor ? ClientEventHandler.TOOLTIP_BORDER_TOP_COLOR : topColor; + return ClientEventHandler.shouldUseAyameTooltipColor() ? ClientEventHandler.TOOLTIP_BORDER_TOP_COLOR : topColor; } @ModifyArg( method = "renderTooltipBackground", @@ -68,7 +68,7 @@ private static int renderFrameGradientAyameTopColor(int topColor) { index = 7 ) private static int renderFrameGradientAyameBottomColor(int bottomColor) { - return ClientEventHandler.useAyameTooltipColor ? ClientEventHandler.TOOLTIP_BORDER_BOTTOM_COLOR : bottomColor; + return ClientEventHandler.shouldUseAyameTooltipColor() ? ClientEventHandler.TOOLTIP_BORDER_BOTTOM_COLOR : bottomColor; } diff --git a/neoforge/src/main/java/org/ayamemc/ayame/neoforge/client/event/NeoForgeClientEventHandler.java b/neoforge/src/main/java/org/ayamemc/ayame/neoforge/client/event/NeoForgeClientEventHandler.java index fc0e5be..57bd212 100644 --- a/neoforge/src/main/java/org/ayamemc/ayame/neoforge/client/event/NeoForgeClientEventHandler.java +++ b/neoforge/src/main/java/org/ayamemc/ayame/neoforge/client/event/NeoForgeClientEventHandler.java @@ -70,7 +70,7 @@ public static void renderCustomModelHand(RenderHandEvent event) { } @SubscribeEvent public static void renderAyameTooltipColor(RenderTooltipEvent.Color event) { - if (ClientEventHandler.useAyameTooltipColor) { + if (ClientEventHandler.shouldUseAyameTooltipColor()) { event.setBorderStart(ClientEventHandler.TOOLTIP_BORDER_TOP_COLOR); event.setBorderEnd(ClientEventHandler.TOOLTIP_BORDER_BOTTOM_COLOR); event.setBackground(ClientEventHandler.TOOLTIP_BACKGROUND_COLOR);