Skip to content

Commit

Permalink
Changelog:
Browse files Browse the repository at this point in the history
- Adding the Ctrl override in inventories
  • Loading branch information
SB2DD committed Mar 28, 2021
1 parent a164679 commit 334d508
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.16.5
yarn_mappings=1.16.5+build.5
loader_version=0.11.2
# Mod Properties
mod_version=1.1
mod_version=1.2
maven_group=me.PolishKrowa
archives_base_name=ctrl-q
# Dependencies
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/me/polishkrowa/ctrlq/mixin/MixinHandledScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package me.polishkrowa.ctrlq.mixin;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.util.InputUtil;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(HandledScreen.class)
public class MixinHandledScreen {
@Shadow @Nullable public Slot focusedSlot;

@Inject(method = "keyPressed", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;hasControlDown()Z"), cancellable = true)
private void injected(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
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);

cir.setReturnValue(true);
}

@Shadow(aliases = {"onMouseClick"})
private void onMouseClick(Slot focusedSlot, int id, int i, SlotActionType aThrow) {}

}
2 changes: 1 addition & 1 deletion src/main/resources/ctrl-q.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": ["MixinMinecraftClient"],
"client": ["MixinMinecraftClient","MixinHandledScreen"],
"injectors": {
"defaultRequire": 1
}
Expand Down

0 comments on commit 334d508

Please sign in to comment.