From 42c60b760d1a88acdaf08da1bf7d0775ba820071 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 26 Mar 2020 09:23:42 +0100 Subject: [PATCH] Added shift click images --- .../carpetclient/mixins/MixinGuiScreen.java | 38 +++++++++++++++++++ src/main/resources/mixins.carpetclient.json | 3 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/main/java/carpetclient/mixins/MixinGuiScreen.java diff --git a/src/main/java/carpetclient/mixins/MixinGuiScreen.java b/src/main/java/carpetclient/mixins/MixinGuiScreen.java new file mode 100644 index 0000000..40d4b48 --- /dev/null +++ b/src/main/java/carpetclient/mixins/MixinGuiScreen.java @@ -0,0 +1,38 @@ +package carpetclient.mixins; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.event.ClickEvent; +import org.lwjgl.input.Keyboard; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.io.File; +import java.net.URI; + +/** + * Class to help open screenshots + */ +@Mixin(GuiScreen.class) +public class MixinGuiScreen { + + @Shadow void openWebLink(URI url) { } + + /* + Method made to help open screenshot folders instead of the image itself when clicking on it in the text area. + */ + @Inject(method = "handleComponentClick", at = @At("HEAD"), cancellable = true) + public void onItemRightClick(ITextComponent component, CallbackInfoReturnable cir) { + if(component != null && GuiScreen.isShiftKeyDown()) + { + ClickEvent clickevent = component.getStyle().getClickEvent(); + if(clickevent != null && clickevent.getAction() == ClickEvent.Action.OPEN_FILE){ + this.openWebLink((new File(clickevent.getValue())).getParentFile().toURI()); + cir.setReturnValue(true); + } + } + } +} diff --git a/src/main/resources/mixins.carpetclient.json b/src/main/resources/mixins.carpetclient.json index 61c73aa..cd9f086 100644 --- a/src/main/resources/mixins.carpetclient.json +++ b/src/main/resources/mixins.carpetclient.json @@ -47,6 +47,7 @@ "IMixinRecipeBookClient", "MixinSearchTree", "MixinWorldServer", - "MixinItemStack" + "MixinItemStack", + "MixinGuiScreen" ] }