@Environment(value=CLIENT)
public final class Document
extends java.lang.Object
General usage is: parse a string using parse(), render it using render().
The parser generates a list of segments, each segment representing a part of the document, with a specific formatting / render type. For example, links are their own segments, a bold section in a link would be its own section and so on. The data structure is essentially a very flat multi-tree, where the segments returned are the leaves, and the roots are the individual lines, represented as text segments. Formatting is done by accumulating formatting information over the parent nodes, up to the root.
| Modifier and Type | Method and Description |
|---|---|
static int |
height(Segment document,
int maxWidth,
net.minecraft.client.font.TextRenderer renderer)
Compute the overall height of a document, e.g.
|
static int |
lineHeight(net.minecraft.client.font.TextRenderer renderer)
Line height for a normal line of text.
|
static Segment |
parse(java.lang.Iterable<java.lang.String> document)
Parses a plain text document into a list of segments.
|
static java.util.Optional<InteractiveSegment> |
render(Segment document,
int x,
int y,
int maxWidth,
int maxHeight,
int yOffset,
net.minecraft.client.font.TextRenderer renderer,
int mouseX,
int mouseY)
Renders a list of segments and tooltips if a segment with a tooltip is hovered.
|
public static Segment parse(java.lang.Iterable<java.lang.String> document)
document - iterator over the lines of the document to parse.public static int height(Segment document, int maxWidth, net.minecraft.client.font.TextRenderer renderer)
document - the document to compute the height of.maxWidth - the maximum height available.renderer - the font renderer used.public static int lineHeight(net.minecraft.client.font.TextRenderer renderer)
renderer - the font renderer used.public static java.util.Optional<InteractiveSegment> render(Segment document, int x, int y, int maxWidth, int maxHeight, int yOffset, net.minecraft.client.font.TextRenderer renderer, int mouseX, int mouseY)
document - the document to render.x - the x position to render at.y - the y position to render at.maxWidth - the width of the area to render the document in.maxHeight - the height of the area to render the document in.yOffset - the vertical scroll offset of the document.renderer - the font renderer to use.mouseX - the x position of the mouse.mouseY - the y position of the mouse.