diff --git a/README.md b/README.md index 3445e64..d980319 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,26 @@ This mod is currently incompatible with the regular version of MojangFix. If you ## List of Changes: +* Note that all changes can be enabled/disabled in the config menu if you have ModMenu and GlassConfigAPI. + +### Modern Minecraft Changes * Adds `Left-Click + Drag` mechanic to evenly distribute held items over empty slots/slots with the same item as in modern Minecraft. * Adds `Right-Click + Drag` mechanic to distribute one item from held items over empty slots/slots with the same item as in modern Minecraft. * `LCtrl + DROP_KEY` to drop a whole stack of items. * Move items from player inventory to the hotbar by pressing the number key corresponding to the desired hotbar slot while hovering the cursor over the item to move. +### MouseTweaks Changes +* MouseTweaks `Right-Click + Drag` + * Very similar to the standard RMB dragging mechanic, with one difference: if you drag over a slot multiple times, an item will be put there multiple times. Replaces the standard mechanic if enabled. +* MouseTweaks `Left-Click + Drag` (with item) + * Lets you quickly pick up or move items of the same type. + * Move items to another inventory if holding `Shift` +* MouseTweaks `Left-Click + Drag + Shift` (without item) + * Quickly move items into another inventory. +* Original take on the scroll wheel + * Scroll to move items between the cursor and the hovered slot + * Note: MouseTweaks scroll will eventually be added as well if I can figure it out + ## Installation using Prism Launcher 1. Download an instance of Babric for Prism Launcher: https://github.com/babric/prism-instance diff --git a/gradle.properties b/gradle.properties index 652148b..a50c180 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=b1.7.3-build.2 loader_version=0.14.24-babric.1 # Mod Properties -mod_version=1.1.2 +mod_version=2.0.0 maven_group=com.github.telvarost archives_base_name=InventoryTweaks diff --git a/src/main/java/com/github/telvarost/inventorytweaks/Config.java b/src/main/java/com/github/telvarost/inventorytweaks/Config.java index ecd1f77..52afab9 100644 --- a/src/main/java/com/github/telvarost/inventorytweaks/Config.java +++ b/src/main/java/com/github/telvarost/inventorytweaks/Config.java @@ -1,16 +1,100 @@ package com.github.telvarost.inventorytweaks; +import blue.endless.jankson.Comment; +import net.glasslauncher.mods.api.gcapi.api.ConfigCategory; import net.glasslauncher.mods.api.gcapi.api.ConfigName; import net.glasslauncher.mods.api.gcapi.api.GConfig; public class Config { - @GConfig(value = "config", visibleName = "InventoryTweaks Config") - public static ConfigFields config = new ConfigFields(); + @GConfig(value = "inventoryTweaks", visibleName = "InventoryTweaks Config", primary = true) + public static InventoryTweaksConfig INVENTORY_TWEAKS_CONFIG = new InventoryTweaksConfig(); - public static class ConfigFields { + public static class InventoryTweaksConfig { -// @ConfigName("Fix double doors") -// public static Boolean FIX_DOUBLE_DOORS = true; + @ConfigCategory("Modern Minecraft Config") + public static ModernMinecraftConfig MODERN_MINECRAFT_CONFIG = new ModernMinecraftConfig(); + + @ConfigCategory("MouseTweaks Config") + public static final MouseTweaksConfig MOUSE_TWEAKS_CONFIG = new MouseTweaksConfig(); + } + + public static class ModernMinecraftConfig { + + @ConfigName("Enable [Click + Drag] graphics") + public static Boolean EnableDragGraphics = true; + + @ConfigName("Enable [Left-Click + Drag]") + public static Boolean EnableLeftClickDrag = true; + + @ConfigName("Enable [Right-Click + Drag]") + public static Boolean EnableRightClickDrag = true; + + @ConfigName("Prefer [Shift-Click] over [Left-Click + Drag]") + public static Boolean LMBPreferShiftClick = true; + + @ConfigName("Prefer [Shift-Click] over [Right-Click + Drag]") + public static Boolean RMBPreferShiftClick = true; + + @ConfigName("Use [DROP_KEY] to drop inventory items") + @Comment("Cursor must not be holding any items") + public static Boolean UseDropKeyInInventory = true; + + @ConfigName("Use [LCtrl + DROP_KEY] to drop entire stack") + public static Boolean LCtrlStackDrop = true; + + @ConfigName("Use [NUMBER_KEYS] to swap items to hotbar") + @Comment("Hover over the slot or swap cursor item") + public static Boolean NumKeyHotbarSwap = true; + } + + public static class MouseTweaksConfig { + + @ConfigCategory("Scroll Wheel Config") + public static final ScrollWheelConfig SCROLL_WHEEL_CONFIG = new ScrollWheelConfig(); + + @ConfigName("Empty cursor [Shift + Left-Click + Drag]") + @Comment("[Shift-Click] items of any type") + public static Boolean LMBTweakShiftClickAny = true; + + @ConfigName("Item in cursor [Shift + Left-Click + Drag]") + @Comment("[Shift-Click] items of the held type") + public static Boolean LMBTweakShiftClick = true; + + @ConfigName("[Right-Click + Drag] over existing slots") + public static Boolean RMBTweak = true; + + @ConfigName("[Left-Click + Drag] to pick up items") + public static Boolean LMBTweakPickUp = true; + } + + public static class ScrollWheelConfig { + + @ConfigName("Enable Scroll Wheel Tweaks") + public static Boolean enableScrollWheelTweaks = true; + + @ConfigName("Invert scroll direction: cursor/slot") + @Comment("For cursor/slot item transfer") + public static Boolean invertScrollCursorSlotDirection = false; + +// @ConfigName("Invert scroll direction: inventories") +// @Comment("For item transfer between inventories") +// public static Boolean invertScrollInventoryDirection = false; +// +// @ConfigName("Position aware scrolling inventory transfer") +// @Comment("Slot position will determine scroll direction") +// public static Boolean positionAwareScrolling = false; +// +// @ConfigName("Wheel slot search order (see comment)") +// @Comment("true = first to last, false = last to first") +// public static Boolean wheelSearchOrder = true; +// +// @ConfigName("[ScrollWheel] transfer (see comment)") +// @Comment("true = cursor/slot, false = inventories") +// public static Boolean scrollWheelBehavior = true; +// +// @ConfigName("[Shift + ScrollWheel] transfer (see comment)") +// @Comment("true = inventories, false = cursor/slot") +// public static Boolean shiftScrollWheelBehavior = 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 9282f5e..06e6936 100644 --- a/src/main/java/com/github/telvarost/inventorytweaks/mixin/ContainerBaseMixin.java +++ b/src/main/java/com/github/telvarost/inventorytweaks/mixin/ContainerBaseMixin.java @@ -1,8 +1,8 @@ package com.github.telvarost.inventorytweaks.mixin; +import com.github.telvarost.inventorytweaks.Config; import net.minecraft.client.gui.screen.ScreenBase; import net.minecraft.client.gui.screen.container.ContainerBase; -import net.minecraft.item.ItemBase; import net.minecraft.item.ItemInstance; import net.minecraft.container.slot.Slot; import org.lwjgl.input.Keyboard; @@ -18,6 +18,8 @@ import java.util.ArrayList; import java.util.List; +import static java.lang.Math.abs; + @Mixin(ContainerBase.class) public abstract class ContainerBaseMixin extends ScreenBase { @Shadow @@ -45,10 +47,16 @@ public abstract class ContainerBaseMixin extends ScreenBase { @Unique int lastLMBSlotId = -1; @Unique - private ItemInstance leftClickPersistentStack; + private ItemInstance leftClickMouseTweaksPersistentStack = null; + + @Unique + private ItemInstance leftClickPersistentStack = null; + + @Unique + private ItemInstance rightClickPersistentStack = null; @Unique - private ItemInstance rightClickPersistentStack; + private boolean isLeftClickDragMouseTweaksStarted = false; @Unique private boolean isLeftClickDragStarted = false; @@ -71,153 +79,59 @@ public abstract class ContainerBaseMixin extends ScreenBase { @Unique List leftClickAmountToFillPersistent = new ArrayList<>(); - @Unique List rightClickAmountToFillPersistent = new ArrayList<>(); - - @Unique private void inventoryTweaks_resetLeftClickDragVariables() - { - leftClickExistingAmount.clear(); - leftClickAmountToFillPersistent.clear(); - leftClickHoveredSlots.clear(); - leftClickPersistentStack = null; - leftClickItemAmount = 0; - isLeftClickDragStarted = false; - } - - @Unique private void inventoryTweaks_resetRightClickDragVariables() - { - rightClickExistingAmount.clear(); - rightClickHoveredSlots.clear(); - rightClickPersistentStack = null; - rightClickItemAmount = 0; - isRightClickDragStarted = false; - } - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) protected void inventoryTweaks_mouseClicked(int mouseX, int mouseY, int button, CallbackInfo ci) { + isLeftClickDragMouseTweaksStarted = false; /** - Right-click */ if (button == 1) { - /** - Get held item */ - ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + boolean exitFunction = false; - /** - Cancel Left-click + Drag */ - if (isLeftClickDragStarted) { - if (leftClickHoveredSlots.size() > 1) { - /** - Handle if a button was clicked */ - super.mouseClicked(mouseX, mouseY, button); - - /** - Return all slots to normal */ - minecraft.player.inventory.setCursorItem(new ItemInstance(leftClickPersistentStack.itemId, leftClickItemAmount, leftClickPersistentStack.getDamage())); - for (int leftClickHoveredSlotsIndex = 0; leftClickHoveredSlotsIndex < leftClickHoveredSlots.size(); leftClickHoveredSlotsIndex++) { - if (0 != leftClickExistingAmount.get(leftClickHoveredSlotsIndex)) { - leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(new ItemInstance(leftClickPersistentStack.itemId, leftClickExistingAmount.get(leftClickHoveredSlotsIndex), leftClickPersistentStack.getDamage())); - } else { - leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(null); - } - } + /** - Should click cancel Left-click + Drag */ + if (!inventoryTweaks_cancelLeftClickDrag()) { - /** - Reset Left-click + Drag variables and exit function */ - inventoryTweaks_resetLeftClickDragVariables(); - ci.cancel(); - return; + /** - Handle Right-click */ + if (Config.ModernMinecraftConfig.EnableRightClickDrag) { + exitFunction = inventoryTweaks_handleRightClick(mouseX, mouseY); } + } else { + exitFunction = true; } - /** - Handle Right-click if an item is held */ - if (cursorStack != null) { - /** - Ensure a slot was clicked */ - Slot clickedSlot = this.getSlot(mouseX, mouseY); - if (clickedSlot != null) { - /** - Handle if a button was clicked */ - super.mouseClicked(mouseX, mouseY, button); - - /** - Record how many items are in the slot */ - if (null != clickedSlot.getItem()) { - rightClickExistingAmount.add(clickedSlot.getItem().count); - } - else - { - rightClickExistingAmount.add(0); - } - - /** - Begin Right-click + Drag */ - if (cursorStack != null && rightClickPersistentStack == null && isRightClickDragStarted == false) { - rightClickPersistentStack = cursorStack; - rightClickItemAmount = rightClickPersistentStack.count; - isRightClickDragStarted = true; - } - - /** - Handle initial Right-click */ - lastRMBSlotId = clickedSlot.id; - lastRMBSlot = clickedSlot; - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 1, false, this.minecraft.player); - ci.cancel(); - return; - } + if (exitFunction) { + /** - Handle if a button was clicked */ + super.mouseClicked(mouseX, mouseY, button); + ci.cancel(); + return; } } /** - Left-click */ if (button == 0) { - /** - Get held item */ - ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + boolean exitFunction = false; - /** - Cancel Right-click + Drag */ - if (isRightClickDragStarted) { - if (rightClickHoveredSlots.size() > 1) { - /** - Handle if a button was clicked */ - super.mouseClicked(mouseX, mouseY, button); - - /** - Return all slots to normal */ - minecraft.player.inventory.setCursorItem(new ItemInstance(rightClickPersistentStack.itemId, rightClickItemAmount, rightClickPersistentStack.getDamage())); - for (int leftClickHoveredSlotsIndex = 0; leftClickHoveredSlotsIndex < rightClickHoveredSlots.size(); leftClickHoveredSlotsIndex++) { - if (0 != rightClickExistingAmount.get(leftClickHoveredSlotsIndex)) { - rightClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(new ItemInstance(rightClickPersistentStack.itemId, rightClickExistingAmount.get(leftClickHoveredSlotsIndex), rightClickPersistentStack.getDamage())); - } else { - rightClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(null); - } - } + /** - Should click cancel Right-click + Drag */ + if (!inventoryTweaks_cancelRightClickDrag()) { - /** - Reset Right-click + Drag variables and exit function */ - inventoryTweaks_resetRightClickDragVariables(); - ci.cancel(); - return; - } - } - - /** - Handle Left-click if an item is held */ - if (cursorStack != null) { - /** - Ensure a slot was clicked */ + /** - Handle Left-click */ + ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); Slot clickedSlot = this.getSlot(mouseX, mouseY); - if (clickedSlot != null) { - /** - Handle if a button was clicked */ - super.mouseClicked(mouseX, mouseY, button); - - /** - Record how many items are in the slot and how many items are needed to fill the slot */ - if (null != clickedSlot.getItem()) { - leftClickAmountToFillPersistent.add(cursorStack.getMaxStackSize() - clickedSlot.getItem().count); - leftClickExistingAmount.add(clickedSlot.getItem().count); - } - else - { - leftClickAmountToFillPersistent.add(cursorStack.getMaxStackSize()); - leftClickExistingAmount.add(0); - } - - /** - Begin Left-click + Drag */ - if (cursorStack != null && leftClickPersistentStack == null && isLeftClickDragStarted == false) { - leftClickPersistentStack = cursorStack; - leftClickItemAmount = leftClickPersistentStack.count; - isLeftClickDragStarted = true; + if (cursorStack != null) { + if (Config.ModernMinecraftConfig.EnableLeftClickDrag) { + exitFunction = inventoryTweaks_handleLeftClickWithItem(cursorStack, clickedSlot); } - - /** - Handle initial Left-click */ - lastLMBSlotId = clickedSlot.id; - lastLMBSlot = clickedSlot; - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 0, false, this.minecraft.player); - ci.cancel(); - return; + } else { + exitFunction = inventoryTweaks_handleLeftClickWithoutItem(clickedSlot); } + } else { + exitFunction = true; + } + + if (exitFunction) { + /** - Handle if a button was clicked */ + super.mouseClicked(mouseX, mouseY, button); + ci.cancel(); + return; } } } @@ -230,50 +144,44 @@ private void inventoryTweaks_mouseReleasedOrSlotChanged(int mouseX, int mouseY, if (slot == null) return; + if (Config.ScrollWheelConfig.enableScrollWheelTweaks) { + int currentWheelDegrees = Mouse.getDWheel(); + if ( (0 != currentWheelDegrees) + && (isLeftClickDragStarted == false) + && (isRightClickDragStarted == false) + ) { + inventoryTweaks_handleScrollWheel(currentWheelDegrees); + } + } + /** - Right-click + Drag logic = distribute one item from held items to each slot */ if ( ( button == -1 ) && ( Mouse.isButtonDown(1) ) && ( isLeftClickDragStarted == false ) + && ( isLeftClickDragMouseTweaksStarted == false ) && ( rightClickPersistentStack != null ) - ) - { - /** - Do nothing if slot has already been added to Right-click + Drag logic */ - if (!rightClickHoveredSlots.contains(slot)) { - ItemInstance slotItemToExamine = slot.getItem(); - - /** - Do nothing if slot item does not match held item */ - if (null != slotItemToExamine && !slotItemToExamine.isDamageAndIDIdentical(rightClickPersistentStack)) { - return; - } - - /** - Do nothing if there are no more items to distribute */ - if (1.0 == (double)rightClickItemAmount / (double)rightClickHoveredSlots.size()) { - return; - } - - /** - First slot is handled instantly in mouseClicked function */ - if (slot.id != lastRMBSlotId) { - if (0 == rightClickHoveredSlots.size()) - { - /** - Add slot to item distribution */ - rightClickHoveredSlots.add(lastRMBSlot); - } - - /** - Add slot to item distribution */ - rightClickHoveredSlots.add(slot); + ) { + ItemInstance slotItemToExamine = slot.getItem(); + + /** - Do nothing if slot item does not match held item or if the slot is full */ + if ( (null != slotItemToExamine) + && ( (!slotItemToExamine.isDamageAndIDIdentical(rightClickPersistentStack)) + || (slotItemToExamine.count == rightClickPersistentStack.getMaxStackSize()) + ) + ) { + return; + } - /** - Record how many items are in the slot */ - if (null != slotItemToExamine) { - rightClickExistingAmount.add(slotItemToExamine.count); - } - else - { - rightClickExistingAmount.add(0); - } + /** - Do nothing if there are no more items to distribute */ + ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + if (null == cursorStack) { + return; + } - /** - Distribute one item to the slot */ - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 1, false, this.minecraft.player); - } + if (!rightClickHoveredSlots.contains(slot)) { + inventoryTweaks_handleRightClickDrag(slotItemToExamine); + } else if (Config.MouseTweaksConfig.RMBTweak) { + inventoryTweaks_handleRightClickDragMouseTweaks(); } } else { inventoryTweaks_resetRightClickDragVariables(); @@ -283,101 +191,541 @@ private void inventoryTweaks_mouseReleasedOrSlotChanged(int mouseX, int mouseY, if ( ( button == -1 ) && ( Mouse.isButtonDown(0) ) && ( isRightClickDragStarted == false ) - && ( leftClickPersistentStack != null ) + ) { + if (isLeftClickDragMouseTweaksStarted) { + inventoryTweaks_handleLeftClickDragMouseTweaks(); + } else if ( leftClickPersistentStack != null ) { + if (inventoryTweaks_handleLeftClickDrag()) { + return; + } + } else { + inventoryTweaks_resetLeftClickDragVariables(); + } + } else { + inventoryTweaks_resetLeftClickDragVariables(); + } + } + + @Unique private void inventoryTweaks_handleScrollWheel(int wheelDegrees) { + ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + ItemInstance slotItemToExamine = slot.getItem(); + + if ( (null != cursorStack) + || (null != slotItemToExamine) ) { - /** - Do nothing if slot has already been added to Left-click + Drag logic */ - if (!leftClickHoveredSlots.contains(slot)) { - ItemInstance slotItemToExamine = slot.getItem(); + //boolean isShiftKeyDown = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); + boolean transferAllowed = true; + float numberOfTurns = (float)wheelDegrees / 120.0f; + int cursorStackAmount = 0; + int slotStackAmount = 0; + ItemInstance itemBeingTransfered = null; + + if (null != cursorStack) { + itemBeingTransfered = cursorStack; + cursorStackAmount = cursorStack.count; + } - /** - Do nothing if slot item does not match held item */ - if (null != slotItemToExamine && !slotItemToExamine.isDamageAndIDIdentical(leftClickPersistentStack)){ - return; + if (null != slotItemToExamine) { + itemBeingTransfered = slotItemToExamine; + slotStackAmount = slotItemToExamine.count; + } + + if ( (null != cursorStack) + && (null != slotItemToExamine) + ) { + transferAllowed = cursorStack.isDamageAndIDIdentical(slotItemToExamine); + } + + if (transferAllowed) { + inventoryTweaks_scrollCursorSlotTransfer(numberOfTurns, cursorStackAmount, slotStackAmount, itemBeingTransfered); + } +// if (isShiftKeyDown) { +// if (Config.ScrollWheelConfig.shiftScrollWheelBehavior) { +// inventoryTweaks_scrollInventoryTransfer(numberOfTurns, cursorStackAmount, slotStackAmount, itemBeingTransfered); +// } else { +// inventoryTweaks_scrollCursorSlotTransfer(numberOfTurns, cursorStackAmount, slotStackAmount, itemBeingTransfered); +// } +// } else { +// if (Config.ScrollWheelConfig.scrollWheelBehavior) { +// inventoryTweaks_scrollCursorSlotTransfer(numberOfTurns, cursorStackAmount, slotStackAmount, itemBeingTransfered); +// } else { +// inventoryTweaks_scrollInventoryTransfer(numberOfTurns, cursorStackAmount, slotStackAmount, itemBeingTransfered); +// } +// } + } + } + + @Unique private void inventoryTweaks_scrollCursorSlotTransfer(float numTurns, int cursorAmount, int slotAmount, ItemInstance transferItem) { + if (Config.ScrollWheelConfig.invertScrollCursorSlotDirection) { + numTurns *= -1; + } + + if (0 > numTurns) { + /** - Transfer items to slot from cursor */ + if (0 != cursorAmount) { + for (int turnIndex = 0; turnIndex < abs(numTurns); turnIndex++) { + if (slotAmount != transferItem.getMaxStackSize()) { + if (0 == (cursorAmount - 1)) { + minecraft.player.inventory.setCursorItem(null); + } else { + minecraft.player.inventory.setCursorItem(new ItemInstance(transferItem.itemId, (cursorAmount - 1), transferItem.getDamage())); + } + slot.setStack(new ItemInstance(transferItem.itemId, (slotAmount + 1), transferItem.getDamage())); + } } + } + } else { + /** - Transfer items to cursor from slot */ + if (0 != slotAmount) { + for (int turnIndex = 0; turnIndex < abs(numTurns); turnIndex++) { + if (cursorAmount != transferItem.getMaxStackSize()) { + if (0 == (slotAmount - 1)) { + slot.setStack(null); + } else { + slot.setStack(new ItemInstance(transferItem.itemId, (slotAmount - 1), transferItem.getDamage())); + } + minecraft.player.inventory.setCursorItem(new ItemInstance(transferItem.itemId, (cursorAmount + 1), transferItem.getDamage())); + } + } + } + } + } - /** - Do nothing if there are no more items to distribute */ - if (1.0 == (double)leftClickItemAmount / (double)leftClickHoveredSlots.size()) { - return; +// @Unique private void inventoryTweaks_scrollInventoryTransfer(float numTurns, int cursorAmount, int slotAmount, ItemInstance transferItem) { +// int itemsLeftToAdd = 0; +// +// if (Config.ScrollWheelConfig.invertScrollInventoryDirection) { +// numTurns *= -1; +// } +// +// if (minecraft.player.container == minecraft.player.playerContainer) { +// System.out.println("Only one container exists"); +// } +// +// if (0 > numTurns) { +// /** - Transfer items out of slot */ +// if (0 != slotAmount) { +// for (int containerIndex = 0; containerIndex < minecraft.player.container.slots.lastIndexOf(Slot) - 1; containerIndex++) { +// Slot curSlot = (Slot)minecraft.player.playerContainer.slots.get(containerIndex); +//// ItemInstance curSlotItem = curSlot.getItem(); +//// int curSlotAmount = (null != curSlotItem) ? curSlotItem.count : 0; +//// +//// if ( (null == curSlotItem) +//// || ( (curSlotItem.isDamageAndIDIdentical(transferItem)) +//// && (curSlotAmount != transferItem.getMaxStackSize()) +//// ) +//// ) { +//// while ( (itemsLeftToAdd < abs(numTurns)) +//// && (curSlotAmount != transferItem.getMaxStackSize()) +//// ) { +//// if (0 == (slotAmount - 1)) { +//// slot.setStack(null); +//// } else { +//// slot.setStack(new ItemInstance(transferItem.itemId, (slotAmount - 1), transferItem.getDamage())); +//// } +//// +//// curSlot.setStack(new ItemInstance(transferItem.itemId, (curSlotAmount + 1), transferItem.getDamage())); +//// +//// curSlotItem = curSlot.getItem(); +//// curSlotAmount = (null != curSlotItem) ? curSlotItem.count : 0; +//// itemsLeftToAdd++; +//// } +//// +//// if (itemsLeftToAdd == numTurns) { +//// return; +//// } +//// } +// } +// } +// } else { +// /** - Transfer items into slot */ +// boolean itemExistsInContainer = true; +// if (itemExistsInContainer) { +//// for (int turnIndex = 0; turnIndex < abs(numTurns); turnIndex++) { +//// } +// System.out.println("Scroll up"); +// Slot slotToModify = (Slot)minecraft.player.container.slots.get(0); +// +// slotToModify.setStack(new ItemInstance(transferItem.itemId, 7, transferItem.getDamage())); +// } +// } +// } + + @Unique private boolean inventoryTweaks_handleRightClick(int mouseX, int mouseY) { + /** - Get held item */ + ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + + /** - Handle Right-click if an item is held */ + if (cursorStack != null) { + + /** - Ensure a slot was clicked */ + Slot clickedSlot = this.getSlot(mouseX, mouseY); + if (clickedSlot != null) { + + /** - Record how many items are in the slot */ + if (null != clickedSlot.getItem()) { + rightClickExistingAmount.add(clickedSlot.getItem().count); + } else { + rightClickExistingAmount.add(0); } - /** - First slot is handled instantly in mouseClicked function */ - if (slot.id != lastLMBSlotId) { - if (0 == leftClickHoveredSlots.size()) - { - /** - Add slot to item distribution */ - leftClickHoveredSlots.add(lastLMBSlot); - } + /** - Begin Right-click + Drag */ + if (cursorStack != null && rightClickPersistentStack == null && isRightClickDragStarted == false) { + rightClickPersistentStack = cursorStack; + rightClickItemAmount = rightClickPersistentStack.count; + isRightClickDragStarted = true; + } - /** - Add slot to item distribution */ - leftClickHoveredSlots.add(slot); + /** - Handle initial Right-click */ + lastRMBSlotId = clickedSlot.id; + lastRMBSlot = clickedSlot; + if (Config.ModernMinecraftConfig.RMBPreferShiftClick) { + boolean isShiftKeyDown = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 1, isShiftKeyDown, this.minecraft.player); - /** - Record how many items are in the slot and how many items are needed to fill the slot */ - if (null != slotItemToExamine) { - leftClickAmountToFillPersistent.add(leftClickPersistentStack.getMaxStackSize() - slotItemToExamine.count); - leftClickExistingAmount.add(slotItemToExamine.count); + if (isShiftKeyDown) { + inventoryTweaks_resetRightClickDragVariables(); } - else - { - leftClickAmountToFillPersistent.add(leftClickPersistentStack.getMaxStackSize()); - leftClickExistingAmount.add(0); + } else { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 1, false, this.minecraft.player); + } + + return true; + } + } + + return false; + } + + @Unique private void inventoryTweaks_handleRightClickDragMouseTweaks() { + if (slot.id != lastRMBSlotId) { + ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + + if (null != cursorStack ) { + /** - Distribute one item to the slot */ + lastRMBSlotId = slot.id; + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 1, false, this.minecraft.player); + } + } + } + + @Unique private void inventoryTweaks_handleRightClickDrag(ItemInstance slotItemToExamine) { + /** - First slot is handled instantly in mouseClicked function */ + if (slot.id != lastRMBSlotId) { + if (0 == rightClickHoveredSlots.size()) + { + /** - Add slot to item distribution */ + rightClickHoveredSlots.add(lastRMBSlot); + } + + /** - Add slot to item distribution */ + rightClickHoveredSlots.add(slot); + + /** - Record how many items are in the slot */ + if (null != slotItemToExamine) { + rightClickExistingAmount.add(slotItemToExamine.count); + } + else + { + rightClickExistingAmount.add(0); + } + + /** - Distribute one item to the slot */ + lastRMBSlotId = slot.id; + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 1, false, this.minecraft.player); + } + } + + @Unique private boolean inventoryTweaks_cancelRightClickDrag() + { + /** - Cancel Right-click + Drag */ + if (isRightClickDragStarted) { + if (rightClickHoveredSlots.size() > 1) { + + /** - Return all slots to normal */ + minecraft.player.inventory.setCursorItem(new ItemInstance(rightClickPersistentStack.itemId, rightClickItemAmount, rightClickPersistentStack.getDamage())); + for (int leftClickHoveredSlotsIndex = 0; leftClickHoveredSlotsIndex < rightClickHoveredSlots.size(); leftClickHoveredSlotsIndex++) { + if (0 != rightClickExistingAmount.get(leftClickHoveredSlotsIndex)) { + rightClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(new ItemInstance(rightClickPersistentStack.itemId, rightClickExistingAmount.get(leftClickHoveredSlotsIndex), rightClickPersistentStack.getDamage())); + } else { + rightClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(null); } + } + + /** - Reset Right-click + Drag variables and exit function */ + inventoryTweaks_resetRightClickDragVariables(); + + return true; + } + } + + return false; + } - /** - Return all slots to normal */ - List leftClickAmountToFill = new ArrayList<>(); - minecraft.player.inventory.setCursorItem(new ItemInstance(leftClickPersistentStack.itemId, leftClickItemAmount, leftClickPersistentStack.getDamage())); - for (int leftClickHoveredSlotsIndex = 0; leftClickHoveredSlotsIndex < leftClickHoveredSlots.size(); leftClickHoveredSlotsIndex++) { - leftClickAmountToFill.add(leftClickAmountToFillPersistent.get(leftClickHoveredSlotsIndex)); - if (0 != leftClickExistingAmount.get(leftClickHoveredSlotsIndex)) { - leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(new ItemInstance(leftClickPersistentStack.itemId, leftClickExistingAmount.get(leftClickHoveredSlotsIndex), leftClickPersistentStack.getDamage())); + @Unique private void inventoryTweaks_resetRightClickDragVariables() + { + rightClickExistingAmount.clear(); + rightClickHoveredSlots.clear(); + rightClickPersistentStack = null; + rightClickItemAmount = 0; + isRightClickDragStarted = false; + } + + @Unique private boolean inventoryTweaks_handleLeftClickWithItem(ItemInstance cursorStack, Slot clickedSlot) { + /** - Ensure a slot was clicked */ + if (clickedSlot != null) { + /** - Record how many items are in the slot and how many items are needed to fill the slot */ + if (null != clickedSlot.getItem()) { + leftClickAmountToFillPersistent.add(cursorStack.getMaxStackSize() - clickedSlot.getItem().count); + leftClickExistingAmount.add(clickedSlot.getItem().count); + } else { + leftClickAmountToFillPersistent.add(cursorStack.getMaxStackSize()); + leftClickExistingAmount.add(0); + } + + /** - Begin Left-click + Drag */ + if (cursorStack != null && leftClickPersistentStack == null && isLeftClickDragStarted == false) { + leftClickPersistentStack = cursorStack; + leftClickItemAmount = leftClickPersistentStack.count; + isLeftClickDragStarted = true; + } + + /** - Handle initial Left-click */ + lastLMBSlotId = clickedSlot.id; + lastLMBSlot = clickedSlot; + if (Config.ModernMinecraftConfig.LMBPreferShiftClick) { + boolean isShiftKeyDown = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 0, isShiftKeyDown, this.minecraft.player); + + if (isShiftKeyDown) { + inventoryTweaks_resetLeftClickDragVariables(); + leftClickMouseTweaksPersistentStack = cursorStack; + isLeftClickDragMouseTweaksStarted = true; + } + } else { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 0, false, this.minecraft.player); + } + + return true; + } + + return false; + } + + @Unique private boolean inventoryTweaks_handleLeftClickWithoutItem(Slot clickedSlot) { + isLeftClickDragMouseTweaksStarted = true; + + /** - Ensure a slot was clicked */ + if (clickedSlot != null) { + /** - Get info for MouseTweaks `Left-Click + Drag` mechanics */ + ItemInstance itemInSlot = clickedSlot.getItem(); + leftClickMouseTweaksPersistentStack = itemInSlot; + + /** - Handle initial Left-click */ + lastLMBSlotId = clickedSlot.id; + lastLMBSlot = clickedSlot; + boolean isShiftKeyDown = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)); + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, clickedSlot.id, 0, isShiftKeyDown, this.minecraft.player); + + return true; + } else { + /** - Get info for MouseTweaks `Left-Click + Drag` mechanics */ + leftClickMouseTweaksPersistentStack = null; + } + + return false; + } + + @Unique private void inventoryTweaks_handleLeftClickDragMouseTweaks() { + if (slot.id != lastLMBSlotId) { + lastLMBSlotId = slot.id; + + ItemInstance slotItemToExamine = slot.getItem(); + if (null != slotItemToExamine) + { + if (null != leftClickMouseTweaksPersistentStack) + { + if (slotItemToExamine.isDamageAndIDIdentical(leftClickMouseTweaksPersistentStack)) + { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) { + if (Config.MouseTweaksConfig.LMBTweakShiftClick) + { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, true, this.minecraft.player); + } } else { - leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(null); + if (Config.MouseTweaksConfig.LMBTweakPickUp) { + ItemInstance cursorStack = minecraft.player.inventory.getCursorItem(); + + if (cursorStack == null) { + /** - Pick up items from slot */ + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + } else if (cursorStack.count < leftClickMouseTweaksPersistentStack.getMaxStackSize()) { + int amountAbleToPickUp = leftClickMouseTweaksPersistentStack.getMaxStackSize() - cursorStack.count; + int amountInSlot = slotItemToExamine.count; + + /** - Pick up items from slot */ + if (amountInSlot <= amountAbleToPickUp) { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + } else if (cursorStack.count == leftClickMouseTweaksPersistentStack.getMaxStackSize()) { + slot.setStack(new ItemInstance(leftClickMouseTweaksPersistentStack.itemId, cursorStack.count, leftClickMouseTweaksPersistentStack.getDamage())); + minecraft.player.inventory.setCursorItem(new ItemInstance(leftClickMouseTweaksPersistentStack.itemId, amountInSlot, leftClickMouseTweaksPersistentStack.getDamage())); + } else { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + + slotItemToExamine = slot.getItem(); + cursorStack = minecraft.player.inventory.getCursorItem(); + amountInSlot = slotItemToExamine.count; + + slot.setStack(new ItemInstance(leftClickMouseTweaksPersistentStack.itemId, cursorStack.count, leftClickMouseTweaksPersistentStack.getDamage())); + minecraft.player.inventory.setCursorItem(new ItemInstance(leftClickMouseTweaksPersistentStack.itemId, amountInSlot, leftClickMouseTweaksPersistentStack.getDamage())); + } + } + } } } + } else if ( (Config.MouseTweaksConfig.LMBTweakShiftClickAny) + && ( (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + || (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) + ) + ) { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, true, this.minecraft.player); + } + } + } + } - /** - Prepare to distribute over slots */ - int numberOfSlotsRemainingToFill = leftClickHoveredSlots.size(); - int itemsPerSlot = leftClickItemAmount / numberOfSlotsRemainingToFill; - int leftClickRemainingItemAmount = leftClickItemAmount; - boolean rerunLoop; + @Unique private boolean inventoryTweaks_handleLeftClickDrag() + { + /** - Do nothing if slot has already been added to Left-click + Drag logic */ + if (!leftClickHoveredSlots.contains(slot)) { + ItemInstance slotItemToExamine = slot.getItem(); - /** - Distribute fewer items to slots whose max stack size will be filled */ - do { - rerunLoop = false; - if (0 != numberOfSlotsRemainingToFill) { - itemsPerSlot = leftClickRemainingItemAmount / numberOfSlotsRemainingToFill; + /** - Do nothing if slot item does not match held item */ + if (null != slotItemToExamine && !slotItemToExamine.isDamageAndIDIdentical(leftClickPersistentStack)){ + return true; + } - if (0 != itemsPerSlot) - { - for (int slotsToCheckIndex = 0; slotsToCheckIndex < leftClickAmountToFill.size(); slotsToCheckIndex++) { - if (0 != leftClickAmountToFill.get(slotsToCheckIndex) && leftClickAmountToFill.get(slotsToCheckIndex) < itemsPerSlot) { - /** - Just fill the slot and return */ - for (int fillTheAmountIndex = 0; fillTheAmountIndex < leftClickAmountToFill.get(slotsToCheckIndex); fillTheAmountIndex++) { - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, leftClickHoveredSlots.get(slotsToCheckIndex).id, 1, false, this.minecraft.player); - } - - leftClickRemainingItemAmount = leftClickRemainingItemAmount - leftClickAmountToFill.get(slotsToCheckIndex); - leftClickAmountToFill.set(slotsToCheckIndex, 0); - numberOfSlotsRemainingToFill--; - rerunLoop = true; + /** - Do nothing if there are no more items to distribute */ + if (1.0 == (double)leftClickItemAmount / (double)leftClickHoveredSlots.size()) { + return true; + } + + /** - First slot is handled instantly in mouseClicked function */ + if (slot.id != lastLMBSlotId) { + if (0 == leftClickHoveredSlots.size()) + { + /** - Add slot to item distribution */ + leftClickHoveredSlots.add(lastLMBSlot); + } + + /** - Add slot to item distribution */ + leftClickHoveredSlots.add(slot); + + /** - Record how many items are in the slot and how many items are needed to fill the slot */ + if (null != slotItemToExamine) { + leftClickAmountToFillPersistent.add(leftClickPersistentStack.getMaxStackSize() - slotItemToExamine.count); + leftClickExistingAmount.add(slotItemToExamine.count); + } + else + { + leftClickAmountToFillPersistent.add(leftClickPersistentStack.getMaxStackSize()); + leftClickExistingAmount.add(0); + } + + /** - Return all slots to normal */ + List leftClickAmountToFill = new ArrayList<>(); + minecraft.player.inventory.setCursorItem(new ItemInstance(leftClickPersistentStack.itemId, leftClickItemAmount, leftClickPersistentStack.getDamage())); + for (int leftClickHoveredSlotsIndex = 0; leftClickHoveredSlotsIndex < leftClickHoveredSlots.size(); leftClickHoveredSlotsIndex++) { + leftClickAmountToFill.add(leftClickAmountToFillPersistent.get(leftClickHoveredSlotsIndex)); + if (0 != leftClickExistingAmount.get(leftClickHoveredSlotsIndex)) { + leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(new ItemInstance(leftClickPersistentStack.itemId, leftClickExistingAmount.get(leftClickHoveredSlotsIndex), leftClickPersistentStack.getDamage())); + } else { + leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(null); + } + } + + /** - Prepare to distribute over slots */ + int numberOfSlotsRemainingToFill = leftClickHoveredSlots.size(); + int itemsPerSlot = leftClickItemAmount / numberOfSlotsRemainingToFill; + int leftClickRemainingItemAmount = leftClickItemAmount; + boolean rerunLoop; + + /** - Distribute fewer items to slots whose max stack size will be filled */ + do { + rerunLoop = false; + if (0 != numberOfSlotsRemainingToFill) { + itemsPerSlot = leftClickRemainingItemAmount / numberOfSlotsRemainingToFill; + + if (0 != itemsPerSlot) + { + for (int slotsToCheckIndex = 0; slotsToCheckIndex < leftClickAmountToFill.size(); slotsToCheckIndex++) { + if (0 != leftClickAmountToFill.get(slotsToCheckIndex) && leftClickAmountToFill.get(slotsToCheckIndex) < itemsPerSlot) { + /** - Just fill the slot and return */ + for (int fillTheAmountIndex = 0; fillTheAmountIndex < leftClickAmountToFill.get(slotsToCheckIndex); fillTheAmountIndex++) { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, leftClickHoveredSlots.get(slotsToCheckIndex).id, 1, false, this.minecraft.player); } + + leftClickRemainingItemAmount = leftClickRemainingItemAmount - leftClickAmountToFill.get(slotsToCheckIndex); + leftClickAmountToFill.set(slotsToCheckIndex, 0); + numberOfSlotsRemainingToFill--; + rerunLoop = true; } } } - } while (rerunLoop && 0 != numberOfSlotsRemainingToFill); + } + } while (rerunLoop && 0 != numberOfSlotsRemainingToFill); - /** - Distribute remaining items evenly over remaining slots that were not already filled to max stack size */ - for (int distributeSlotsIndex = 0; distributeSlotsIndex < leftClickHoveredSlots.size(); distributeSlotsIndex++) { - if (0 != leftClickAmountToFill.get(distributeSlotsIndex)) { - for (int addSlotIndex = 0; addSlotIndex < itemsPerSlot; addSlotIndex++) { - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, leftClickHoveredSlots.get(distributeSlotsIndex).id, 1, false, this.minecraft.player); - } + /** - Distribute remaining items evenly over remaining slots that were not already filled to max stack size */ + for (int distributeSlotsIndex = 0; distributeSlotsIndex < leftClickHoveredSlots.size(); distributeSlotsIndex++) { + if (0 != leftClickAmountToFill.get(distributeSlotsIndex)) { + for (int addSlotIndex = 0; addSlotIndex < itemsPerSlot; addSlotIndex++) { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, leftClickHoveredSlots.get(distributeSlotsIndex).id, 1, false, this.minecraft.player); } } } } - } else { - inventoryTweaks_resetLeftClickDragVariables(); } + + return false; + } + + @Unique private boolean inventoryTweaks_cancelLeftClickDrag() + { + /** - Cancel Left-click + Drag */ + if (isLeftClickDragStarted) { + if (leftClickHoveredSlots.size() > 1) { + + /** - Return all slots to normal */ + minecraft.player.inventory.setCursorItem(new ItemInstance(leftClickPersistentStack.itemId, leftClickItemAmount, leftClickPersistentStack.getDamage())); + for (int leftClickHoveredSlotsIndex = 0; leftClickHoveredSlotsIndex < leftClickHoveredSlots.size(); leftClickHoveredSlotsIndex++) { + if (0 != leftClickExistingAmount.get(leftClickHoveredSlotsIndex)) { + leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(new ItemInstance(leftClickPersistentStack.itemId, leftClickExistingAmount.get(leftClickHoveredSlotsIndex), leftClickPersistentStack.getDamage())); + } else { + leftClickHoveredSlots.get(leftClickHoveredSlotsIndex).setStack(null); + } + } + + /** - Reset Left-click + Drag variables and exit function */ + inventoryTweaks_resetLeftClickDragVariables(); + return true; + } + } + + return false; + } + + @Unique private void inventoryTweaks_resetLeftClickDragVariables() + { + leftClickExistingAmount.clear(); + leftClickAmountToFillPersistent.clear(); + leftClickHoveredSlots.clear(); + leftClickPersistentStack = null; + leftClickMouseTweaksPersistentStack = null; + leftClickItemAmount = 0; + isLeftClickDragStarted = false; + isLeftClickDragMouseTweaksStarted = false; } @Unique @@ -385,38 +733,57 @@ private void inventoryTweaks_mouseReleasedOrSlotChanged(int mouseX, int mouseY, @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/container/ContainerBase;isMouseOverSlot(Lnet/minecraft/container/slot/Slot;II)Z")) private boolean inventoryTweaks_isMouseOverSlot(ContainerBase guiContainer, Slot slot, int x, int y) { - return ( (drawingHoveredSlot = rightClickHoveredSlots.contains(slot)) - || (drawingHoveredSlot = leftClickHoveredSlots.contains(slot)) - || isMouseOverSlot(slot, x, y) - ); + if (Config.ModernMinecraftConfig.EnableDragGraphics) { + return ( (drawingHoveredSlot = rightClickHoveredSlots.contains(slot)) + || (drawingHoveredSlot = leftClickHoveredSlots.contains(slot)) + || isMouseOverSlot(slot, x, y) + ); + } else { + return isMouseOverSlot(slot, x, y); + } } @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/container/ContainerBase;fillGradient(IIIIII)V", ordinal = 0)) private void inventoryTweaks_fillGradient(ContainerBase instance, int startX, int startY, int endX, int endY, int colorStart, int colorEnd) { - if (colorStart != colorEnd) throw new AssertionError(); - int color = drawingHoveredSlot ? 0x20ffffff : colorStart; - this.fillGradient(startX, startY, endX, endY, color, color); + if (Config.ModernMinecraftConfig.EnableDragGraphics) { + if (colorStart != colorEnd) throw new AssertionError(); + int color = drawingHoveredSlot ? 0x20ffffff : colorStart; + this.fillGradient(startX, startY, endX, endY, color, color); + } else { + this.fillGradient(startX, startY, endX, endY, colorStart, colorEnd); + } } @Inject(method = "keyPressed", at = @At("RETURN")) private void inventoryTweaks_keyPressed(char character, int keyCode, CallbackInfo ci) { - if (this.slot == null) + if (this.slot == null) { return; + } - if (keyCode == this.minecraft.options.dropKey.key) { - if (this.minecraft.player.inventory.getCursorItem() != null) - return; + if (Config.ModernMinecraftConfig.UseDropKeyInInventory) { + if (keyCode == this.minecraft.options.dropKey.key) { + if (this.minecraft.player.inventory.getCursorItem() != null) { + return; + } - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, -999, Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 0 : 1, false, this.minecraft.player); - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + if (Config.ModernMinecraftConfig.LCtrlStackDrop) { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, -999, Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) ? 0 : 1, false, this.minecraft.player); + } else { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, -999, 1, false, this.minecraft.player); + } + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + } } - if (keyCode >= Keyboard.KEY_1 && keyCode <= Keyboard.KEY_9) { - if (this.minecraft.player.inventory.getCursorItem() == null) + if (Config.ModernMinecraftConfig.NumKeyHotbarSwap) { + if (keyCode >= Keyboard.KEY_1 && keyCode <= Keyboard.KEY_9) { + if (this.minecraft.player.inventory.getCursorItem() == null) { + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + } + this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, 35 + keyCode - 1, 0, false, this.minecraft.player); this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, 35 + keyCode - 1, 0, false, this.minecraft.player); - this.minecraft.interactionManager.clickSlot(this.container.currentContainerId, slot.id, 0, false, this.minecraft.player); + } } } } diff --git a/src/main/java/com/github/telvarost/inventorytweaks/mixin/PlayerMixin.java b/src/main/java/com/github/telvarost/inventorytweaks/mixin/PlayerMixin.java index 2e629df..bd8e474 100644 --- a/src/main/java/com/github/telvarost/inventorytweaks/mixin/PlayerMixin.java +++ b/src/main/java/com/github/telvarost/inventorytweaks/mixin/PlayerMixin.java @@ -1,5 +1,6 @@ package com.github.telvarost.inventorytweaks.mixin; +import com.github.telvarost.inventorytweaks.Config; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.ClientPlayer; import net.minecraft.entity.player.PlayerBase; @@ -13,6 +14,10 @@ public abstract class PlayerMixin { @Inject(method = "dropSelectedItem", at = @At("HEAD"), cancellable = true) private void inventoryTweaks_dropSelectedItem(CallbackInfo ci) { + if (!Config.ModernMinecraftConfig.LCtrlStackDrop) { + return; + } + if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) { Minecraft minecraft = MinecraftAccessor.getInstance(); PlayerBase playerBase = (PlayerBase) (Object) this;