-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
patches/minecraft/net/minecraft/util/ScreenShotHelper.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- ../src-base/minecraft/net/minecraft/util/ScreenShotHelper.java | ||
+++ ../src-work/minecraft/net/minecraft/util/ScreenShotHelper.java | ||
@@ -52,10 +52,13 @@ | ||
file2 = new File(file1, p_148259_1_); | ||
} | ||
|
||
+ net.minecraftforge.client.event.ScreenshotEvent event = net.minecraftforge.client.ForgeHooksClient.onScreenshot(bufferedimage, file2); | ||
+ if (event.isCanceled()) return event.getCancelMessage(); else file2 = event.getScreenshotFile(); | ||
ImageIO.write(bufferedimage, "png", (File)file2); | ||
ITextComponent itextcomponent = new TextComponentString(file2.getName()); | ||
itextcomponent.func_150256_b().func_150241_a(new ClickEvent(ClickEvent.Action.OPEN_FILE, file2.getAbsolutePath())); | ||
itextcomponent.func_150256_b().func_150228_d(Boolean.valueOf(true)); | ||
+ if (event.getResultMessage() != null) return event.getResultMessage(); | ||
return new TextComponentTranslation("screenshot.success", new Object[] {itextcomponent}); | ||
} | ||
catch (Exception exception) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/net/minecraftforge/client/event/ScreenshotEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package net.minecraftforge.client.event; | ||
|
||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.TextComponentString; | ||
import net.minecraftforge.fml.common.eventhandler.Cancelable; | ||
import net.minecraftforge.fml.common.eventhandler.Event; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
|
||
/** | ||
* This event is fired before and after a screenshot is taken | ||
* This event is fired on the {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS} | ||
* This event is {@link Cancelable} | ||
* | ||
* {@link #screenshotFile} contains the file the screenshot will be/was saved to | ||
* {@link #image} contains the {@link BufferedImage} that will be saved | ||
* {@link #resultMessage} contains the {@link ITextComponent} to be returned. If {@code null}, the default vanilla message will be used instead | ||
*/ | ||
@Cancelable | ||
public class ScreenshotEvent extends Event | ||
{ | ||
|
||
public static final ITextComponent DEFAULT_CANCEL_REASON = new TextComponentString("Screenshot canceled"); | ||
|
||
private BufferedImage image; | ||
private File screenshotFile; | ||
|
||
private ITextComponent resultMessage = null; | ||
|
||
public ScreenshotEvent(BufferedImage image, File screenshotFile) | ||
{ | ||
this.image = image; | ||
this.screenshotFile = screenshotFile; | ||
} | ||
|
||
public BufferedImage getImage() | ||
{ | ||
return image; | ||
} | ||
|
||
public File getScreenshotFile() | ||
{ | ||
return screenshotFile; | ||
} | ||
|
||
public void setScreenshotFile(File screenshotFile) | ||
{ | ||
this.screenshotFile = screenshotFile; | ||
} | ||
|
||
public ITextComponent getResultMessage() | ||
{ | ||
return resultMessage; | ||
} | ||
|
||
public void setResultMessage(ITextComponent resultMessage) | ||
{ | ||
this.resultMessage = resultMessage; | ||
} | ||
|
||
public ITextComponent getCancelMessage() | ||
{ | ||
return getResultMessage() != null ? getResultMessage() : DEFAULT_CANCEL_REASON; | ||
} | ||
|
||
} |