|
| 1 | +package me.polishkrowa.ctrlq.mixin; |
| 2 | + |
| 3 | +import net.minecraft.client.MinecraftClient; |
| 4 | +import net.minecraft.client.gui.screen.ingame.HandledScreen; |
| 5 | +import net.minecraft.client.util.InputUtil; |
| 6 | +import net.minecraft.screen.slot.Slot; |
| 7 | +import net.minecraft.screen.slot.SlotActionType; |
| 8 | +import org.jetbrains.annotations.Nullable; |
| 9 | +import org.spongepowered.asm.mixin.Mixin; |
| 10 | +import org.spongepowered.asm.mixin.Shadow; |
| 11 | +import org.spongepowered.asm.mixin.injection.At; |
| 12 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 13 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 14 | + |
| 15 | +@Mixin(HandledScreen.class) |
| 16 | +public class MixinHandledScreen { |
| 17 | + @Shadow @Nullable public Slot focusedSlot; |
| 18 | + |
| 19 | + @Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;hasControlDown()Z"), cancellable = true) |
| 20 | + private void injected(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) { |
| 21 | + this.onMouseClick(this.focusedSlot, this.focusedSlot.id, InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 341) || InputUtil.isKeyPressed(MinecraftClient.getInstance().getWindow().getHandle(), 345) ? 1 : 0, SlotActionType.THROW); |
| 22 | + |
| 23 | + cir.setReturnValue(true); |
| 24 | + } |
| 25 | + |
| 26 | + @Shadow(aliases = {"onMouseClick"}) |
| 27 | + private void onMouseClick(Slot focusedSlot, int id, int i, SlotActionType aThrow) {} |
| 28 | + |
| 29 | +} |
0 commit comments