diff --git a/build.gradle b/build.gradle index 76f7a4e..5d75df3 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { - id 'fabric-loom' version '1.7.4' - id 'babric-loom-extension' version '1.7.5' + id 'fabric-loom' version '1.8.12' + id 'babric-loom-extension' version '1.8.9' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index b64cd9c..f4d2192 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3+c6a9668 loader_version=0.15.6-babric.1 # Mod Properties -mod_version=2.2.0 +mod_version=2.3.0 maven_group=com.github.telvarost archives_base_name=InventoryTweaks diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0d18421..e1adfb4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/com/github/telvarost/inventorytweaks/Config.java b/src/main/java/com/github/telvarost/inventorytweaks/Config.java index 9592bbd..a86d889 100644 --- a/src/main/java/com/github/telvarost/inventorytweaks/Config.java +++ b/src/main/java/com/github/telvarost/inventorytweaks/Config.java @@ -28,6 +28,9 @@ public static class ModernMinecraftConfig { @ConfigEntry(name = "Enable [Right-Click + Drag]") public Boolean EnableRightClickDrag = true; + @ConfigEntry(name = "Enable [Shift-Click] crafting") + public Boolean EnableShiftClickCrafting = true; + @ConfigEntry(name = "Prefer [Shift-Click] over [Left-Click + Drag]") public Boolean LMBPreferShiftClick = true; diff --git a/src/main/java/com/github/telvarost/inventorytweaks/mixin/ContainerBaseMixin.java b/src/main/java/com/github/telvarost/inventorytweaks/mixin/ContainerBaseMixin.java index 588972a..0b60e90 100644 --- a/src/main/java/com/github/telvarost/inventorytweaks/mixin/ContainerBaseMixin.java +++ b/src/main/java/com/github/telvarost/inventorytweaks/mixin/ContainerBaseMixin.java @@ -1,6 +1,7 @@ package com.github.telvarost.inventorytweaks.mixin; import com.github.telvarost.inventorytweaks.Config; +import net.minecraft.screen.slot.CraftingResultSlot; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.spongepowered.asm.mixin.Mixin; @@ -25,12 +26,19 @@ @Mixin(HandledScreen.class) public abstract class ContainerBaseMixin extends Screen { + @Shadow - protected abstract Slot getSlotAt(int x, int y); + protected int backgroundWidth; + + @Shadow + protected int backgroundHeight; @Shadow public net.minecraft.screen.ScreenHandler container; + @Shadow + protected abstract Slot getSlotAt(int x, int y); + @Shadow protected abstract boolean isPointOverSlot(Slot slot, int x, int Y); @@ -81,6 +89,16 @@ public abstract class ContainerBaseMixin extends Screen { protected void inventoryTweaks_mouseClicked(int mouseX, int mouseY, int button, CallbackInfo ci) { isLeftClickDragMouseTweaksStarted = false; + /** - Handle shift click crafting */ + if (Config.INVENTORY_TWEAKS_CONFIG.MODERN_MINECRAFT_CONFIG.EnableShiftClickCrafting) { + if (inventoryTweaks_handleShiftClickCrafting(mouseX, mouseY, button)) { + /** - Handle if a button was clicked */ + super.mouseClicked(mouseX, mouseY, button); + ci.cancel(); + return; + } + } + /** - Check if client is on a server */ boolean isClientOnServer = minecraft.world.isRemote; @@ -137,6 +155,49 @@ protected void inventoryTweaks_mouseClicked(int mouseX, int mouseY, int button, } } + @Unique private boolean inventoryTweaks_handleShiftClickCrafting(int mouseX, int mouseY, int button) { + Slot slot = this.getSlotAt(mouseX, mouseY); + + if (slot instanceof CraftingResultSlot) { + boolean isShiftKeyDown = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); + if (true == isShiftKeyDown && slot.hasStack()) { + for (int craftingAttempts = 0; craftingAttempts < 256; craftingAttempts++) { + if (slot.hasStack()) { + inventoryTweaks_internalMouseClicked(mouseX, mouseY, button); + } else { + break; + } + } + return true; + } + } + + return false; + } + + @Unique private void inventoryTweaks_internalMouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + if (button == 0 || button == 1) { + Slot var4 = this.getSlotAt(mouseX, mouseY); + int var5 = (this.width - this.backgroundWidth) / 2; + int var6 = (this.height - this.backgroundHeight) / 2; + boolean var7 = mouseX < var5 || mouseY < var6 || mouseX >= var5 + this.backgroundWidth || mouseY >= var6 + this.backgroundHeight; + int var8 = -1; + if (var4 != null) { + var8 = var4.id; + } + + if (var7) { + var8 = -999; + } + + if (var8 != -1) { + boolean var9 = var8 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54)); + this.minecraft.interactionManager.clickSlot(this.container.syncId, var8, button, var9, this.minecraft.player); + } + } + } + @Inject(method = "mouseReleased", at = @At("RETURN"), cancellable = true) private void inventoryTweaks_mouseReleasedOrSlotChanged(int mouseX, int mouseY, int button, CallbackInfo ci) { slot = this.getSlotAt(mouseX, mouseY); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1ede25d..38b09d0 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,12 +19,6 @@ "environment": "client", "entrypoints": { - "stationapi:event_bus": [ - ], - "stationapi:event_bus_client": [ - ], - "stationapi:event_bus_server": [ - ], "gcapi3": [ "com.github.telvarost.inventorytweaks.Config" ] @@ -35,11 +29,11 @@ "depends": { "minecraft": "1.0.0-beta.7.3", - "gcapi3": ">=3.0.1", - "stationapi": "*" + "gcapi3": ">=3.0.1" }, "recommends": { + "stationapi": "*", "modmenu": "*" },