Package org.moddingx.libx.util.game
Class ComponentUtil
java.lang.Object
org.moddingx.libx.util.game.ComponentUtil
Utilities for
text components
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getConsoleString
(net.minecraft.network.chat.Component tc) Gets atext component
as a string formatted with ANSI escape codes to be printed on the console.static net.minecraft.util.FormattedCharSequence
subSequence
(net.minecraft.util.FormattedCharSequence text, int start) Gets a sub-sequence from the givenFormattedCharSequence
.static net.minecraft.util.FormattedCharSequence
subSequence
(net.minecraft.util.FormattedCharSequence text, int start, int end) Gets a sub-sequence from the givenFormattedCharSequence
.static net.minecraft.network.chat.Component
toPrettyComponent
(JsonElement json) Turns aJsonElement
to aComponent
with syntax highlighting that can be used for display.static net.minecraft.network.chat.Component
withCopyAction
(net.minecraft.network.chat.Component component, String copyText) Adds aclick event
to the given component to copy the given text to clipboard.
-
Constructor Details
-
ComponentUtil
public ComponentUtil()
-
-
Method Details
-
getConsoleString
Gets atext component
as a string formatted with ANSI escape codes to be printed on the console. -
toPrettyComponent
Turns aJsonElement
to aComponent
with syntax highlighting that can be used for display. -
withCopyAction
public static net.minecraft.network.chat.Component withCopyAction(net.minecraft.network.chat.Component component, String copyText) Adds aclick event
to the given component to copy the given text to clipboard. -
subSequence
public static net.minecraft.util.FormattedCharSequence subSequence(net.minecraft.util.FormattedCharSequence text, int start) Gets a sub-sequence from the givenFormattedCharSequence
. The sub sequence will include all characters fromstart
(inclusive) to the end of the sequence. -
subSequence
public static net.minecraft.util.FormattedCharSequence subSequence(net.minecraft.util.FormattedCharSequence text, int start, int end) Gets a sub-sequence from the givenFormattedCharSequence
. The sub sequence will include all characters betweenstart
(inclusive) andend
(exclusive).start
andend
may not be negative but may be greater that the length of the sequence.
-