Properly handle OOMExceptions when creating a 360° screenshot
This commit is contained in:
@@ -11,6 +11,7 @@ import com.replaymod.replay.events.ReplayDispatchKeypressesEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiControls;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ScreenShotHelper;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -51,13 +52,14 @@ public class AdvancedScreenshots implements Extra {
|
||||
}
|
||||
|
||||
private void createEquirectangularScreenshot() {
|
||||
try {
|
||||
// take 360° screenshot
|
||||
File screenshotFolder = new File(mc.mcDataDir, "screenshots");
|
||||
screenshotFolder.mkdir();
|
||||
File screenshotFile = ScreenShotHelper.getTimestampedPNGFileForDirectory(screenshotFolder);
|
||||
|
||||
int width = 8640;
|
||||
int height = 4320;
|
||||
int height = 4 * 4320;
|
||||
int width = 2 * height;
|
||||
|
||||
int displayWidthBefore = mc.displayWidth;
|
||||
int displayHeightBefore = mc.displayHeight;
|
||||
@@ -97,5 +99,10 @@ public class AdvancedScreenshots implements Extra {
|
||||
mc.resize(displayWidthBefore, displayHeightBefore);
|
||||
|
||||
new GuiUploadScreenshot(ReplayModReplay.instance.getReplayHandler().getOverlay(), mod, screenshotFile).open();
|
||||
} catch (OutOfMemoryError e) {
|
||||
e.printStackTrace();
|
||||
CrashReport report = CrashReport.makeCrashReport(e, "Creating Equirectangular Screenshot");
|
||||
Minecraft.getMinecraft().crashed(report);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.replaymod.extras.ReplayModExtras;
|
||||
import com.replaymod.render.frame.RGBFrame;
|
||||
import com.replaymod.render.rendering.FrameConsumer;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
@@ -40,6 +41,10 @@ public class ScreenshotWriter implements FrameConsumer<RGBFrame> {
|
||||
}
|
||||
|
||||
ImageIO.write(img, "PNG", outputFile);
|
||||
} catch (OutOfMemoryError e) {
|
||||
e.printStackTrace();
|
||||
CrashReport report = CrashReport.makeCrashReport(e, "Exporting frame");
|
||||
Minecraft.getMinecraft().crashed(report);
|
||||
} catch (Throwable t) {
|
||||
CrashReport report = CrashReport.makeCrashReport(t, "Exporting frame");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user