Skip to content

Commit cefdbba

Browse files
committed
[Controller] Allow switching from playback to recording
1 parent 72ba40d commit cefdbba

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/main/java/com/minecrafttas/tasmod/handlers/PlayUntilHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ public void onPlaybackTickPre(long index) {
3535
if (playUntil != null && playUntil == index) {
3636
TASmodClient.tickratechanger.pauseGame(true);
3737
PlaybackControllerClient controller = TASmodClient.controller;
38-
controller.setTASState(TASstate.NONE);
38+
controller.setTASState(TASstate.RECORDING);
3939
controller.setIndex(controller.index() - 1);
4040
for (long i = controller.size() - 1; i >= index; i--) {
4141
controller.remove(i);
4242
}
43-
controller.setTASState(TASstate.RECORDING);
4443
playUntil = null;
4544
}
4645
}

src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerClient.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,18 @@ public String setTASStateClient(TASstate stateIn, boolean verbose) {
237237
case PLAYBACK:
238238
return TextFormatting.RED + "Please report this message to the mod author, because you should never be able to see this (Error: Playback)";
239239
case RECORDING:
240-
return verbose ? TextFormatting.RED + "A playback is currently running. Please stop the playback first before starting a recording" : "";
240+
stopPlayback(false);
241+
startRecording();
242+
state = TASstate.RECORDING;
243+
return verbose ? TextFormatting.GREEN + "Switching from playback to recording" : "";
241244
case PAUSED:
242245
LOGGER.debug(LoggerMarkers.Playback, "Pausing a playback");
243246
state = TASstate.PAUSED;
244247
stateAfterPause = TASstate.PLAYBACK;
245248
TASmodClient.virtual.clear();
246249
return verbose ? TextFormatting.GREEN + "Pausing a playback" : "";
247250
case NONE:
248-
stopPlayback();
251+
stopPlayback(true);
249252
state = TASstate.NONE;
250253
return verbose ? TextFormatting.GREEN + "Stopping the playback" : "";
251254
}
@@ -298,10 +301,12 @@ private void startPlayback() {
298301
// TASmod.ktrngHandler.setInitialSeed(startSeed);
299302
}
300303

301-
private void stopPlayback() {
304+
private void stopPlayback(boolean clearInputs) {
302305
LOGGER.debug(LoggerMarkers.Playback, "Stopping a playback");
303306
Minecraft.getMinecraft().gameSettings.chatLinks = true;
304-
TASmodClient.virtual.clear();
307+
if (clearInputs) {
308+
TASmodClient.virtual.clear();
309+
}
305310
}
306311

307312
/**

src/main/java/com/minecrafttas/tasmod/playback/PlaybackControllerServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void setState(TASstate stateIn) {
8888

8989
public void setServerState(TASstate stateIn) {
9090
if (state != stateIn) {
91-
if (state == TASstate.RECORDING && stateIn == TASstate.PLAYBACK || state == TASstate.PLAYBACK && stateIn == TASstate.RECORDING)
91+
if (state == TASstate.RECORDING && stateIn == TASstate.PLAYBACK)
9292
return;
9393
if (state == TASstate.NONE && state == TASstate.PAUSED) {
9494
return;

0 commit comments

Comments
 (0)