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

Add fill all and empty all container actions #7837

Closed
wants to merge 4 commits into from

Conversation

rlnt
Copy link
Contributor

@rlnt rlnt commented Apr 22, 2024

This pull request introduces two new actions for containers: fill all and empty all.
It also changes the default behavior of normal rightclick and leftclick of containers in terminals. The old implementation tried to insert and extract as much as possible and was only limited by the insertion/extraction limit set by the respective handlers of other mods. Basic Mekanism tanks for example only allowed 1 bucket per operation.

The new implementation follows the same approach but tries to insert/extract a bucket at most when leftclicking or rightclicking.
The new feature makes use of the shift key. If you shift-leftclick with a container on a fluid, it will try to fill the whole container. If a container doesn't allow to fill itself at once, the implementation will iterate to repeat the operation. It's limited to 10k iterations tho which is unlikely to happen.
Shift-rightclick allows the opposite and will try to empty the whole container at once.

This pull request covers some of the features requested in issue #3782

It does not implement the filling of stacked items tho.

Let me know if changes are required by submitting a review.

@rlnt rlnt force-pushed the container-emptying branch 3 times, most recently from 15d4dc1 to f7feac7 Compare April 28, 2024 20:45
@rlnt
Copy link
Contributor Author

rlnt commented Apr 28, 2024

Rebased the PR on main.

I also switched to a different approach for the single operation amount. It now uses the amount per unit defined by the key. For fluids, this is still 1000 but if an addon registers a custom container strategy, we should respect their own operation amount in case they are base 2 or something like that.

@rlnt rlnt force-pushed the container-emptying branch 2 times, most recently from df5a5e1 to 103846d Compare May 1, 2024 18:01
what);
} else if (action == InventoryAction.EMPTY_ITEM) {
handleEmptyHeldItem((what, amount, mode) -> realInv.insert(realInvSlot, what, amount, mode));
what, action == InventoryAction.FILL_ALL_ITEM);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You ran spotless, yes? Since this formatting is not great

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did and now I reran it and I get the same output.

@rlnt rlnt closed this May 30, 2024
@rlnt rlnt deleted the container-emptying branch May 30, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants