// Find stack slot (look in hotbar only).
// We're looking for a brand new stack in the hotbar
// (not an existing stack whose amount has been increased)
int currentSlot = -1;
for (int i = 0; i < InvTweaksConst.INVENTORY_HOTBAR_SIZE; i++) {
ItemStack currentHotbarStack = containerMgr.getItemStack(i + 27);
// Don't move already started stacks
if (currentHotbarStack != null && getAnimationsToGo(currentHotbarStack) == 5 && hotbarClone[i] == null) {
currentSlot = i + 27;
}
}
if (currentSlot != -1) {
itemPickupPending = false;
// Find preffered slots
List<Integer> prefferedPositions = new LinkedList<Integer>();
InvTweaksItemTree tree = config.getTree();
ItemStack stack = containerMgr.getItemStack(currentSlot);
List<InvTweaksItemTreeItem> items = tree.getItems(getItemID(stack),
getItemDamage(stack));
for (InvTweaksConfigSortingRule rule : config.getRules()) {
if (tree.matches(items, rule.getKeyword())) {
for (int slot : rule.getPreferredSlots()) {