Ringosham Posted March 23, 2016 Share Posted March 23, 2016 This only happened on 1.9. Here's what I am trying to do. private boolean msgShown = false; @SubscribeEvent public void onTick(TickEvent.PlayerTickEvent event) { if (!msgShown) { event.player.addChatMessage(new TextComponentString("Text 1")); Minecraft.getMinecraft().thePlayer.addChatMessage(new TextComponentString("Text 2")); msgShown = true; } } Both of these lines work in 1.7.10 - 1.8.9. But in 1.9 I got NullPointerException with Ticking player when opening a world. I don't really know why it doesn't work. I'm using the latest version of Forge for 1.9 I'll post the log if you need to. Quote Link to comment Share on other sites More sharing options...
UberAffe Posted March 23, 2016 Share Posted March 23, 2016 The tick event is client and server side so this line should cause a problem on the server side in every minecraft version Minecraft.getMinecraft().thePlayer.addChatMessage(new TextComponentString("Text 2")); Logs would be helpful. Quote Current Project: Armerger Planned mods: Light Drafter | Ore Swords Looking for help getting a mod off the ground? Coding | Textures Link to comment Share on other sites More sharing options...
Ringosham Posted March 23, 2016 Author Share Posted March 23, 2016 The tick event is client and server side so this line should cause a problem on the server side in every minecraft version Minecraft.getMinecraft().thePlayer.addChatMessage(new TextComponentString("Text 2")); Logs would be helpful. Interesting, that worked in the previous versions...... Oh well, thanks for the help. (Now I feel kinda dumb.) Quote Link to comment Share on other sites More sharing options...
Ernio Posted March 23, 2016 Share Posted March 23, 2016 MC#thePlayer is the client player which you control. This event is fired for server and client sides - for EVERY player in all server worlds AND for every player in MC#theWorld (client has only one world). Proper way to access player: event.player Additionally: This event has 2 phases (fired twice per tick) - use event.phase to pick ONE. Next: Learn @SideOnly: http://www.minecraftforge.net/forum/index.php/topic,22764.0.html Also: If you want to only ever use this to display stuff for MC#thePlayer - use ClientTickEvent registered from ClientProxy. That one is fired for client only and can safely use MC#thePlayer. Quote 1.7.10 is no longer supported by forge, you are on your own. Link to comment Share on other sites More sharing options...
Recommended Posts
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.