Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve InventoryBehavior #4037

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft

Improve InventoryBehavior #4037

wants to merge 21 commits into from

Conversation

ZeroMemes
Copy link
Member

@ZeroMemes ZeroMemes commented Jul 1, 2023

Eventually aiming to fix #4020, fix #3409, fix #3000, the first point listed in #3565, and probably other issues.

Supersedes #4021.

@ZeroMemes
Copy link
Member Author

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.

float hardness = state.getBlockHardness(null, null);

@rycbar0
Copy link
Contributor

rycbar0 commented Jul 5, 2023

will InventoryBehavior get a method to safely move items from, to, inside containers (like furnaces)?

@ZeroMemes
Copy link
Member Author

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.

@ZacSharp
Copy link
Collaborator

ZacSharp commented Jul 6, 2023

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.

@ZeroMemes
Copy link
Member Author

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 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).

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 👍

@ZeroMemes
Copy link
Member Author

Tools are automatically moved from the inventory as of bc18f0e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants