Make thread requirements of ReplayHandler#setup explicit and fix illegal usage
This commit is contained in:
@@ -845,11 +845,11 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
startFromBeginning = false;
|
startFromBeginning = false;
|
||||||
nextPacket = null;
|
nextPacket = null;
|
||||||
lastPacketSent = System.currentTimeMillis();
|
lastPacketSent = System.currentTimeMillis();
|
||||||
replayHandler.restartedReplay();
|
|
||||||
if (replayIn != null) {
|
if (replayIn != null) {
|
||||||
replayIn.close();
|
replayIn.close();
|
||||||
replayIn = null;
|
replayIn = null;
|
||||||
}
|
}
|
||||||
|
ReplayMod.instance.runSync(replayHandler::restartedReplay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -161,25 +161,22 @@ public class ReplayHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void restartedReplay() {
|
void restartedReplay() {
|
||||||
|
Preconditions.checkState(isOnMainThread(), "Must be called from Minecraft thread.");
|
||||||
|
|
||||||
channel.close();
|
channel.close();
|
||||||
|
|
||||||
// Force re-creation of camera entity by unloading the previous world
|
|
||||||
try {
|
|
||||||
ReplayMod.instance.runSync(() -> {
|
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
mc.mouse.unlockCursor();
|
mc.mouse.unlockCursor();
|
||||||
//#else
|
//#else
|
||||||
//$$ mc.setIngameNotInFocus();
|
//$$ mc.setIngameNotInFocus();
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
// Force re-creation of camera entity by unloading the previous world
|
||||||
//#if MC>=11400
|
//#if MC>=11400
|
||||||
mc.disconnect();
|
mc.disconnect();
|
||||||
//#else
|
//#else
|
||||||
//$$ mc.loadWorld(null);
|
//$$ mc.loadWorld(null);
|
||||||
//#endif
|
//#endif
|
||||||
});
|
|
||||||
} catch (InterruptedException | ExecutionException | TimeoutException e) {
|
|
||||||
LOGGER.error("Failed to properly restart (shutdown) replay:", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
restrictions = new Restrictions();
|
restrictions = new Restrictions();
|
||||||
|
|
||||||
@@ -236,6 +233,8 @@ public class ReplayHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setup() {
|
private void setup() {
|
||||||
|
Preconditions.checkState(isOnMainThread(), "Must be called from Minecraft thread.");
|
||||||
|
|
||||||
//#if MC>=11100
|
//#if MC>=11100
|
||||||
mc.inGameHud.getChatHud().clear(false);
|
mc.inGameHud.getChatHud().clear(false);
|
||||||
//#else
|
//#else
|
||||||
|
|||||||
Reference in New Issue
Block a user