mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Add a way to render tooltips from Formatted text and TooltipComponents elements (#10056)
This commit is contained in:
1 parent
decaace84a
commit
28e55b2843
2 files changed
+13
-2
No files matched your search
@@ -814,11 +814,15 @@ public class ForgeHooksClient {
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponents(ItemStack stack, List<? extends FormattedText> textElements, Optional<TooltipComponent> itemComponent, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) {
|
||||
Font font = getTooltipFont(stack, fallbackFont);
|
||||
List<Either<FormattedText, TooltipComponent>> elements = textElements.stream()
|
||||
.map((Function<FormattedText, Either<FormattedText, TooltipComponent>>) Either::left)
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
itemComponent.ifPresent(c -> elements.add(1, Either.right(c)));
|
||||
return gatherTooltipComponentsFromElements(stack, elements, mouseX, screenWidth, screenHeight, fallbackFont);
|
||||
}
|
||||
|
||||
public static List<ClientTooltipComponent> gatherTooltipComponentsFromElements(ItemStack stack, List<Either<FormattedText, TooltipComponent>> elements, int mouseX, int screenWidth, int screenHeight, Font fallbackFont) {
|
||||
Font font = getTooltipFont(stack, fallbackFont);
|
||||
|
||||
var event = new RenderTooltipEvent.GatherComponents(stack, screenWidth, screenHeight, elements, -1);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
|
||||
Reference in new issue
Block a user