Skip to content
This repository has been archived by the owner on Sep 7, 2024. It is now read-only.

Replays randomly fail with a null pointer exception #4

Open
nueadkie opened this issue Mar 10, 2024 · 6 comments
Open

Replays randomly fail with a null pointer exception #4

nueadkie opened this issue Mar 10, 2024 · 6 comments

Comments

@nueadkie
Copy link

Sometimes, replays fail when trying to play them. It seems to almost always happen after recording something when you just load the game, but it occasionally happens at random. The crashes always throw the exception java.lang.NullPointerException: Cannot read field "field_72995_K" because "p_i45324_1_" is null.

For reference, I am running Java 21 with the Java 17-21 installation of GTNH 2.5.1 as described in the GTNH wiki. The null pointer exception happens with both the org folder existing and being deleted from the Replay Mod.
Is this an error with just replaying the recording, or is the recording itself corrupted?

If necessary, see the files for the relevant latest.log, crash reports, replay files, and save file. I also recorded a screen-capture of what I did starting from when the game was first loaded. crash-2024-03-10_12.23.34-client.txt corresponds to the crash from replay 1 and crash-2024-03-10_12.24.09-client.txt corresponds to the crash from replay 2.

latest.log
crash-2024-03-10_12.23.34-client.txt
crash-2024-03-10_12.24.09-client.txt
Replay files: replays.zip
Save file: https://www.mediafire.com/file/l0w1k9x10vbnbak/extract_to_save_folder.zip/file

Screen-capture recording: https://youtu.be/m6r4hMrVVAY

@wohaopa
Copy link
Owner

wohaopa commented Mar 11, 2024

Have you installed replaymodfixmod? I didn’t see it in the crash report. This error should have been fixed by replaymodfixmod. This error is because the world object is not instantiated when entering the replay world. This is also happens in the replaymod of other large 1.7.10 packs. The principle of replaymod is to record all packets and re-execute them in a special world during replay. There is a way to convert a stand-alone player into a server player, which allows you to see your own model, but the packet is sent to the client too early, and the client is still loading screen.

@wohaopa
Copy link
Owner

wohaopa commented Mar 11, 2024

Thank you for the information. I now have a new understanding of this error. It should only appear when entering the replay twice after startup. When you enter the replay for the third time, you should be able to enter the first two, just like 1 or 2 in the video.

@nueadkie
Copy link
Author

It turned out to be an embarrassing oversight on my part... I originally installed GTNH for Java 8, then made a new instance for GTNH for Java 21 but forgot to copy over the .jar for replaymodfixmod😅
Sorry for the confusion!

Anyway, testing the mod properly now, it seems that under similar circumstances, this mod will catch and prevent the game from crashing when loading replays, but the player won't be rendered. The error being caught is in the snippet of the log pasted below. This is the known issue "cannot render entity in replay," right?

[22:08:22] [Client thread/ERROR] [replaymod fix mod]: NPE!: %snet.minecraft.network.play.server.S0CPacketSpawnPlayer
[22:08:22] [Client thread/ERROR] [replaymod fix mod]: catching
java.lang.NullPointerException: Cannot read field "field_72995_K" because "p_i45324_1_" is null
	at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:144) ~[yz.class:?]
	at net.minecraft.client.entity.AbstractClientPlayer.<init>(SourceFile:33) ~[blg.class:?]
	at net.minecraft.client.entity.EntityOtherPlayerMP.<init>(EntityOtherPlayerMP.java:28) ~[bll.class:?]
	at net.minecraft.client.network.NetHandlerPlayClient.func_147237_a(NetHandlerPlayClient.java:464) ~[bjb.class:?]
	at net.minecraft.network.play.server.S0CPacketSpawnPlayer.func_148833_a(SourceFile:94) ~[gb.class:?]
	at net.minecraft.network.play.server.S0CPacketSpawnPlayer.func_148833_a(SourceFile:19) ~[gb.class:?]
	at net.minecraft.network.NetworkManager.redirect$zca000$inject(NetworkManager.java:1026) [ej.class:?]
	at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212) [ej.class:?]
	at com.replaymod.replay.gui.screen.GuiOpeningReplay.func_146269_k(GuiOpeningReplay.java:16) [GuiOpeningReplay.class:?]
	at com.replaymod.replay.InputReplayTimer.func_74275_a(InputReplayTimer.java:76) [InputReplayTimer.class:?]
	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:959) [bao.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:3110) [bao.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:148) [Main.class:?]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(Unknown Source) ~[?:?]
	at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:165) [lwjgl3ify-1.5.7-forgePatches.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:29) [lwjgl3ify-1.5.7-forgePatches.jar:?]
	at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:87) [NewLaunch.jar:?]
	at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129) [NewLaunch.jar:?]
	at org.prismlauncher.EntryPoint.main(EntryPoint.java:70) [NewLaunch.jar:?]

@wohaopa
Copy link
Owner

wohaopa commented Mar 11, 2024

This error is not really perfectly fixed. I just let it not crash. I specially printed this information.

@nueadkie
Copy link
Author

One last thing I found is that after making a replay right after loading the game, when you load it, a message appears in chat Error loading entity tracker: readerIndex(1) + length(4) exceeds writerIndex(4): PooledUnsafeDirectByteBuf(ridx: 1, widx: 4, cap: 4). Again, the player won't be rendered, but it seems that this only happens for the first recording after loading the game; subsequent recordings are fine. The relevant error in the log is pasted below. Is this an issue that is similar to the error found in my previous comment? I just wanted to mention this for completeness.

[22:08:02] [Thread-54/ERROR] [com.replaymod.simplepathing.gui.GuiPathing]: Loading entity tracker:
java.lang.IndexOutOfBoundsException: readerIndex(1) + length(4) exceeds writerIndex(4): PooledUnsafeDirectByteBuf(ridx: 1, widx: 4, cap: 4)
	at com.replaymod.lib.com.github.steveice10.netty.buffer.AbstractByteBuf.checkReadableBytes0(AbstractByteBuf.java:1477) ~[AbstractByteBuf.class:?]
	at com.replaymod.lib.com.github.steveice10.netty.buffer.AbstractByteBuf.readInt(AbstractByteBuf.java:810) ~[AbstractByteBuf.class:?]
	at com.replaymod.lib.com.github.steveice10.packetlib.tcp.io.ByteBufNetInput.readInt(ByteBufNetInput.java:51) ~[ByteBufNetInput.class:?]
	at com.replaymod.replaystudio.protocol.packets.EntityId.getEntityId(EntityId.java:106) ~[EntityId.class:?]
	at com.replaymod.replaystudio.util.PacketUtils.getEntityId(PacketUtils.java:58) ~[PacketUtils.class:?]
	at com.replaymod.replaystudio.util.EntityPositionTracker.loadFromPacketData(EntityPositionTracker.java:165) ~[EntityPositionTracker.class:?]
	at com.replaymod.replaystudio.util.EntityPositionTracker.load(EntityPositionTracker.java:96) ~[EntityPositionTracker.class:?]
	at com.replaymod.simplepathing.gui.GuiPathing.lambda$startLoadingEntityTracker$6(GuiPathing.java:490) ~[GuiPathing.class:?]
	at java.base/java.lang.Thread.run(Unknown Source) [?:?]
[22:08:02] [Client thread/INFO]: [CHAT] [Replay Mod] Error loading entity tracker: readerIndex(1) + length(4) exceeds writerIndex(4): PooledUnsafeDirectByteBuf(ridx: 1, widx: 4, cap: 4)

@txzzqaz
Copy link

txzzqaz commented Apr 10, 2024

I have a rough solution but I don’t know if it is feasible: automatically run the recording every time I start the game, and then delete the recording file.This won't extend boot time too much, but I can't figure out how to do it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants