Jump to content

[1.15.2] Updating ChatComponentText


xSlart01x

Recommended Posts

Hi everyone, i'm trying to update an 1.8.9 mod to 1.15.2. For now, i'm blocked on this component.

Old code was:

ManageKeys.mc.thePlayer.addChatMessage((IChatComponent)new ChatComponentText(ChatFormatting.RED + "*string*"));

New code (actually) is:

ManageKeys.mc.player.sendMessage((ITextComponent)new ChatComponentText(ChatFormatting.RED + "*string*"));

I don't now if i'm doing right but i'm blocked here. Appreciating your help.
Best regards, Slart.

Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

The point of the chat component system is to NOT use TextFormatting (old name EnumChatFormatting) with string concatenation. Use Style#setColor (from ITextComponent#getStyle).

ChatComponentText is StringTextComponent now.

 

Also: Do not store the Minecraft instance somewhere. Use Minecraft#getInstance.

Firstly, thanks for the answer.
Now, i've never used this type of.. istruction? What should be the type "Class#method" ?

Link to comment
Share on other sites

11 minutes ago, diesieben07 said:

It's just a notation for instance methods, meaning you need an instance of the class to call the method.

Okay.. maybe i've understood... So....

Style cs = new Style();

Then

cs.setStyle(/*Color?*/);
// Now output of the chat message:
mc.player.sendMessage((ITextComponent)new StringTextComponent("*String*");

And what goes inside setStyle?

Link to comment
Share on other sites

9 minutes ago, diesieben07 said:

Nowhere in my post did I say to do that.

I said to use ITextComponent#getStyle.

Mhhh....

If i declare an object

ITextComponent style;
// Then
style.getStyle();

Where i set the style?

p.s. if it is all wrong excuse me but i've not understood so much..

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.