Posted March 22, 20178 yr 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()); } }
March 22, 20178 yr 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());
March 22, 20178 yr Author Fail. My bad. Sorry, I just recently got into modding (hence the "Joined 22 Minutes ago") I'll try that!
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.