|
@@ -20,15 +20,18 @@
|
|
package me.shedaniel.architectury.mixin.fabric.client;
|
|
package me.shedaniel.architectury.mixin.fabric.client;
|
|
|
|
|
|
import me.shedaniel.architectury.event.events.client.ClientScreenInputEvent;
|
|
import me.shedaniel.architectury.event.events.client.ClientScreenInputEvent;
|
|
|
|
+import me.shedaniel.architectury.impl.fabric.ScreenInputDelegate;
|
|
import net.minecraft.client.KeyboardHandler;
|
|
import net.minecraft.client.KeyboardHandler;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.components.events.ContainerEventHandler;
|
|
import net.minecraft.client.gui.components.events.ContainerEventHandler;
|
|
|
|
+import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.InteractionResult;
|
|
import org.spongepowered.asm.mixin.Final;
|
|
import org.spongepowered.asm.mixin.Final;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
|
|
+import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|
|
|
|
|
@@ -41,48 +44,22 @@ public class MixinKeyboardHandler {
|
|
@Shadow
|
|
@Shadow
|
|
private boolean sendRepeatsToGui;
|
|
private boolean sendRepeatsToGui;
|
|
|
|
|
|
- @Inject(method = "charTyped", at = @At(value = "INVOKE",
|
|
|
|
- target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V",
|
|
|
|
- ordinal = 0), cancellable = true)
|
|
|
|
- public void onCharFirst(long long_1, int int_1, int int_2, CallbackInfo info) {
|
|
|
|
- if (!info.isCancelled()) {
|
|
|
|
- InteractionResult result = ClientScreenInputEvent.CHAR_TYPED_PRE.invoker().charTyped(minecraft, minecraft.screen, (char) int_1, int_2);
|
|
|
|
- if (result != InteractionResult.PASS)
|
|
|
|
- info.cancel();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Inject(method = "charTyped", at = @At(value = "INVOKE",
|
|
|
|
- target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V",
|
|
|
|
- ordinal = 1), cancellable = true)
|
|
|
|
- public void onCharSecond(long long_1, int int_1, int int_2, CallbackInfo info) {
|
|
|
|
- if (!info.isCancelled()) {
|
|
|
|
- InteractionResult result = ClientScreenInputEvent.CHAR_TYPED_PRE.invoker().charTyped(minecraft, minecraft.screen, (char) int_1, int_2);
|
|
|
|
- if (result != InteractionResult.PASS)
|
|
|
|
- info.cancel();
|
|
|
|
|
|
+ @SuppressWarnings("UnresolvedMixinReference")
|
|
|
|
+ @ModifyVariable(method = {"method_1458", "lambda$charTyped$5"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
|
|
|
+ private static GuiEventListener wrapCharTypedFirst(GuiEventListener screen) {
|
|
|
|
+ if (screen instanceof ScreenInputDelegate) {
|
|
|
|
+ return ((ScreenInputDelegate) screen).architectury_delegateInputs();
|
|
}
|
|
}
|
|
|
|
+ return screen;
|
|
}
|
|
}
|
|
|
|
|
|
- @Inject(method = "charTyped", at = @At(value = "INVOKE",
|
|
|
|
- target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V",
|
|
|
|
- ordinal = 0, shift = At.Shift.AFTER), cancellable = true)
|
|
|
|
- public void onCharFirstPost(long long_1, int int_1, int int_2, CallbackInfo info) {
|
|
|
|
- if (!info.isCancelled()) {
|
|
|
|
- InteractionResult result = ClientScreenInputEvent.CHAR_TYPED_POST.invoker().charTyped(minecraft, minecraft.screen, (char) int_1, int_2);
|
|
|
|
- if (result != InteractionResult.PASS)
|
|
|
|
- info.cancel();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Inject(method = "charTyped", at = @At(value = "INVOKE",
|
|
|
|
- target = "Lnet/minecraft/client/gui/screens/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V",
|
|
|
|
- ordinal = 1, shift = At.Shift.AFTER), cancellable = true)
|
|
|
|
- public void onCharSecondPost(long long_1, int int_1, int int_2, CallbackInfo info) {
|
|
|
|
- if (!info.isCancelled()) {
|
|
|
|
- InteractionResult result = ClientScreenInputEvent.CHAR_TYPED_POST.invoker().charTyped(minecraft, minecraft.screen, (char) int_1, int_2);
|
|
|
|
- if (result != InteractionResult.PASS)
|
|
|
|
- info.cancel();
|
|
|
|
|
|
+ @SuppressWarnings("UnresolvedMixinReference")
|
|
|
|
+ @ModifyVariable(method = {"method_1473", "lambda$charTyped$6"}, at = @At("HEAD"), ordinal = 0, argsOnly = true)
|
|
|
|
+ private static GuiEventListener wrapCharTypedSecond(GuiEventListener screen) {
|
|
|
|
+ if (screen instanceof ScreenInputDelegate) {
|
|
|
|
+ return ((ScreenInputDelegate) screen).architectury_delegateInputs();
|
|
}
|
|
}
|
|
|
|
+ return screen;
|
|
}
|
|
}
|
|
|
|
|
|
@Inject(method = "keyPress", at = @At(value = "INVOKE",
|
|
@Inject(method = "keyPress", at = @At(value = "INVOKE",
|