blob: edc8fd68b597ade31ff8db512ee6fcc834f0027e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
package moe.nea.firmament.mixins;
import moe.nea.firmament.events.HandledScreenKeyPressedEvent;
import moe.nea.firmament.keybindings.GenericInputAction;
import moe.nea.firmament.keybindings.InputModifiers;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.client.input.MouseButtonEvent;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Screen.class)
public class ScreenInputEvents {
@Inject(method = "keyPressed", at = @At("HEAD"), cancellable = true)
public void onKeyPressed(KeyEvent input, CallbackInfoReturnable<Boolean> cir) {
if (HandledScreenKeyPressedEvent.Companion.publish(new HandledScreenKeyPressedEvent(
(Screen) (Object) this,
GenericInputAction.of(input),
InputModifiers.of(input))).getCancelled()) {
cir.setReturnValue(true);
}
}
public boolean onMouseClicked$firmament(MouseButtonEvent click, boolean doubled) {
return HandledScreenKeyPressedEvent.Companion.publish(
new HandledScreenKeyPressedEvent((Screen) (Object) this,
GenericInputAction.mouse(click), InputModifiers.current())).getCancelled();
}
}
|