-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b002c6e
commit 8923587
Showing
4 changed files
with
71 additions
and
12 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
src/client/java/wiki/mc/rtfw/mixin/HandledScreenMixin.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,37 @@ | ||
package wiki.mc.rtfw.mixin; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.ingame.HandledScreen; | ||
import net.minecraft.screen.slot.Slot; | ||
import net.minecraft.util.Util; | ||
import org.jetbrains.annotations.Nullable; | ||
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 wiki.mc.rtfw.FTFWClient; | ||
|
||
import java.net.URI; | ||
|
||
@Mixin(HandledScreen.class) | ||
public class HandledScreenMixin { | ||
@Shadow | ||
@Nullable | ||
protected Slot focusedSlot; | ||
|
||
@Inject(method = "keyPressed", at = @At("HEAD")) | ||
public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) { | ||
if (FTFWClient.readKey.matchesKey(keyCode, scanCode)) { | ||
Slot slot = this.focusedSlot; | ||
if (slot != null && slot.hasStack()) { | ||
String pageName = slot.getStack().getItem().getName().getString(); | ||
String language = MinecraftClient.getInstance().getLanguageManager().getLanguage(); | ||
URI uri = FTFWClient.buildUri(pageName, language); | ||
if (uri != null) { | ||
Util.getOperatingSystem().open(uri); | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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,11 @@ | ||
{ | ||
"required": true, | ||
"package": "wiki.mc.rtfw.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"client": [ | ||
"HandledScreenMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |