diff --git a/src/main/java/codechicken/lib/gui/modular/lib/GuiRender.java b/src/main/java/codechicken/lib/gui/modular/lib/GuiRender.java index bc13e1ec..bcae9359 100644 --- a/src/main/java/codechicken/lib/gui/modular/lib/GuiRender.java +++ b/src/main/java/codechicken/lib/gui/modular/lib/GuiRender.java @@ -1302,11 +1302,8 @@ public void renderTooltip(Component message, double mouseX, double mouseY) { } public void renderTooltip(Component message, double mouseX, double mouseY, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) { - this.renderTooltip(List.of(message.getVisualOrderText()), mouseX, mouseY, backgroundTop, backgroundBottom, borderTop, borderBottom); - } - - public void componentTooltip(List tooltips, double mouseX, double mouseY) { - componentTooltip(tooltips, mouseX, mouseY, 0xf0100010, 0xf0100010, 0x505000ff, 0x5028007f); + List list = ForgeHooksClient.gatherTooltipComponents(tooltipStack, List.of(message), Optional.empty(), (int) mouseX, guiWidth(), guiHeight(), font()); + this.renderTooltipInternal(list, mouseX, mouseY, backgroundTop, backgroundBottom, borderTop, borderBottom, DefaultTooltipPositioner.INSTANCE); } public void componentTooltip(List tooltips, double mouseX, double mouseY, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) { @@ -1318,21 +1315,34 @@ public void componentTooltip(List tooltips, double mous componentTooltip(tooltips, mouseX, mouseY, 0xf0100010, 0xf0100010, 0x505000ff, 0x5028007f, stack); } - public void componentTooltip(List tooltips, double mouseX, double mouseY, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom, ItemStack stack) { + public void componentTooltip(List tooltips, double mouseX, double mouseY) { + componentTooltip(tooltips, mouseX, mouseY, 0xf0100010, 0xf0100010, 0x505000ff, 0x5028007f, ItemStack.EMPTY); + } + + public void componentTooltip(List tooltips, double mouseX, double mouseY, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom, ItemStack stack) { this.tooltipStack = stack; List list = ForgeHooksClient.gatherTooltipComponents(tooltipStack, tooltips, Optional.empty(), (int) mouseX, guiWidth(), guiHeight(), font()); this.renderTooltipInternal(list, mouseX, mouseY, backgroundTop, backgroundBottom, borderTop, borderBottom, DefaultTooltipPositioner.INSTANCE); this.tooltipStack = ItemStack.EMPTY; } + /** + * Warning: This tooltip method with not automatically wrap tooltip lines + */ public void renderTooltip(List tooltips, double mouseX, double mouseY) { renderTooltip(tooltips, mouseX, mouseY, 0xf0100010, 0xf0100010, 0x505000ff, 0x5028007f); } + /** + * Warning: This tooltip method with not automatically wrap tooltip lines + */ public void renderTooltip(List tooltips, double mouseX, double mouseY, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) { this.renderTooltipInternal(tooltips.stream().map(ClientTooltipComponent::create).collect(Collectors.toList()), mouseX, mouseY, backgroundTop, backgroundBottom, borderTop, borderBottom, DefaultTooltipPositioner.INSTANCE); } + /** + * Warning: This tooltip method with not automatically wrap tooltip lines + */ public void renderTooltip(List tooltips, ClientTooltipPositioner positioner, double mouseX, double mouseY, int backgroundTop, int backgroundBottom, int borderTop, int borderBottom) { this.renderTooltipInternal(tooltips.stream().map(ClientTooltipComponent::create).collect(Collectors.toList()), mouseX, mouseY, backgroundTop, backgroundBottom, borderTop, borderBottom, positioner); } diff --git a/src/main/java/codechicken/lib/gui/modular/lib/TooltipHandler.java b/src/main/java/codechicken/lib/gui/modular/lib/TooltipHandler.java index 46ebc188..0f1d5cfc 100644 --- a/src/main/java/codechicken/lib/gui/modular/lib/TooltipHandler.java +++ b/src/main/java/codechicken/lib/gui/modular/lib/TooltipHandler.java @@ -7,6 +7,7 @@ import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.function.Supplier; /** @@ -100,7 +101,7 @@ default boolean renderTooltip(GuiRender render, double mouseX, double mouseY) { List list = supplier.get(); if (list.isEmpty()) return false; //Run all components though split to account for newline characters in translations - render.renderTooltip(list.stream().flatMap(component -> render.font().split(component, Integer.MAX_VALUE).stream()).toList(), mouseX, mouseY); + render.componentTooltip(list.stream().flatMap(component -> render.font().getSplitter().splitLines(component, Integer.MAX_VALUE, component.getStyle()).stream()).toList(), mouseX, mouseY); return true; } }