Posted October 11, 20204 yr Hello, I'm making a mod with forge 1.16.3. I want to get screenshot path and read it and change to base64-string. @SubscribeEvent public void onScreenShot(ScreenshotEvent event) throws IOException { byte[] data = Files.readAllBytes(event.getScreenshotFile().toPath()); String base64str = Base64.getEncoder().encodeToString(data); LOGGER.info(base64str); } But it throw java.nio.file.NoSuchFileException: [Screenshotfile.png] and crashed. ScreenShotEvent fired normally so I think that screen shot file is not created yet when event fires but I don't know how should I fix. Could you help me, please?
October 11, 20204 yr 3 hours ago, nashiroaoi said: ScreenShotEvent fired normally so I think that screen shot file is not created yet when event fires but I don't know how should I fix. The NativeImage is written to the file location after the event is called. You can specify the new location for the file if you would like. However, you want to read any information directly from the NativeImage instead of where it will be posted.
October 12, 20204 yr Author 16 hours ago, ChampionAsh5357 said: The NativeImage is written to the file location after the event is called. You can specify the new location for the file if you would like. However, you want to read any information directly from the NativeImage instead of where it will be posted. I changed byte[] data = Files.readAllBytes(event.getScreenshotFile().toPath()); to byte[] data = event.getImage().getBytes(); on my code then it completely worked! Thank you so much!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.