Class ScreenshotEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.ScreenshotEvent
All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent

public class ScreenshotEvent extends net.neoforged.bus.api.Event implements net.neoforged.bus.api.ICancellableEvent
Fired when a screenshot is taken, but before it is written to disk.

This event is cancellable, and does not

invalid reference
have a result
. If this event is cancelled, then the screenshot is not written to disk, and the message in the event will be posted to the player's chat.

This event is fired on the main Forge event bus, only on the logical client.

See Also:
  • Field Details

    • DEFAULT_CANCEL_REASON

      public static final Component DEFAULT_CANCEL_REASON
    • image

      private final NativeImage image
    • screenshotFile

      private File screenshotFile
    • resultMessage

      @Nullable private @Nullable Component resultMessage
  • Constructor Details

    • ScreenshotEvent

      @Internal public ScreenshotEvent(NativeImage image, File screenshotFile)
  • Method Details

    • getImage

      public NativeImage getImage()
      Returns the in-memory image of the screenshot.
      Returns:
      the in-memory image of the screenshot
    • getScreenshotFile

      public File getScreenshotFile()
      Returns:
      the file where the screenshot will be saved to
    • setScreenshotFile

      public void setScreenshotFile(File screenshotFile)
      Sets the new file where the screenshot will be saved to.
      Parameters:
      screenshotFile - the new filepath
    • getResultMessage

      @Nullable public @Nullable Component getResultMessage()
      Returns the custom cancellation message, or null if no custom message is set.
      Returns:
      the custom cancellation message, or null if no custom message is set
    • setResultMessage

      public void setResultMessage(@Nullable @Nullable Component resultMessage)
      Sets the new custom cancellation message used to inform the player. It may be null, in which case the default cancel reason will be used.
      Parameters:
      resultMessage - the new result message
    • getCancelMessage

      public Component getCancelMessage()
      Returns the cancellation message to be used in informing the player.

      If there is no custom message given (getResultMessage() returns null), then the message will be the default cancel reason message.

      Returns:
      the cancel message for the player