DuskFall Posted March 3, 2014 Posted March 3, 2014 So for some reason, i'm getting a npe in in my sendChatToPlayer function, but it was working previously. Here's all it is : public static void sendChatToPlayer(EntityPlayer player, String message) { player.addChatComponentMessage(new ChatComponentText(message)); } And the stacktrace is : Caused by: java.lang.NullPointerException at net.minecraft.entity.player.EntityPlayerMP.addChatComponentMessage(EntityPlayerMP.java:987) ~[EntityPlayerMP.class:?] at mymod.util.ChatMessageHandler.sendChatToPlayer(ChatMessageHandler.java:33) ~[ChatMessageHandler.class:?] The line it fails at is : this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); in the EntityPlayerMP class in the net.minecraft.blah.blah bit. Whats going wrong? Quote
DuskFall Posted March 3, 2014 Author Posted March 3, 2014 I personally wasnt calling that, the player.addChatComponentMessage(new ChatComponentText(message)) calls it. As in, the function addChatComponentMessage is as follows : public void addChatComponentMessage(IChatComponent p_146105_1_) { this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_)); } Quote
DuskFall Posted March 3, 2014 Author Posted March 3, 2014 I call sendChatToPlayer(EntityPlayer player, String message) in er, almost everywhere, but the problem is in my "setSkill" method in my ExtendedEntityProperties. The method is : public void setSkill(Skill lookup, int i, EntityPlayer player) { Side side = FMLCommonHandler.instance().getEffectiveSide(); RSLogging.log(this.getClass(), "Increasing level"); if (side == Side.CLIENT) { RSLogging.log(this.getClass(), "So not doing anything"); } else { this.SkillAmounts[lookup.ordinal()] = i; this.ExpAmounts[lookup.ordinal()] = this.limits[i - 1]; RSChatMessageHandler.sendChatToPlayer(player, "Congratulations, you are now " + this.getSkill(lookup) +" " + lookup.name().toLowerCase()); } } (RSLogging.log takes the class and a message, and prints the class, effective side and message) Quote
DuskFall Posted March 3, 2014 Author Posted March 3, 2014 I havent solved it, but i found a work around that suits me fine Quote
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.