Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

  • Author

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

    }

  • Author

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)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.