From a9361c757a636c9d62bbc180a5c0468f649784ba Mon Sep 17 00:00:00 2001 From: Juuxel <6596629+Juuxel@users.noreply.github.com> Date: Tue, 10 Mar 2020 19:58:00 +0200 Subject: Add text hover rendering to WText --- src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/main/java/io') diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java index 7e90b39..64a7c3e 100644 --- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java +++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WText.java @@ -2,12 +2,14 @@ package io.github.cottonmc.cotton.gui.widget; import io.github.cottonmc.cotton.gui.client.LibGuiClient; import io.github.cottonmc.cotton.gui.client.ScreenDrawing; +import io.github.cottonmc.cotton.gui.client.TextHoverRendererScreen; import io.github.cottonmc.cotton.gui.widget.data.Alignment; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.util.Texts; import net.minecraft.text.Text; @@ -80,6 +82,14 @@ public class WText extends WWidget { ScreenDrawing.drawString(str, alignment, x, y + i * font.fontHeight, width, c); } + + Text hoveredText = getTextAt(mouseX, mouseY); + if (hoveredText != null) { + Screen screen = MinecraftClient.getInstance().currentScreen; + if (screen instanceof TextHoverRendererScreen) { + ((TextHoverRendererScreen) screen).renderTextHover(hoveredText, x + mouseX, y + mouseY); + } + } } @Override -- cgit