Jump to content

[1.15.2] How to add a shortened hyperlink to the chat


squidlex

Recommended Posts

I'm looking to send this message if a mod is not installed to the chat:

 

'To use all the features of this item, please install the latest version of 'The Midnight', which can be found here'

 

I've already got everything in place for checking if the mod is installed, but I don't know where to go from here, a code example would be incredibly helpful to me!

What I've already got:

if(ModList.get().isLoaded("midnight")) {
    if (worldIn.isRemote) {
        playerIn.sendMessage(/*a hyperlinked message*/);
    }
}

Thank you for your time and help!

Edited by squidlex
Link to comment
Share on other sites

6 hours ago, diesieben07 said:

You need to give a ClickEvent to an ITextComponent via it's Style (ITextComponent#getStyle).

 

Thanks for your help! I now have

myMessage.getStyle().setClickEvent()

But I don't know how to actually provide a link.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.