Skip to content

Commit a938c7d

Browse files
authored
[Commands] Fix corruption when trying to use restartandplay under certain conditions (#252)
2 parents e18f943 + f70d57d commit a938c7d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/main/java/com/minecrafttas/tasmod/commands/CommandRestartAndPlay.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.minecrafttas.tasmod.networking.TASmodBufferBuilder;
1111
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
1212
import com.minecrafttas.tasmod.registries.TASmodPackets;
13+
import com.minecrafttas.tasmod.savestates.SavestateHandlerServer.SavestateState;
1314
import com.minecrafttas.tasmod.savestates.exceptions.LoadstateException;
1415

1516
import net.minecraft.client.Minecraft;
@@ -50,9 +51,21 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
5051
try {
5152
TASmod.savestateHandlerServer.loadState(0, false);
5253
} catch (LoadstateException e) {
53-
e.printStackTrace();
54+
TASmod.LOGGER.catching(e);
55+
if (e.getMessage() != null) {
56+
sender.sendMessage(new TextComponentString(TextFormatting.RED + "Could not load the initial savestate: " + e.getMessage()));
57+
}
58+
TASmod.savestateHandlerServer.state = SavestateState.NONE;
59+
TASmod.tickratechanger.pauseGame(false);
60+
return;
5461
} catch (IOException e) {
55-
e.printStackTrace();
62+
TASmod.LOGGER.catching(e);
63+
if (e.getMessage() != null) {
64+
sender.sendMessage(new TextComponentString(TextFormatting.RED + "Could not load the initial savestate: " + e.getMessage()));
65+
}
66+
TASmod.savestateHandlerServer.state = SavestateState.NONE;
67+
TASmod.tickratechanger.pauseGame(false);
68+
return;
5669
}
5770
TASmod.playbackControllerServer.setServerState(TASstate.PLAYBACK);
5871
try {

src/main/java/com/minecrafttas/tasmod/tickratechanger/TickrateChangerServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public void togglePause() {
145145
}
146146

147147
/**
148-
* Enables tickrate 0
148+
* Enables/Disables tickrate 0 on both client and server
149149
*
150150
* @param pause True if the game should be paused, false if unpause
151151
*/

0 commit comments

Comments
 (0)