mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Add missing stack tooltip rendering hooks (#9533)
Fix automatic tooltip wrapping discarding empty lines used as spacers
This commit is contained in:
1 parent
5318d70c18
commit
9cf1a77fdb
3 files changed
+28
-2
No files matched your search
@@ -74,6 +74,7 @@ import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.ChatTypeDecoration;
|
||||
import net.minecraft.network.chat.CommonComponents;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.ComponentContents;
|
||||
import net.minecraft.network.chat.FormattedText;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.chat.Style;
|
||||
@@ -1078,7 +1079,7 @@ public class ForgeHooksClient
|
||||
{
|
||||
return event.getTooltipElements().stream()
|
||||
.flatMap(either -> either.map(
|
||||
text -> font.split(text, tooltipTextWidthF).stream().map(ClientTooltipComponent::create),
|
||||
text -> splitLine(text, font, tooltipTextWidthF),
|
||||
component -> Stream.of(ClientTooltipComponent.create(component))
|
||||
))
|
||||
.toList();
|
||||
@@ -1091,6 +1092,15 @@ public class ForgeHooksClient
|
||||
.toList();
|
||||
}
|
||||
|
||||
private static Stream<ClientTooltipComponent> splitLine(FormattedText text, Font font, int maxWidth)
|
||||
{
|
||||
if (text instanceof Component component && component.getString().isEmpty())
|
||||
{
|
||||
return Stream.of(component.getVisualOrderText()).map(ClientTooltipComponent::create);
|
||||
}
|
||||
return font.split(text, maxWidth).stream().map(ClientTooltipComponent::create);
|
||||
}
|
||||
|
||||
public static Comparator<ParticleRenderType> makeParticleRenderTypeComparator(List<ParticleRenderType> renderOrder)
|
||||
{
|
||||
Comparator<ParticleRenderType> vanillaComparator = Comparator.comparingInt(renderOrder::indexOf);
|
||||
|
||||
Reference in new issue
Block a user