Fixed the inventory sorting system so it now properly merges duplicate item stacks before sorting.
Before this change the sorter used each stack separately so items like multiple slots of oak planks would stay split across different slots. Now the system first collects all items from the main inventory, adds them up per material, and then rebuilds the inventory.
The main fix was adding a simple material-based map that adds up the item amounts before rebuilding the inventory:
val map = HashMap<Material, Int>()
for (i in 9..35) {
val item = inv.getItem(i)
if (item != null && item.type != Material.AIR) {
map[item.type] = (map[item.type] ?: 0) + item.amount
inv.setItem(i, null)
}
}
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.