33import java .io .File ;
44import java .io .IOException ;
55
6+ import com .mojang .realmsclient .gui .ChatFormatting ;
7+
68import de .scribble .lp .tasmod .ClientProxy ;
79import de .scribble .lp .tasmod .CommonProxy ;
10+ import de .scribble .lp .tasmod .TASmod ;
811import de .scribble .lp .tasmod .inputcontainer .InputContainer ;
912import de .scribble .lp .tasmod .savestates .server .exceptions .SavestateException ;
13+ import de .scribble .lp .tasmod .util .TASstate ;
14+ import net .minecraft .client .Minecraft ;
15+ import net .minecraft .util .text .TextComponentString ;
1016import net .minecraftforge .fml .relauncher .Side ;
1117import net .minecraftforge .fml .relauncher .SideOnly ;
1218
@@ -43,9 +49,9 @@ public static void savestate(String nameOfSavestate) throws SavestateException,
4349
4450 InputContainer container = ClientProxy .virtual .getContainer ();
4551 if (container .isRecording ()) {
46- ClientProxy .serialiser .saveToFileV1 (targetfile , container );
52+ ClientProxy .serialiser .saveToFileV1 (targetfile , container ); //If the container is recording, store it entirely
4753 } else if (container .isPlayingback ()){
48- ClientProxy .serialiser .saveToFileV1Until (targetfile , container , container .index ());
54+ ClientProxy .serialiser .saveToFileV1Until (targetfile , container , container .index ()); //If the container is playing, store it until the current index
4955 }
5056 }
5157
@@ -68,10 +74,16 @@ public static void loadstate(String nameOfSavestate) throws IOException {
6874
6975 File targetfile = new File (savestateDirectory , nameOfSavestate + ".tas" );
7076
71- if (!targetfile .exists ()) {
72- ClientProxy .virtual .getContainer ().clear ();
73- } else {
74- ClientProxy .virtual .loadSavestate (ClientProxy .serialiser .fromEntireFileV1 (targetfile ));
77+ InputContainer container = ClientProxy .virtual .getContainer ();
78+ if (!container .isNothingPlaying ()) { // If the file exists and the container is recording or playing, load the clientSavestate
79+ if (targetfile .exists ()) {
80+ ClientProxy .virtual .loadClientSavestate (ClientProxy .serialiser .fromEntireFileV1 (targetfile ));
81+ } else {
82+ ClientProxy .virtual .getContainer ().setTASState (TASstate .NONE , false );
83+ Minecraft .getMinecraft ().player .sendMessage (new TextComponentString (ChatFormatting .YELLOW
84+ + "Inputs could not be loaded for this savestate, since the file doesn't exist. Stopping!" ));
85+ TASmod .logger .warn ("Inputs could not be loaded for this savestate, since the file doesn't exist." );
86+ }
7587 }
7688 }
7789}
0 commit comments