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 my mod is not syncing the client side after respawn properly because the capabilities to receive the data have not been attached on the client yet. I get logs like this:

 

    [21Jan2023 15:18:13.229] [Server thread/INFO] [org.xire.joko.stats_and_skills.StatsNSkills/]: Cloned player stats.
    [21Jan2023 15:18:13.230] [Server thread/ERROR] [org.xire.joko.stats_and_skills.StatsNSkills/]: Reduced stats for player JontomXire because of death.
    [21Jan2023 15:18:13.244] [Render thread/ERROR] [org.xire.joko.stats_and_skills.StatsNSkills/]: Capabilities missing when syncing data for player JontomXire.
 

To try and solve this, I send a message to the server when handling AttachCapabilitiesEvent on the client. The problem is that when initially logging on, the network does not seem to be initialised. I get this error:

 

    [21Jan2023 15:25:19.507] [Render thread/ERROR] [net.minecraftforge.eventbus.EventBus/EVENTBUS]: Exception caught during firing event: Cannot invoke "net.minecraft.client.multiplayer.ClientPacketListener.m_6198_()" because the return value of "net.minecraft.client.Minecraft.m_91403_()" is null
        Index: 1
        Listeners:
            0: NORMAL
            1: ASM: class org.xire.joko.stats_and_skills.PlayerData onAttachCapability(Lnet/minecraftforge/event/AttachCapabilitiesEvent;)V
    java.lang.NullPointerException: Cannot invoke "net.minecraft.client.multiplayer.ClientPacketListener.m_6198_()" because the return value of "net.minecraft.client.Minecraft.m_91403_()" is null
    at TRANSFORMER/[email protected]/net.minecraftforge.network.simple.SimpleChannel.sendToServer(SimpleChannel.java:87)
 

So I either need a way to work out if this call will work or crash:

    INSTANCE.sendToServer(msg);

where INSTANCE is:

    private static final ResourceLocation RESOURCE = new ResourceLocation(StatsNSkills.MODID, "comms");
    private static final String           VERSION  = "1";
    private static final SimpleChannel    INSTANCE = NetworkRegistry.newSimpleChannel(RESOURCE,
                                                                                      () -> VERSION,
                                                                                      VERSION::equals,
                                                                                      VERSION::equals);

 

Or a better trigger to send the sync packet from the server side after respawn.


 

People that post snippets of incomplete code will usually just be ignored.

That is unless the error is trivially obvious from what you post.

You need to show all relevant code, preferably on github.

We don't play guessing games with you to try to figure out what the problem is.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

  • Author

https://gitlab.com/JontomXire/stats-and-skills

 

I actually did include all relevant bits of code, just not all the superfluous context.

 

I would imagine that a quick look, by someone that has access to the source code and knows how it is all laid out, at SimpleChannel.java:87 would be very illuminating. And that the error message, read by someone who understands that part of the Forge code, would allow them to immediately identify the problem and a solution.

Edited by Jontom Xire

  • Author

The answer is to change the call to send to server to be like this:

 

        if (null != Minecraft.getInstance().getConnection()) {
            INSTANCE.sendToServer(msg);
        }

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.