Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Comment thread
31a05b9c marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.combat.AutoTotem;
import meteordevelopment.meteorclient.utils.player.InvUtils;
import meteordevelopment.meteorclient.utils.player.SlotUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -136,25 +137,29 @@ private void checkSlot(int slot, ItemStack stack) {

// If there are still items left in the stack, but it just crossed the threshold
if (stack.isStackable() && !stack.isEmpty() && stack.getCount() <= minCount.get()) {
fromSlot = findItem(stack, slot, minCount.get() - stack.getCount() + 1);
fromSlot = findItem(stack, slot, minCount.get() - stack.getCount() + 1, true);
}

// If the stack just went from above the threshold to empty in a single tick
// this can happen if the threshold is set low enough while using modules that
// place many blocks per tick, like surround or holefiller
if (prevStack.isStackable() && stack.isEmpty() && !prevStack.isEmpty()) {
fromSlot = findItem(prevStack, slot, minCount.get() - stack.getCount() + 1);
fromSlot = findItem(prevStack, slot, minCount.get() - stack.getCount() + 1, false);
}

// Unstackable items
if (unstackable.get() && !prevStack.isStackable() && stack.isEmpty() && !prevStack.isEmpty()) {
fromSlot = findItem(prevStack, slot, 1);
fromSlot = findItem(prevStack, slot, 1, false);
}

// eliminate occasional loops when moving items from hotbar to itself
if (fromSlot == mc.player.getInventory().getSelectedSlot()) return;
if ((fromSlot < 9 || fromSlot == SlotUtils.OFFHAND) && fromSlot < slot && slot != mc.player.getInventory().getSelectedSlot()) return;

InvUtils.move().from(fromSlot).to(slot);
}

private int findItem(ItemStack lookForStack, int excludedSlot, int goodEnoughCount) {
private int findItem(ItemStack lookForStack, int excludedSlot, int goodEnoughCount, boolean mustCombine) {
int slot = -1;
int count = 0;

Expand All @@ -164,6 +169,7 @@ private int findItem(ItemStack lookForStack, int excludedSlot, int goodEnoughCou
ItemStack stack = mc.player.getInventory().getStack(i);
if (stack.getItem() != lookForStack.getItem()) continue;

if (mustCombine && !ItemStack.areItemsAndComponentsEqual(lookForStack, stack)) continue;
if (sameEnchants.get() && !stack.getEnchantments().equals(lookForStack.getEnchantments())) continue;
Comment thread
31a05b9c marked this conversation as resolved.

if (stack.getCount() > count) {
Expand Down