Class TextComponent
Component-rendering component with optional background and text effects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncentered()Sets the font used to render the text.Sets a glow effect for the text glyphs.Adds one named UTF-16 highlight range.Returns the retained named-highlight registry for this text.letterSpacing(float pixels) lineHeight(float multiplier) protected floatpreferredHeight(com.render.api.gui.GuiRenderContext context) protected floatpreferredHeightForWidth(com.render.api.gui.GuiRenderContext context, float resolvedWidth) protected floatpreferredWidth(com.render.api.gui.GuiRenderContext context) protected voidrenderSelf(com.render.api.gui.GuiRenderContext context) shadow(boolean shadow) Enables or disables the standard text shadow.Sets a custom shadow effect for the text glyphs.net.minecraft.network.chat.Componenttext()Returns the current component text.text(GuiRichText text) Sets typed per-span browser-grade text.Sets literal text content.text(net.minecraft.network.chat.Component text) Sets rich text content.textAlignment(GuiTextAlignment alignment) Sets horizontal text alignment within this component's content bounds.Sets a glow effect for the text glyphs.textPaint(GuiTextPaint paint) textScalePixels(float pixels) Sets the text size in design-space pixels.textShadow(GuiShadow shadow) Sets a custom shadow effect for the text glyphs.textStyle(GuiTextStyle style) Sets the immutable browser-grade base style.verticalTextAlignment(GuiTextVerticalAlignment alignment) Methods inherited from class GuiComponent
activeStateStyle, add, alignContent, alignItems, alignSelf, anchor, anchorName, anchorPlacement, animatedBorder, animation, applyStyle, aspectRatio, autoHeight, autoSize, autoWidth, backdropFilters, backfaceVisibility, backgroundColor, backgroundColor, backgroundLayer, backgroundLayers, backgroundLayers, border, borderCollapse, borderColor, borderColor, borderSpacing, borderWidth, boxDecorationBreak, boxGlow, boxShadow, boxShadows, boxShadows, boxSizing, breakAfter, breakBefore, breakInside, cancel, captionSide, caretStyle, childGap, childLayout, childLayoutViewport, childOffsetX, childOffsetY, children, clearChildren, clipChildren, clipPath, clipsChildren, color, color, columnCount, columnFill, columnGap, columnRule, columnSpan, columnWidth, computedStyle, containsChildClipPoint, contextMenu, cornerRadius, defaultDisplay, dirtyCategories, disabled, display, emptyCells, enabled, enabled, filters, findById, findById, flexBasis, flexDirection, flexGrow, flexShrink, flexWrap, focused, focused, fragmentTree, gradient, gridAutoFlow, gridPlacement, gridTemplate, handlesMouseClick, handlesMouseScroll, height, height, height, hovered, id, id, indeterminate, indeterminate, inlineStyle, inset, inset, intrinsicSize, invalidateModernLayout, isClippingChildren, isFocusable, justifyContent, justifyItems, justifySelf, lastInvalidationReason, layoutChildren, layoutFragments, listStyleImage, listStylePosition, listStyleType, margin, margin, margin, marginBreak, markerGap, markerSide, maskLayers, maskLayers, matchesStyleState, maxHeight, maxWidth, minHeight, minWidth, motionPath, onCharTyped, onFocusChanged, onKeyPressed, onModernLayoutComplete, onMouseClicked, onMouseDragged, onMouseReleased, onMouseScrolled, opacity, order, orphans, outline, padding, padding, padding, pageName, paint, parent, pause, play, position, position, pressed, pseudoElementBox, pseudoElementStyle, quotes, rangeState, rangeState, readOnly, readOnly, remove, removeStyleClass, renderChildren, renderClippedChildren, renderOverlay, requestFocus, required, required, resolveBaseProperties, resume, rowGap, scrollMargin, scrollMargin, scrollSnapStop, self, shouldRouteToChildren, size, size, startingStyle, stateProvider, styleAttribute, styleAttribute, styleClass, styleClasses, styledPseudoElements, styleOpen, styleState, styleState, tabIndex, tabIndex, tableLayout, tick, tooltip, transform, transformBox, transformOrigin, transformStyle, transition, transition, transition, transition, transition, transition, transitionAll, transitionAll, transitionAll, translate, translateX, translateY, validity, validity, verticalAlign, viewTransitionName, viewTransitionName, visible, visible, widows, width, width, width, writeModernInline, writeTextShadow, writingState, x, x, y, y, zIndex
-
Constructor Details
-
TextComponent
public TextComponent()
-
-
Method Details
-
text
Sets literal text content.- Parameters:
text- literal text to render- Returns:
- this component
-
text
public net.minecraft.network.chat.Component text()Returns the current component text.- Returns:
- current text
-
text
Sets rich text content.- Parameters:
text- component to render- Returns:
- this component
-
text
Sets typed per-span browser-grade text. -
textStyle
Sets the immutable browser-grade base style. Component spans are adapted over this style when no explicitGuiRichTextis present. -
font
Sets the font used to render the text.- Parameters:
font- font configuration- Returns:
- this component
-
textAlignment
Sets horizontal text alignment within this component's content bounds.- Parameters:
alignment- horizontal text alignment- Returns:
- this component
-
centerText
-
rightAlignText
-
verticalTextAlignment
-
centerTextVertically
-
centered
- Overrides:
centeredin classGuiComponent<TextComponent>
-
textScalePixels
Sets the text size in design-space pixels.- Parameters:
pixels- text size- Returns:
- this component
-
letterSpacing
-
lineHeight
-
highlights
Returns the retained named-highlight registry for this text.- Returns:
- highlight registry
-
highlight
Adds one named UTF-16 highlight range.- Parameters:
name- highlight name matched byHIGHLIGHT(name)startUtf16- inclusive startendUtf16- exclusive end- Returns:
- this component
-
textPaint
-
shadow
Enables or disables the standard text shadow.- Parameters:
shadow-trueto render the vanilla-style text shadow- Returns:
- this component
-
shadow
Sets a custom shadow effect for the text glyphs.- Overrides:
shadowin classGuiComponent<TextComponent>- Parameters:
shadow- text shadow configuration, ornullto clear it- Returns:
- this component
-
textShadow
Sets a custom shadow effect for the text glyphs.- Parameters:
shadow- text shadow configuration, ornullto clear it- Returns:
- this component
-
glow
Sets a glow effect for the text glyphs.- Overrides:
glowin classGuiComponent<TextComponent>- Parameters:
glow- text glow configuration, ornullto clear it- Returns:
- this component
-
textGlow
Sets a glow effect for the text glyphs.- Parameters:
glow- text glow configuration, ornullto clear it- Returns:
- this component
-
preferredWidth
protected float preferredWidth(com.render.api.gui.GuiRenderContext context) - Overrides:
preferredWidthin classGuiComponent<TextComponent>
-
preferredHeight
protected float preferredHeight(com.render.api.gui.GuiRenderContext context) - Overrides:
preferredHeightin classGuiComponent<TextComponent>
-
preferredHeightForWidth
protected float preferredHeightForWidth(com.render.api.gui.GuiRenderContext context, float resolvedWidth) - Overrides:
preferredHeightForWidthin classGuiComponent<TextComponent>
-
renderSelf
protected void renderSelf(com.render.api.gui.GuiRenderContext context) - Overrides:
renderSelfin classGuiComponent<TextComponent>
-