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 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:
- 
Nested Class SummaryNested classes/interfaces inherited from class net.neoforged.bus.api.Eventnet.neoforged.bus.api.Event.HasResult, net.neoforged.bus.api.Event.Result
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Componentprivate final NativeImageprivate @Nullable Componentprivate File
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionReturns the cancellation message to be used in informing the player.getImage()Returns the in-memory image of the screenshot.@Nullable ComponentReturns the custom cancellation message, ornullif no custom message is set.voidsetResultMessage(@Nullable Component resultMessage) Sets the new custom cancellation message used to inform the player.voidsetScreenshotFile(File screenshotFile) Sets the new file where the screenshot will be saved to.Methods inherited from class net.neoforged.bus.api.EventgetResult, hasResult, setResultMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.bus.api.ICancellableEventisCanceled, setCanceled
- 
Field Details- 
DEFAULT_CANCEL_REASON
- 
image
- 
screenshotFile
- 
resultMessage
 
- 
- 
Constructor Details- 
ScreenshotEvent
 
- 
- 
Method Details- 
getImageReturns the in-memory image of the screenshot.- Returns:
- the in-memory image of the screenshot
 
- 
getScreenshotFile- Returns:
- the file where the screenshot will be saved to
 
- 
setScreenshotFileSets the new file where the screenshot will be saved to.- Parameters:
- screenshotFile- the new filepath
 
- 
getResultMessageReturns the custom cancellation message, ornullif no custom message is set.- Returns:
- the custom cancellation message, or nullif no custom message is set
 
- 
setResultMessageSets the new custom cancellation message used to inform the player. It may benull, in which case the default cancel reason will be used.- Parameters:
- resultMessage- the new result message
 
- 
getCancelMessageReturns the cancellation message to be used in informing the player.If there is no custom message given ( getResultMessage()returnsnull), then the message will be the default cancel reason message.- Returns:
- the cancel message for the player
 
 
-