fix autototem hsStacked

This commit is contained in:
Daniella / Tove 2024-05-27 22:16:40 +02:00
parent bd87a604d5
commit b1e1586f51

View file

@ -274,39 +274,46 @@ public class AutoTotem extends Feature {
private boolean replenishHyperswap() {
// sideswapping to replenish hotbar when needed
if(replenishCooldown == 0) {
Container container = mc.player.inventoryContainer;
ArrayList<Integer> toFix = new ArrayList<>();
for (int i = 0; i < hotbarSlots; i++) {
ItemStack stack = container.getSlot(44 - i).getStack();
if (stack.getItem() != Items.TOTEM_OF_UNDYING || (hsStacked && stack.getCount() <= switchCount)) {
toFix.add(8 - i);
}
}
if (toFix.isEmpty()) {
Integer toFix = getSlotToReplenish();
if (toFix == null) {
if(redownload) {
InventoryUtils.redownload();
replenishCooldown = replenishRate;
}
return true;
}
Integer slotToFix = toFix.get(0);
if(!hsStacked) {
ArrayList<Integer> invTotemSlots = scan(false, false);
if (invTotemSlots.isEmpty()) {
return false;
}
InventoryUtils.swapWithHB(invTotemSlots.remove(0), slotToFix);
InventoryUtils.swapWithHB(invTotemSlots.remove(0), toFix);
} else {
int slot = findStackSlot();
if(slot == -1) {
return false;
}
InventoryUtils.swapWithHB(slot, slotToFix);
InventoryUtils.swapWithHB(slot, toFix);
}
}
return true;
}
private Integer getSlotToReplenish() {
Container container = mc.player.inventoryContainer;
Integer toFix = null;
int lowestCount = Integer.MAX_VALUE;
for (int i = 0; i < hotbarSlots; i++) {
ItemStack stack = container.getSlot(44 - i).getStack();
if (stack.getItem() != Items.TOTEM_OF_UNDYING || (hsStacked && stack.getCount() <= switchCount)) {
if(stack.getCount() < lowestCount) {
lowestCount = stack.getCount();
toFix = 8 - i;
}
}
}
return toFix;
}
/// STACK
@ -339,7 +346,7 @@ public class AutoTotem extends Feature {
int biggestCount = 0;
int slot = -1;
for (int i = 0 ; i < 5 * 9 ; i++) {
ItemStack itemStack = mc.player.inventoryContainer.getInventory().get(i);
ItemStack itemStack = mc.player.inventoryContainer.getSlot(i).getStack();
if(itemStack.getItem().equals(Items.TOTEM_OF_UNDYING)) {
if(itemStack.getCount() > biggestCount) {
slot = i;