Posted April 27, 20232 yr I'm making currently a Command that shows you Information of the World. There you can also see the Seed of the World. But I want it to make it clickable to make it copyable to clipboard. Know someone what the Code is?
April 27, 20232 yr Add a MutableComponent with a Style that sets the clickEvent when action of COPY_TO_CLIPBOARD.
April 28, 20232 yr Author One Question: What is the best Method to implement MutableComponent inside of displayClientMessage Method? Here is a Code and tried to implement it inside it: if (entity instanceof Player _player && !_player.level.isClientSide()) _player.displayClientMessage(new TextComponent(("§6" + "Seed: " + "§r" new MutableComponent(world.getServer().overworld().getSeed()).withStyle(style -> style.bold(true)).build())), (false)); But got this Error: error: MutableComponent is abstract; cannot be instantiated
April 28, 20232 yr There is already is a command that does what you want. See SeedCommand Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
April 28, 20232 yr Author No what I want is how to use MutableComponent correctly inside of displayClientMessage.
April 28, 20232 yr No. You should do your own research. We are not going to write your mod for you. In this case, look at how Mojang creates theirs in SeedCommand. If you did this, you spent less than 20 minutes trying to figure it out for yourself. hint: (Mutable)Component is an interface so you are looking for one of its concrete subclasses. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
April 29, 20232 yr Author I got to made the Component that I copied from SeedCommand to work. But the only issue that if I get the Component Variable inside the displayClientMessage and using getString() it only prints the String but not the Style to the chat. I think I'm missing something... Component TestComponent = ComponentUtils.wrapInSquareBrackets((new TextComponent(TestString)).withStyle((TestStyle) -> { return TestStyle.withColor(ChatFormatting.RED).withInsertion(TestString); })); if (entity instanceof Player _player && !_player.level.isClientSide()) _player.displayClientMessage(new TextComponent(TestComponent.getString()), (false));
April 29, 20232 yr Why are calling toString() on your Component and then wrapping that in another Component? A java.lang.String is just an array of unicode characters. It has no way to understand or store Minecraft's style attachments. Boilerplate: If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one. If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install Large files should be posted to a file sharing site like https://gist.github.com You should also read the support forum sticky post.
April 30, 20232 yr Author Well that makes sense. I need to mention that I never had to do with Component and ComponentUtils. Only with TextComponent and TranslatebleComponent. So then I thought I can research for myself how to implement Text with Styles.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.