This is very prone to breaking and ignores everything about the structure of componentsYeah, sure... you can use:
Code:((TextComponent)getDisplayName()).content()
The use of Adventure for text is very annoying :/
thank you very muchYeah, sure... you can use:
Code:((TextComponent)getDisplayName()).content()
The use of Adventure for text is very annoying :/
I need the text of the item name without other formattingComponents represent rich text used by Minecraft itself. Typically the answer to "how to get the text" depends on what you need it for, there are very few legitimate uses to actually get the plain text, as components can hold things that cannot be easily represented by simple text
This is very prone to breaking and ignores everything about the structure of components
Why? You shouldn’t be storing data in an items name or lore, unless you have a really good reason not to. You should store any information in the itemstacks persistent data container.I need the text of the item name without other formatting
This is a very not good way to get the text. What happens if I set the display name of an itemstack to a translatable component, or some other component type? Casting it to TextComponent isn't going to work then. Like others have said, there are very few legitimate reasons to want the plain text content of a component. Otherwise, you shouldn't try to convert Minecraft's tree-like text component structure to a 2 dimensional string.Yeah, sure... you can use:
Code:((TextComponent)getDisplayName()).content()
The use of Adventure for text is very annoying :/
Yeah, this is the correct what to get the Component's plain textshould work for most cases and is certainly cleaner than ripping out the content of a TextComponent.Java:PlainTextComponentSerializer.plainText().serialize()