generated from Legacy-Fabric/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from KingContaria/master redirect instead of ov…
…erwrite redirect instead of overwrite
- Loading branch information
Showing
1 changed file
with
16 additions
and
26 deletions.
There are no files selected for viewing
42 changes: 16 additions & 26 deletions
42
src/main/java/com128/kzf/m/LegacyInputPatch/mixin/ScreenMixin.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 |
---|---|---|
@@ -1,26 +1,16 @@ | ||
package com128.kzf.m.LegacyInputPatch.mixin; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.DrawableHelper; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.widget.IdentifibleBooleanConsumer; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Overwrite; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.lwjgl.input.Keyboard; | ||
|
||
@Mixin(Screen.class) | ||
public abstract class ScreenMixin extends DrawableHelper implements IdentifibleBooleanConsumer { | ||
@Shadow | ||
protected void keyPressed(char character, int code) {}; | ||
@Shadow | ||
protected MinecraftClient client; | ||
|
||
@Overwrite | ||
public void method_6755() { | ||
int code = Keyboard.getEventKey(); | ||
char character = Keyboard.getEventCharacter(); | ||
if (Keyboard.getEventKeyState() || (code == 0 && Character.isDefined(character))) | ||
this.keyPressed(character, code); | ||
this.client.handleKeyInput(); | ||
} | ||
} | ||
package com128.kzf.m.LegacyInputPatch.mixin; | ||
|
||
import net.minecraft.client.gui.screen.Screen; | ||
import org.lwjgl.input.Keyboard; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
@Mixin(Screen.class) | ||
public class ScreenMixin { | ||
|
||
@Redirect(method = "method_6755", at = @At(value = "INVOKE", target = "Lorg/lwjgl/input/Keyboard;getEventKeyState()Z")) | ||
private boolean inputPatch() { | ||
return Keyboard.getEventKeyState() || (Keyboard.getEventKey() == 0 && Character.isDefined(Keyboard.getEventCharacter())); | ||
} | ||
} |