Open opl- opened 10 years ago
Bug: Method ChestInventory.selectItemAtWithShift crashes every time you call it with slot >= 54.
Fix:
@Override public synchronized void selectItemAtWithShift(int slot) { delay(); ItemStack item = getItemAt(slot); int rangeStart, rangeEnd; if(item == null) return; if(slot < items.length) { rangeStart = items.length; rangeEnd = items.length + inventory.length; } else { rangeStart = 0; rangeEnd = items.length; } boolean slotFound = false; for(int i = rangeStart; i < rangeEnd; i++) { if((slot < items.length ? inventory[i - items.length] : items[i]) == null) { if(slot < items.length) { items[slot] = null; inventory[i - items.length] = item; } else { items[i] = item; inventory[slot - items.length] = null; } slotFound = true; break; } } if(!slotFound) return; bot.getEventBus().fire(new InventoryChangeEvent(this, slot, 0, (short) 0, item, true)); }
I tried making a PR but i failed. My GitHub skills are just terrible, so I'm posting this as an issue with proposed fix.
The inventory system is rather poorly implemented and now outdated.
Bug: Method ChestInventory.selectItemAtWithShift crashes every time you call it with slot >= 54.
Fix:
I tried making a PR but i failed. My GitHub skills are just terrible, so I'm posting this as an issue with proposed fix.