Class ScreenshotEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.client.event.ScreenshotEvent

public class ScreenshotEvent extends net.minecraftforge.eventbus.api.Event
Fired when a screenshot is taken, but before it is written to disk.

This event is cancellable, and does not 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

      private 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

      public 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(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