Skip to content

Commit

Permalink
Merge pull request #1 from KingContaria/master redirect instead of ov…
Browse files Browse the repository at this point in the history
…erwrite

redirect instead of overwrite
  • Loading branch information
HowardZHY authored Oct 19, 2022
2 parents 63f9a68 + 2820426 commit 122c1e7
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions src/main/java/com128/kzf/m/LegacyInputPatch/mixin/ScreenMixin.java
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()));
}
}

0 comments on commit 122c1e7

Please sign in to comment.