Tropicraft

Tropicraft

9M Downloads

TropicalBook fails to load with ReplayMod

Johni0702 opened this issue ยท 0 comments

commented

Issue Description

The ReplayMod allows users to record and replay their game sessions (it does that by recording and replaying packets sent from the server).
Trying to open such a replay with Tropicraft installed, will cause an IllegalStateException while loading the TropicalBook (see below) because the client isn't actually connected to any server (i.e. Minecraft.getCurrentServerData() returns null).

ServerData server = Minecraft.getMinecraft().getCurrentServerData();
if (server == null) {
throw new IllegalStateException("Cannot load encyclopedia outside of a game!");
}
// FIXME Encyclopedia save data breaks if the client changes the server name
// Needs to be moved to serverside storage
return Paths.get("encyclopedia-servers", server.serverName, fileName).toFile();

(Storing the book data server-side as suggested by the FIXME would ofc also fix this issue if that's something you were wanting to do anyway)

Steps to Reproduce

  1. Install RM+Tropicraft
  2. Enter SP
  3. Exit SP
  4. Enter replay
  5. Replay doesn't open due to exception below

Tropicraft Version: Can confirm for 7.1.9, reported for any 1.12.2 version except 7.1.0
RM Version: Any version

Crash log

[17:49:18] [Client thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.world.WorldEvent$Load@7d014da1:
java.lang.IllegalStateException: Cannot load encyclopedia outside of a game!
	at net.tropicraft.core.encyclopedia.TropicalBook.getSaveFile(TropicalBook.java:88) ~[TropicalBook.class:?]
	at net.tropicraft.core.encyclopedia.TropicalBook.loadData(TropicalBook.java:104) ~[TropicalBook.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_61_TropicalBook_loadData_Load.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) [EventBus.class:?]
	at net.minecraft.client.multiplayer.WorldClient.<init>(WorldClient.java:75) [bsb.class:?]
	at net.minecraft.client.network.NetHandlerPlayClient.func_147282_a(NetHandlerPlayClient.java:298) [brz.class:?]
	at net.minecraft.network.play.server.SPacketJoinGame.func_148833_a(SourceFile:76) [jh.class:?]
	at net.minecraft.network.play.server.SPacketJoinGame.func_148833_a(SourceFile:13) [jh.class:?]
	at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_212]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_212]
	at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?]
	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1088) [bib.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398) [bib.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:123) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]