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:
  • Screenshot
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final net.minecraft.network.chat.Component
     
    private final com.mojang.blaze3d.platform.NativeImage
     
    private @Nullable net.minecraft.network.chat.Component
     
    private File
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ScreenshotEvent(com.mojang.blaze3d.platform.NativeImage image, File screenshotFile)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.network.chat.Component
    Returns the cancellation message to be used in informing the player.
    com.mojang.blaze3d.platform.NativeImage
    Returns the in-memory image of the screenshot.
    @Nullable net.minecraft.network.chat.Component
    Returns the custom cancellation message, or null if no custom message is set.
     
    void
    setResultMessage(@Nullable net.minecraft.network.chat.Component resultMessage)
    Sets the new custom cancellation message used to inform the player.
    void
    setScreenshotFile(File screenshotFile)
    Sets the new file where the screenshot will be saved to.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.neoforged.bus.api.ICancellableEvent

    isCanceled, setCanceled
  • Field Details

    • DEFAULT_CANCEL_REASON

      public static final net.minecraft.network.chat.Component DEFAULT_CANCEL_REASON
    • image

      private final com.mojang.blaze3d.platform.NativeImage image
    • screenshotFile

      private File screenshotFile
    • resultMessage

      @Nullable private @Nullable net.minecraft.network.chat.Component resultMessage
  • Constructor Details

    • ScreenshotEvent

      @Internal public ScreenshotEvent(com.mojang.blaze3d.platform.NativeImage image, File screenshotFile)
  • Method Details

    • getImage

      public com.mojang.blaze3d.platform.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 net.minecraft.network.chat.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 net.minecraft.network.chat.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 net.minecraft.network.chat.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