Skip to content

Commit 852d17a

Browse files
committed
[PlaybackSerialiser] Fixed FileCommmands#onRecord() not being called
- Enabled DesyncMonitorFileCommandExtension by default
1 parent e6f89b0 commit 852d17a

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.minecrafttas.tasmod.networking.TASmodBufferBuilder;
4343
import com.minecrafttas.tasmod.networking.TASmodPackets;
4444
import com.minecrafttas.tasmod.playback.metadata.PlaybackMetadata;
45+
import com.minecrafttas.tasmod.playback.tasfile.PlaybackSerialiser;
4546
import com.minecrafttas.tasmod.playback.tasfile.PlaybackSerialiser2;
4647
import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackLoadException;
4748
import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackSaveException;
@@ -800,8 +801,10 @@ public void onClientPacket(PacketID id, ByteBuffer buf, String username) throws
800801
try {
801802
TASmodClient.controller.setInputs(PlaybackSerialiser2.loadFromFile(new File(directory, name + ".mctas"), flavor));
802803
} catch (PlaybackLoadException e) {
803-
if (mc.world != null)
804-
mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.RED + e.getMessage()));
804+
if (mc.world != null) {
805+
TextComponentString textComponent = new TextComponentString(e.getMessage());
806+
mc.ingameGUI.getChatGUI().printChatMessage(textComponent);
807+
}
805808
LOGGER.catching(e);
806809
return;
807810
} catch (Exception e) {

src/main/java/com/minecrafttas/tasmod/playback/filecommands/PlaybackFileCommandsRegistry.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public void register(PlaybackFileCommandExtension extension) {
3636
}
3737

3838
REGISTRY.put(extension.name(), extension);
39+
enabledExtensions = getEnabled();
3940
}
4041

4142
@Override
@@ -86,16 +87,20 @@ public List<PlaybackFileCommandExtension> getEnabled() {
8687
}
8788

8889
@Override
89-
public void onPlaybackTick(long index, TickContainer container) {
90+
public void onRecordTick(long index, TickContainer container) {
9091
enabledExtensions.forEach(extension -> {
91-
extension.onRecord(index, container);
92+
if(extension.isEnabled()) {
93+
extension.onRecord(index, container);
94+
}
9295
});
9396
}
94-
97+
9598
@Override
96-
public void onRecordTick(long index, TickContainer container) {
99+
public void onPlaybackTick(long index, TickContainer container) {
97100
enabledExtensions.forEach(extension -> {
98-
extension.onPlayback(index, container);
101+
if(extension.isEnabled()) {
102+
extension.onPlayback(index, container);
103+
}
99104
});
100105
}
101106

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.minecrafttas.tasmod.TASmod;
1313
import com.minecrafttas.tasmod.TASmodClient;
1414
import com.minecrafttas.tasmod.events.EventPlaybackClient;
15-
import com.minecrafttas.tasmod.playback.PlaybackControllerClient;
1615
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TASstate;
1716
import com.minecrafttas.tasmod.playback.PlaybackControllerClient.TickContainer;
1817
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand;
@@ -38,6 +37,10 @@ public class DesyncMonitorFileCommandExtension extends PlaybackFileCommandExtens
3837

3938
private MonitorContainer currentValues;
4039

40+
public DesyncMonitorFileCommandExtension() {
41+
enabled = true;
42+
}
43+
4144
@Override
4245
public String name() {
4346
return "tasmod_desyncMonitoring@v1";
@@ -93,6 +96,7 @@ public void onDeserialiseEndlineComment(long tick, TickContainer container, Play
9396
List<PlaybackFileCommand> commandsEndline = fileCommandContainer.get("desyncMonitor");
9497
if (commandsEndline == null || commandsEndline.isEmpty()) {
9598
recordNull(tick);
99+
return;
96100
}
97101

98102
PlaybackFileCommand command = commandsEndline.get(0);

src/main/java/com/minecrafttas/tasmod/playback/tasfile/PlaybackSerialiser2.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static SerialiserFlavorBase searchForFlavor(List<String> lines, List<Seri
163163
return flavor.clone();
164164
}
165165
}
166-
throw new PlaybackLoadException("Couldn't find a flavorname in the file. TASmod is missing a flavor-extension or the file is broken");
166+
throw new PlaybackLoadException("Couldn't find a flavorname in the file. TASfile is missing a flavor-extension or the file is broken");
167167
}
168168

169169
public static SerialiserFlavorBase readFlavor(File file) throws PlaybackLoadException, IOException {

0 commit comments

Comments
 (0)