Jump to content

Recommended Posts

Posted

So I am having this weird glitch where I try (for testing purposes) to display a chat message to a player who loaded up a world/joined a server.

This is my code so far:

	package weatherplus.forge;
	import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
	public class EventHandler{
    @SubscribeEvent
    public void onLogin(PlayerEvent.PlayerLoggedInEvent event){
        event.player.sendMessage(new TextComponentString("[WeatherPlus] Client-Side features enabled"));
        System.out.println("[WeatherPlus] Player logged in: " + event.player.getName());
    }
    
    @SubscribeEvent
    public void onLogoff(PlayerEvent.PlayerLoggedOutEvent event){
        System.out.println("[WeatherPlus] Player logged out: " + event.player.getName());
    }
}
	

Posted

Have you registered the EventHandler in your mod initialisation?

 

Super simple if you haven't just add:

// To register the handler outside of the EventHandler class
MinecraftForge.EVENT_BUS.register(new EventHandler());

 

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.