Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void run() {

@SubscribeEvent
static void registerNetwork(RegisterPayloadHandlersEvent event) {
final PayloadRegistrar registrar = event.registrar("1");
final PayloadRegistrar registrar = event.registrar("1").optional();
registrar.commonToClient(Restrictions.ID, Restrictions.CODEC, (payload, context) -> {});
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/replaymod/render/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public final class Setting<T> {
new SettingsRegistry.SettingKeys<>("advanced", "skipPostRenderGui", null, false);
public static final SettingsRegistry.SettingKey<Boolean> FRAME_TIME_FROM_WORLD_TIME =
new SettingsRegistry.SettingKeys<>("render", "frameTimeFromWorldTime", null, false);
public static final SettingsRegistry.SettingKey<Integer> SKIN_PRELOAD_DELAY =
new SettingsRegistry.SettingKeys<>("render", "skinPreloadDelay", null, 3);
}
15 changes: 12 additions & 3 deletions src/main/java/com/replaymod/render/rendering/VideoRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.replaymod.render.PNGWriter;
import com.replaymod.render.RenderSettings;
import com.replaymod.render.ReplayModRender;
import com.replaymod.render.Setting;
import com.replaymod.render.FFmpegWriter;
import com.replaymod.render.blend.BlendState;
import com.replaymod.render.capturer.RenderInfo;
Expand Down Expand Up @@ -196,18 +197,26 @@ public boolean renderVideo() throws Throwable {

ReplayTimer timer = (ReplayTimer) ((MinecraftAccessor) mc).getTimer();

// Play up to one second before starting to render
// Play up to several seconds before starting to render
// This is necessary in order to ensure that all entities have at least two position packets
// and their first position in the recording is correct.
// Additionally, this gives time for player skins to load from the network.
// Note that it is impossible to also get the interpolation between their latest position
// and the one in the recording correct as there's no reliable way to tell when the server ticks
// or when we should be done with the interpolation of the entity
int preloadDelaySeconds = 3; // Default value, try to read from config
try {
preloadDelaySeconds = ReplayModRender.instance.getCore().getSettingsRegistry().get(Setting.SKIN_PRELOAD_DELAY);
} catch (Exception e) {
LOGGER.warn("Failed to load skin preload delay setting, using default value of 3 seconds", e);
}
int preloadDelayMs = preloadDelaySeconds * 1000;
Optional<Integer> optionalVideoStartTime = timeline.getValue(TimestampProperty.PROPERTY, 0);
if (optionalVideoStartTime.isPresent()) {
int videoStart = optionalVideoStartTime.get();

if (videoStart > 1000) {
int replayTime = videoStart - 1000;
if (videoStart > preloadDelayMs) {
int replayTime = videoStart - preloadDelayMs;
//#if MC>=11200
timer.tickDelta = 0;
((TimerAccessor) timer).setTickLength(DEFAULT_MS_PER_TICK);
Expand Down