Jump to content

Forge Chat Message


NeverMind

Recommended Posts

Hello everyone. I started learning java and soon started working in forge. I have 1 question. How can I send a message to a player when he loggins on the world? In 1.6, I think this worked: NetworkRegistry.instance().registerConnectionHandler(new ConnectionHandler()); (and that i could create the class ConnectionHandler and everything is easy), but now I get an error when I write this part. Any help, please?

Link to comment
Share on other sites

you need to create and register an event handler for your mod and then you can use the following in said event handler.

@SubscribeEvent
public void loginEvent(EntityJoinWorldEvent event){
if (event.entity instanceof EntityPlayer && event.world.isRemote)
	((EntityPlayer)event.entity).addChatComponentMessage(new ChatComponentText("Welcome to the world!!!!"));
}

if you dont know how to setup an event handler i can give you instructions.

I am the author of Draconic Evolution

Link to comment
Share on other sites

If you want a global message then I think this will work:

 

FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("Welcom" + player));

 

But if you want it to just be sent to the specific person I am not sure sorry.

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.

×
×
  • Create New...

Important Information

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