Skip to content

Commit 33e99f3

Browse files
committed
[PlaybackController] Fix continuing recording desyncing
- Breaking playuntil
1 parent 3db6ada commit 33e99f3

File tree

6 files changed

+31
-45
lines changed

6 files changed

+31
-45
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@ public void execute(MinecraftServer server, ICommandSender sender, String[] args
4040
sender.sendMessage(new TextComponentString("Stops the next playback one tick before the specified tick and lets you record from there:\n\n/playuntil 10, runs the playback until tick 9 and will record from there. Useful when you can't savestate"));
4141
}
4242
}
43-
4443
}

src/main/java/com/minecrafttas/tasmod/events/EventPlaybackClient.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import com.minecrafttas.mctcommon.events.EventListenerRegistry.EventBase;
44
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
5-
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
65
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.InputContainer;
6+
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
77

88
public interface EventPlaybackClient {
99

@@ -84,4 +84,18 @@ public interface EventRecordClear extends EventBase {
8484
*/
8585
public void onRecordingClear();
8686
}
87+
88+
/**
89+
* Fired when an input is deleted
90+
*/
91+
@FunctionalInterface
92+
public interface EventInputDelete extends EventBase {
93+
94+
/**
95+
* Fired when an input is deleted
96+
*
97+
* @param The index of the input
98+
*/
99+
public void onInputDelete(long index);
100+
}
87101
}

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

Lines changed: 0 additions & 38 deletions
This file was deleted.

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ public class PlayUntilHandler implements ClientPacketHandler, ServerPacketHandle
3333
@Override
3434
public void onPlaybackTick(long index, InputContainer container) {
3535
/* Playuntil logic */
36-
if (playUntil != null && playUntil == index + 1) {
36+
if (playUntil != null && playUntil == index) {
3737
TASmodClient.tickratechanger.pauseGame(true);
3838
PlaybackControllerClient controller = TASmodClient.controller;
3939
playUntil = null;
4040
controller.setTASState(TASstate.NONE);
41+
controller.unpressContainer();
42+
controller.setIndex(controller.index() - 1);
4143
for (long i = controller.size() - 1; i >= index; i--) {
42-
controller.getInputs().remove(i);
44+
controller.remove(i);
4345
}
44-
index--;
4546
controller.setTASState(TASstate.RECORDING);
4647
return;
4748
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ private void playbackNextTick() {
490490

491491
/* Stop condition */
492492
if (index == inputs.size() || inputs.isEmpty()) {
493+
index--;
493494
unpressContainer();
494495
setTASState(TASstate.NONE);
495496
}
@@ -501,7 +502,6 @@ private void playbackNextTick() {
501502
this.camera = container.getCameraAngle().clone();
502503
EventListenerRegistry.fireEvent(EventPlaybackTick.class, index, container);
503504
}
504-
505505
}
506506
// =====================================================================================================
507507
// Methods to manipulate inputs
@@ -518,6 +518,11 @@ public long index() {
518518
return index;
519519
}
520520

521+
public void remove(long index) {
522+
inputs.remove(index);
523+
EventListenerRegistry.fireEvent(EventPlaybackClient.EventInputDelete.class, index);
524+
}
525+
521526
public BigArrayList<InputContainer> getInputs() {
522527
return inputs;
523528
}

src/main/java/com/minecrafttas/tasmod/playback/filecommands/builtin/DesyncMonitorFileCommandExtension.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @author Scribble
3030
*/
31-
public class DesyncMonitorFileCommandExtension extends PlaybackFileCommandExtension implements EventPlaybackClient.EventControllerStateChange {
31+
public class DesyncMonitorFileCommandExtension extends PlaybackFileCommandExtension implements EventPlaybackClient.EventControllerStateChange, EventPlaybackClient.EventInputDelete {
3232

3333
/**
3434
* List containing {@link MonitorContainer MonitorContainers} in a TASfile
@@ -365,4 +365,9 @@ public void onClear() {
365365
lastPos = "";
366366
lastMotion = "";
367367
}
368+
369+
@Override
370+
public void onInputDelete(long index) {
371+
monitorContainer.remove(index);
372+
}
368373
}

0 commit comments

Comments
 (0)