Jump to content

[1.7.10] Send chat message on player join a server


Emax

Recommended Posts

Hi, i'm developing a client mod i'm searching for a event that is called when the player join the server

and after he joins automatically send a chat message, i tried this code, but throw a NullPointerException when getting the player

 

	
       @SubscribeEvent
public void onConnectedToServerEvent(ClientConnectedToServerEvent event) {
	EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
        player.sendChatMessage("Hello!"); // <-- NullPointerException
}

Link to comment
Share on other sites

The method sendPacket(C01PacketChatMessage) is undefined for the type NetworkManager

 

	
       @SubscribeEvent
public void onConnectedToServerEvent(ClientConnectedToServerEvent event) {
	event.manager.sendPacket(new C01PacketChatMessage("Hi!"));
}

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

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