Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix locking storage and conversion monitors (#8272)
Fix #8179 The bug was probably introduced during the rewrite in 70838d7 I'm still a bit confused how `onUseItemOn` and `onUseWithoutItem` should interact. My findings were that `onUseItemOn` is always called first (even with an empty hand) and only if the event was not consumed (by returning true) `onUseWithoutItem` would be called. My intuition looking at those function names would have been that `onUseItemOn` would never be called with an empty hand in the first place. The problem was, that the event that would potentially lead to the code for locking and unlocking in the `onUseWithoutItem` function was consumed earlier by the `onUseItemOn` function. I chose to check for the `!InteractionUtil.isInAlternateUseMode(player)` condition to bypass those event consumptions. Another functionality that was broken due to a similar problem, that could only be observed after fixing the locking, was the insert all items behavior when right-clicking empty-handedly. This was fixed by the additional check for `else if (!heldItem.isEmpty())` and moving the return into that block so that the empty-handed case would not return true and continue to run into the `onUseWithoutItem` code. Another point for the review: I changed the `return super.onUseWithoutItem(player, pos);` in `onUseWithoutItem` in `AbstractMonitorPart` to `return super.onUseItemOn(heldItem, player, hand, pos);` because it looked like a copy&paste error during the rewrite. If that served a specific purpose feel free to restore it, the fix should work without it.
- Loading branch information