Jump to content

[1.7.2]Crash on player.addChatComponentMessage


DuskFall

Recommended Posts

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?

Link to comment
Share on other sites

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_));

    }

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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