Fixed Race Condition which locked the user in the GuiReplaySaving caused by Minecraft opening the GUI in a delayed thread
This commit is contained in:
@@ -2,7 +2,6 @@ package eu.crushedpixel.replaymod.events;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.gui.GuiConstants;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
||||
import eu.crushedpixel.replaymod.gui.GuiReplaySettings;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiLoginPrompt;
|
||||
import eu.crushedpixel.replaymod.gui.online.GuiReplayCenter;
|
||||
@@ -37,15 +36,7 @@ public class GuiEventHandler {
|
||||
private static final Color DARK_RED = Color.decode("#DF0101");
|
||||
private static final Color DARK_GREEN = Color.decode("#01DF01");
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final List<Class> allowedGUIs = new ArrayList<Class>() {
|
||||
{
|
||||
add(GuiReplaySettings.class);
|
||||
add(GuiReplaySaving.class);
|
||||
add(GuiIngameMenu.class);
|
||||
add(GuiOptions.class);
|
||||
add(GuiVideoSettings.class);
|
||||
}
|
||||
};
|
||||
|
||||
public int replayCount = 0;
|
||||
private GuiButton editorButton;
|
||||
|
||||
@@ -68,11 +59,6 @@ public class GuiEventHandler {
|
||||
if(ReplayHandler.isInReplay()) ReplayHandler.setInReplay(false);
|
||||
}
|
||||
|
||||
if(event.gui != null && ReplayMod.replayFileAppender.isBusy() && !allowedGUIs.contains(event.gui.getClass())) {
|
||||
event.gui = new GuiReplaySaving(event.gui);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!AuthenticationHandler.isAuthenticated()) return;
|
||||
|
||||
if(event.gui instanceof GuiChat || event.gui instanceof GuiInventory) {
|
||||
|
||||
@@ -18,6 +18,12 @@ public class GuiReplaySaving extends GuiScreen {
|
||||
ReplayMod.replayFileAppender.addFinishListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorldAndResolution(Minecraft mc, int width, int height) {
|
||||
super.setWorldAndResolution(mc, width, height);
|
||||
ReplayMod.replayFileAppender.callListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
|
||||
@@ -164,7 +164,6 @@ public class GuiVideoRenderer extends GuiScreen {
|
||||
drawString(fontRendererObj, leftString, width - 12 - fontRendererObj.getStringWidth(leftString),
|
||||
previewCheckBox.yPosition + 5 + 20, Color.WHITE.getRGB());
|
||||
|
||||
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ public class ReplayFileAppender extends Thread {
|
||||
@Override
|
||||
public void run() {
|
||||
final GuiReplaySaving savingScreen = new GuiReplaySaving(null);
|
||||
|
||||
Minecraft.getMinecraft().displayGuiScreen(savingScreen);
|
||||
}
|
||||
});
|
||||
@@ -96,7 +95,7 @@ public class ReplayFileAppender extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
private void callListeners() {
|
||||
public void callListeners() {
|
||||
if(filesToMove.isEmpty() && !newReplayFileWriting) {
|
||||
for(final GuiReplaySaving gui : listeners) {
|
||||
Minecraft.getMinecraft().addScheduledTask(new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user