Jump to content

Recommended Posts

Posted

Hello,

 

I've recently started modding again so I'm still fairly new to the 1.13 changes.

As capabilities have changed somewhat, I'm getting stuck trying to read/write the cap data when the player first joins: I get a NullPointer when I first login after the capability gets attached. Meaning, the first login works, but any following attempts fail will crash:

net.minecraft.crash.ReportedException: Loading entity NBT
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:154) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:882) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:800) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:646) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231] {}
Caused by: java.lang.NullPointerException
	at net.minecraftforge.fml.network.PacketDistributor.lambda$playerConsumer$1(PacketDistributor.java:216) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.network.PacketDistributor$PacketTarget.send(PacketDistributor.java:178) ~[?:?] {re:classloading}
	at net.minecraftforge.fml.network.simple.SimpleChannel.send(SimpleChannel.java:118) ~[?:?] {re:classloading}
	at com.unassigned.voidmagic.common.capability.playervoid.impl.PlayerVoid.setVoidStored(PlayerVoid.java:61) ~[?:?] {re:classloading}
	at com.unassigned.voidmagic.common.capability.playervoid.PlayerVoidStorage.readNBT(PlayerVoidStorage.java:37) ~[?:?] {re:classloading}
	at com.unassigned.voidmagic.common.capability.playervoid.PlayerVoidStorage.readNBT(PlayerVoidStorage.java:10) ~[?:?] {re:classloading}
	at com.unassigned.voidmagic.common.capability.playervoid.PlayerVoidProvider.deserializeNBT(PlayerVoidProvider.java:39) ~[?:?] {re:classloading,pl:capability_inject_definalize:A}
	at com.unassigned.voidmagic.common.capability.playervoid.PlayerVoidProvider.deserializeNBT(PlayerVoidProvider.java:15) ~[?:?] {re:classloading,pl:capability_inject_definalize:A}
	at net.minecraftforge.common.capabilities.CapabilityDispatcher.deserializeNBT(CapabilityDispatcher.java:139) ~[?:?] {re:classloading}
	at net.minecraftforge.common.capabilities.CapabilityProvider.deserializeCaps(CapabilityProvider.java:96) ~[?:?] {re:classloading}
	at net.minecraft.entity.Entity.read(Entity.java:1656) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.management.PlayerList.readPlayerDataFromFile(PlayerList.java:269) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerList.initializeConnectionToPlayer(PlayerList.java:112) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:119) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:63) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:241) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:148) ~[?:?] {re:classloading}
	... 5 more

 

I should also add that it does not crash when I send the packet through other means. I do have some idea to what is causing this crash, however: the packet to update the server w/ the client is being sent while the client is not actually connected yet. I found this result through checking if the client is connected before syncing the data, however this leads to the values not being synced once the NBT is set. I just have no idea on how to fix this problem.

 

Here is the code that is within the stacktrace, and here is my github if you need to see anything else.

 

PlayerVoidStorage (Capability Storage Class):

  Reveal hidden contents

 

PlayerVoidProvider (Capability Provider Class):

  Reveal hidden contents

 

PlayerVoid (impl of IPlayerVoid):

  Reveal hidden contents

 

Posted

You should have a reference to your actual capability and only use/provide your LazyOptional for external operations.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 1/7/2020 at 2:21 AM, Cadiboo said:

You should have a reference to your actual capability and only use/provide your LazyOptional for external operations.

Expand  

Yeah, I just needed some clarification on the new LazyOptional system, as I'm still not too sure what/when to use them. So doing something like this:

                e.getCapability(PlayerVoidProvider.CAPABILITY_PLAYER_VOID).ifPresent(pv -> pv.setVoidStored(message.playerVoid));

isn't correct? Or am I mistaking what you are meaning.

 

Posted

If you know that the object exists and have access to it, you shouldn’t be using an optional. An Optional should be exposed to the rest of the world with getCapability BUT you know that your capability will never be null so you should use a direct reference in your internal code.

About Me

  Reveal hidden contents

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
  On 1/7/2020 at 5:16 AM, Cadiboo said:

If you know that the object exists and have access to it, you shouldn’t be using an optional. An Optional should be exposed to the rest of the world with getCapability BUT you know that your capability will never be null so you should use a direct reference in your internal code.

Expand  

Ok. I think I see what you are meaning, however I still don't exactly see where I'm doing anything wrong. I know when I get the capability to send the packet that the cap isn't ever null, so direct reference is fine in this case I believe.

Posted

I believe I went through and changed what needed to be changed, but I still get the same error. I did quite the rewrite to get everything in order again, and just for optimization purposes. Here is the stacktrace again:

  Reveal hidden contents

 

Here are some direct links to the proper github files, as those will house the lines where everything is happening.

CapabilityPlayerVoid

PlayerVoid

MessagePlayerVoid

 

Thank you both for your help so far.

Posted
  On 1/8/2020 at 9:17 AM, diesieben07 said:

You are trying to send a packet while being read from NBT. That does not work, the player doesn't exist fully yet, so you can't send a packet to it.

Expand  

Ah gotcha. I did the following, which is quite hacky but seems to work: I added a parameter to the setVoidStored to send the packet or not, then send the packet when the entity joins the world.

 

new readNBT within the cap:

                            instance.setVoidStored(compound.getInt("VoidStored"), false);

 

new event to send the packet after the player is done connecting:

    @SubscribeEvent
    public void onJoinWorld(EntityJoinWorldEvent event) {
        Entity e = event.getEntity();
        if(e != null) {
            if(e instanceof PlayerEntity) {
                CapabilityPlayerVoid.getPlayerVoid((PlayerEntity)e).ifPresent(IPlayerVoid::onVoidChanged);
            }
        }
    }

 

Let me know if there is a simpler way of doing it. Other than that thanks for your help!

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Is there a fix for this issue? I have tried reinstalling OpenAL.dll, switching Java versions, and even muting my game when it launched, but all of these attempts have resulted in my game crashing nonetheless. I have been dealing with this issue for approximately a week straight. I have not changed any sound settings, so I am very confused. Full Code: https://gnomebot.dev/paste/mclogs/beEBzpm "4/16/2025 12:16:30 AM 1000 Error Faulting application name: javaw.exe, version: **.**.**.**, time stamp: 23 0xd75c3041 24 Faulting module name: OpenAL.dll, version: **.**.**.**, time stamp: 0x647635a125 Exception code: 0xc0000409 26 Fault offset: 0x00000000000a2b05 27 Faulting process id: 0x10A0 28 Faulting application start time: 0x1DBAE81D04A6F2F 29 Faulting application path: C:\Users\********\curseforge\minecraft\Install\java30 \java-runtime-delta\bin\javaw.exe 31 Faulting module path: C:\Users\********\curseforge\minecraft\Install\natives\n32 eoforge-21.1.148\OpenAL.dll 33 Report Id: 28552180-f359-40cc-adeb-08dada7e99d8 34 Faulting package full name: 35 Faulting package-relative application ID:" Any sort of insight would be greatly appreciated, it's giving me a headache.
    • I'm new to this, if that wasn't obvious. My friend and I are trying to make a modpack for 1.19.2. I've made a modpack previously with 0 issues before and many of the same mods. However, I can't seem to find the issue when trying to load up his new modpack.   Any help would be greatly appreciated.
    • Im trying to make a customized modpack for just myself using the atm9 modpack as a base. It was working till recently, when curseforge force updated all the mods in the pack. Currently every time I get to the main menu I try and create a world in single player and it just says saving world. then generates a crash report.    Crash Report: https://pastebin.com/xXESPfJs   Latest Log Part 1: https://pastebin.com/Cb2VpUyr  Part 2: https://pastebin.com/9SWVn4Dx
    • Okay, for him the config file looked like this: flywheel-client.toml: #Select the backend to use. Set to "DEFAULT" to let Flywheel decide. backend = "DEFAULT" #Enable or disable instance update limiting with distance. limitUpdates = true #The number of worker threads to use. Set to -1 to let Flywheel decide. Set to 0 to disable parallelism. Requires a game restart to take effect. #Range: -1 ~ 12 workerThreads = -1 #Config options for Flywheel's built-in backends. [flw_backends]     #How smooth Flywheel's shader-based lighting should be. May have a large performance impact.     #Allowed Values: FLAT, TRI_LINEAR, SMOOTH, SMOOTH_INNER_FACE_CORRECTED     lightSmoothness = "SMOOTH" There was no "INSTANCING", so we changed "DEFAULT" to "OFF", but this didn't help. Changing it to "INSTANCING" didn't work as well.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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