Skip to content

Commit

Permalink
Added shift click images
Browse files Browse the repository at this point in the history
  • Loading branch information
X-com committed Mar 26, 2020
1 parent ae2eeb9 commit 42c60b7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/main/java/carpetclient/mixins/MixinGuiScreen.java
Original file line number Diff line number Diff line change
@@ -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<Boolean> 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);
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/mixins.carpetclient.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"IMixinRecipeBookClient",
"MixinSearchTree",
"MixinWorldServer",
"MixinItemStack"
"MixinItemStack",
"MixinGuiScreen"
]
}

0 comments on commit 42c60b7

Please sign in to comment.