#How to automate screenshots?

10 messages · Page 1 of 1 (latest)

sand musk
#

I want to take screenshots when certain events occur, such as reaching a certain coordinate or completing a achievement.
For example, if I get a diamond, I want a screenshot called DIAMONDS.png.

It seems like there should be a class like https://mcstreetguy.github.io/ForgeJavaDocs/1.20.1-latest/net/minecraft/client/Screenshot.html, so it seems like it should be possible in some way, but I don't know how to do it in detail. I tried calling takeScreenshot(), but it didn't work.

Does anyone have a good way to do it?

light monolithBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

sand musk
#

I don't know how to do it. Maybe I can simulate pressing f12?
But even if I could do that, what I want to do is save it with a specific file name. When I press f12, I can't save it with a specific name.

#

Anyone have any good ideas?

sand musk
#

According to https://mcstreetguy.github.io/ForgeJavaDocs/1.20.1-latest/net/minecraft/client/Screenshot.html, there is a method called
grab(File p_92296_, String p_92297_, RenderTarget p_92300_, Consumer<Component> p_92301_).
I think this is the method to take a screenshot.

const $screenshot = Java.loadClass('net.minecraft.client.Screenshot')

ClientEvents.tick(e => {
    $screenshot.grab(Client.gameDirectory, String(new Date()), Client.mainRenderTarget, Text.of(new Date()))
})

However, an error occurs even though I used the source code above.
This should be correct according to the docs, but something is strange...

#
src/test.js#7: Error in 'ClientEvents.tick': Can't find method net.minecraft.client.Screenshot.m_92289_(java.io.File,string,com.mojang.blaze3d.pipeline.MainTarget,net.minecraft.network.chat.MutableComponent).
…rhino.EvaluatorException: Can't find method net.minecraft.client.Screenshot.m_92289_(java.io.File,string,com.mojang.blaze3d.pipeline.MainTarget,net.minecraft.network.chat.MutableComponent). (client_scripts:src/test.js#7)
  at …rhino.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:67)
  at …rhino.Context.reportRuntimeError(Context.java:133)
  at …rhino.Context.reportRuntimeError(Context.java:173)
  at …rhino.Context.reportRuntimeError1(Context.java:145)
  at …rhino.NativeJavaMethod.call(NativeJavaMethod.java:379)
  at …rhino.Interpreter.interpretLoop(Interpreter.java:986)
  at script(client_scripts:src/test.js:7)
  at …rhino.Interpreter.interpret(Interpreter.java:370)
  at …rhino.InterpretedFunction.call(InterpretedFunction.java:72)
  at …rhino.Context.callSync(Context.java:1290)
  at …rhino.Context.doTopCall(Context.java:1307)
  at …rhino.InterpretedFunction.call(InterpretedFunction.java:70)
  at …rhino.Context.callSync(Context.java:1290)
  at …rhino.ArrowFunction.call(ArrowFunction.java:42)
  at …rhino.Context.callSync(Context.java:1290)
  at …rhino.InterfaceAdapter.invoke(InterfaceAdapter.java:125)
  at …rhino.VMBridge.lambda$newInterfaceProxy$0(VMBridge.java:74)
  at TRANSFORMER/jdk.proxy3/jdk.proxy3.$Proxy86.onEvent(Unknown Source)
  at …kubejs.event.EventHandlerContainer.handle(EventHandlerContainer.java:39)
  at …kubejs.event.EventHandler.postToHandlers(EventHandler.java:304)
  at …kubejs.event.EventHandler.post(EventHandler.java:272)
  at …kubejs.event.EventHandler.post(EventHandler.java:226)
  at …kubejs.event.EventHandler.post(EventHandler.java:189)
  at net.minecraft.client.Minecraft.handler$dno000$kjs$postTickClient(Minecraft.java:13980)
  at net.minecraft.client.Minecraft.m_91398_(Minecraft.java:1876)
#
  at net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1112)
  at net.minecraft.client.Minecraft.m_91374_(Minecraft.java:718)
  at net.minecraft.client.main.Main.main(Main.java:218)
  at java.lang.reflect.Method.invoke(Method.java:568)
  at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.runTarget(CommonLaunchHandler.java:111)
  at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonLaunchHandler.clientService(CommonLaunchHandler.java:99)
  at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$makeService$0(CommonClientLaunchHandler.java:25)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:108)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:78)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
  at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
  at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141)
#

This is error logs

#

Does anyone know anything?

#

I'm sure someone has thought of something like this in some way, but there's no data or examples. It doesn't seem impossible, but I don't know what the problem is...