diff --git a/src/main/java/com/replaymod/simplepathing/SPTimeline.java b/src/main/java/com/replaymod/simplepathing/SPTimeline.java index f0223ed0..b3ab522c 100644 --- a/src/main/java/com/replaymod/simplepathing/SPTimeline.java +++ b/src/main/java/com/replaymod/simplepathing/SPTimeline.java @@ -107,9 +107,7 @@ public class SPTimeline implements PathingRegistry { Validate.isTrue(defaultInterpolatorType != InterpolatorType.DEFAULT, "Must not be DEFAULT"); this.defaultInterpolatorType = Validate.notNull(defaultInterpolatorType); - if (entityTracker != null) { - timeline.pushChange(updateInterpolators()); - } + timeline.pushChange(updateInterpolators()); } public Change setDefaultInterpolator(Interpolator interpolator) { @@ -521,6 +519,9 @@ public class SPTimeline implements PathingRegistry { } private Change updateSpectatorPositions() { + if (entityTracker == null) { + return CombinedChange.create(); + } List changes = new ArrayList<>(); timePath.updateAll(); for (Keyframe keyframe : positionPath.getKeyframes()) { diff --git a/src/main/java/com/replaymod/simplepathing/gui/GuiKeyframeTimeline.java b/src/main/java/com/replaymod/simplepathing/gui/GuiKeyframeTimeline.java index 413cb501..b152202b 100644 --- a/src/main/java/com/replaymod/simplepathing/gui/GuiKeyframeTimeline.java +++ b/src/main/java/com/replaymod/simplepathing/gui/GuiKeyframeTimeline.java @@ -272,7 +272,7 @@ public class GuiKeyframeTimeline extends AbstractGuiTimeline mouseDrag(position, button, timeSinceLastCall))) return true; + if (!gui.loadEntityTracker(() -> mouseDrag(position, button, timeSinceLastCall))) return true; // Threshold passed SPTimeline timeline = gui.getMod().getCurrentTimeline(); Point mouse = new Point(position); diff --git a/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java b/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java index 50730f81..87722653 100644 --- a/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java +++ b/src/main/java/com/replaymod/simplepathing/gui/GuiPathing.java @@ -265,6 +265,8 @@ public class GuiPathing { private final ReplayHandler replayHandler; private final RealtimeTimelinePlayer player; + // Whether any error which occured during entity tracker loading has already been shown to the user + private boolean errorShown; private EntityPositionTracker entityTracker; private Consumer entityTrackerLoadingProgress; private SettableFuture entityTrackerFuture; @@ -550,7 +552,7 @@ public class GuiPathing { scrollbar.setZoom(scrollbar.getZoom() * factor); } - public boolean ensureEntityTracker(Runnable withDelayedTracker) { + public boolean loadEntityTracker(Runnable thenRun) { if (entityTracker == null) { LOGGER.debug("Entity tracker not yet loaded, delaying..."); LoadEntityTrackerPopup popup = new LoadEntityTrackerPopup(replayHandler.getOverlay()); @@ -562,14 +564,21 @@ public class GuiPathing { if (mod.getCurrentTimeline().getEntityTracker() == null) { mod.getCurrentTimeline().setEntityTracker(entityTracker); } - withDelayedTracker.run(); + thenRun.run(); } @Override public void onFailure(@Nonnull Throwable t) { - String message = "Failed to load entity tracker, pathing will be unavailable."; - GuiReplayOverlay overlay = replayHandler.getOverlay(); - Utils.error(LOGGER, overlay, CrashReport.create(t, message), popup::close); + if (errorShown) { + String message = "Failed to load entity tracker, spectator keyframes will be broken."; + GuiReplayOverlay overlay = replayHandler.getOverlay(); + Utils.error(LOGGER, overlay, CrashReport.create(t, message), () -> { + popup.close(); + thenRun.run(); + }); + } else { + thenRun.run(); + } } }); return false; @@ -586,7 +595,7 @@ public class GuiPathing { */ private void updateKeyframe(SPPath path) { LOGGER.debug("Updating keyframe on path {}" + path); - if (!ensureEntityTracker(() -> updateKeyframe(path))) return; + if (!loadEntityTracker(() -> updateKeyframe(path))) return; int time = timeline.getCursorPosition(); SPTimeline timeline = mod.getCurrentTimeline(); @@ -640,7 +649,7 @@ public class GuiPathing { } public void openEditKeyframePopup(SPPath path, long time) { - if (!ensureEntityTracker(() -> openEditKeyframePopup(path, time))) return; + if (!loadEntityTracker(() -> openEditKeyframePopup(path, time))) return; Keyframe keyframe = mod.getCurrentTimeline().getKeyframe(path, time); if (keyframe.getProperties().contains(SpectatorProperty.PROPERTY)) { new GuiEditKeyframe.Spectator(this, path, keyframe.getTime()).open();