Posted February 28, 20205 yr 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.
February 28, 20205 yr Author 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" ?
February 28, 20205 yr Author 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?
February 28, 20205 yr Author 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..
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.