Improve InventoryBehavior
Eventually aiming to fix #4020, fix #3409, fix #3000, the first point listed in #3565, and probably other issues.
Supersedes #4021.
While I'm looking at ToolSet (since there's multiple code paths that almost do the same thing but not quite, for example useSwordToMine is only recognized by getBestSlot), it's probably worth fixing the following line to address issues like #3945.
https://github.com/cabaletta/baritone/blob/6654476da435203df9f5f42ed9f41310f5560c30/src/main/java/baritone/utils/ToolSet.java#L181
will InventoryBehavior get a method to safely move items from, to, inside containers (like furnaces)?
will InventoryBehavior get a method to safely move items from, to, inside containers (like furnaces)?
That's not an objective of this PR, but I hope to get the code to a point where adding such functionality would be as simple as creating a custom inventory move operation that could be submitted in a similar way to regular inventory->hotbar moves.
Since I'll be away for the next couple days, will this be capable of doing what this patch could do all the time (i.e. move items on demand)? So far you only seem to plan on cleaning up the old behavior.
To find a slot to move the item to, instead of using hardcoded slots InventoryBehavior could track when each item was last requested and then replace the least recently used one it is allowed to move away (a setting to lock items would be useful). Tracking interactions instead of requests would allow respecting the user needing an item and we could even give user interactions some more importance because the user can't swap items back as easily as Baritone can.
Since I'll be away for the next couple days, will this be capable of doing what this patch could do all the time (i.e. move items on demand)? So far you only seem to plan on cleaning up the old behavior.
Yes. I intend on moving all inventory management code to use InventoryBehavior, which includes MovementHelper.switchToBestToolFor, and will support moving items from the inventory when allowInventory is on.
To find a slot to move the item to, instead of using hardcoded slots
InventoryBehaviorcould track when each item was last requested and then replace the least recently used one it is allowed to move away (a setting to lock items would be useful).
The allowHotbarManagement setting that I currently have is purely to preserve old behavior, as I haven't put in place a way to reserve/lock slots or mark them as important/useful. The hard-coded reserved slots will not be staying.
Tracking interactions instead of requests would allow respecting the user needing an item and we could even give user interactions some more importance because the user can't swap items back as easily as Baritone can.
Good idea 👍
Tools are automatically moved from the inventory as of bc18f0eabd4be03eea6984d333326d8646140505