Package org.moddingx.libx.util.game
Class ComponentUtil
java.lang.Object
org.moddingx.libx.util.game.ComponentUtil
Utilities for
text components.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetConsoleString(net.minecraft.network.chat.Component tc) Gets atext componentas a string formatted with ANSI escape codes to be printed on the console.static net.minecraft.util.FormattedCharSequencesubSequence(net.minecraft.util.FormattedCharSequence text, int start) Gets a sub-sequence from the givenFormattedCharSequence.static net.minecraft.util.FormattedCharSequencesubSequence(net.minecraft.util.FormattedCharSequence text, int start, int end) Gets a sub-sequence from the givenFormattedCharSequence.static net.minecraft.network.chat.ComponenttoPrettyComponent(JsonElement json) Turns aJsonElementinto aComponentwith syntax highlighting that can be used for display.static net.minecraft.network.chat.ComponenttoPrettyComponent(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<net.minecraft.core.component.DataComponentType<?>>> registry, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.component.DataComponentMap components) Turns aDataComponentMapinto aComponentwith syntax highlighting that can be used for display.static net.minecraft.network.chat.ComponenttoPrettyComponent(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<net.minecraft.core.component.DataComponentType<?>>> registry, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.component.DataComponentPatch patch) Turns aDataComponentPatchinto aComponentwith syntax highlighting that can be used for display.static net.minecraft.network.chat.ComponentwithCopyAction(net.minecraft.network.chat.Component component, String copyText) Adds aclick eventto the given component to copy the given text to clipboard.
-
Constructor Details
-
ComponentUtil
public ComponentUtil()
-
-
Method Details
-
getConsoleString
Gets atext componentas a string formatted with ANSI escape codes to be printed on the console. -
toPrettyComponent
Turns aJsonElementinto aComponentwith syntax highlighting that can be used for display. -
toPrettyComponent
public static net.minecraft.network.chat.Component toPrettyComponent(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<net.minecraft.core.component.DataComponentType<?>>> registry, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.component.DataComponentMap components) Turns aDataComponentMapinto aComponentwith syntax highlighting that can be used for display.- Parameters:
registry- The registry in which the data component types for thedata component mapare registered.registryAccess- Aregistry accessto provide access to datapack registries when encoding data component values.
-
toPrettyComponent
public static net.minecraft.network.chat.Component toPrettyComponent(net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<net.minecraft.core.component.DataComponentType<?>>> registry, net.minecraft.core.RegistryAccess registryAccess, net.minecraft.core.component.DataComponentPatch patch) Turns aDataComponentPatchinto aComponentwith syntax highlighting that can be used for display.- Parameters:
registry- The registry in which the data component types for thedata component patchare registered.registryAccess- Aregistry accessto provide access to datapack registries when encoding data component values.
-
withCopyAction
public static net.minecraft.network.chat.Component withCopyAction(net.minecraft.network.chat.Component component, String copyText) Adds aclick eventto 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).startandendmay not be negative but may be greater that the length of the sequence.
-