Fix hopper updates source slot twice #11945
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #11740
The
hopperPush
/hopperPull
methods introduced by the Optimize Hoppers patch already update the source slot correctly after moving items:hopperPush
:hopperPull
:However, in
HopperBlockEntity#tryMoveInItem
, if the target slot isn't empty (i.e., a merge happens), the source slot is updated once again by shrinking the sourceItemStack
. This causes issues with certain source containers, such as the chiseled bookshelf.Since the
ChiseledBookShelfBlockEntity
checks whether theremoveItem
call is meaningful (i.e., ensuring it doesn't attempt to remove an already empty slot), andtryMoveInItem
is called beforeremoveItem
, the block state of the current chiseled bookshelf isn't updated properly. As a result, the book still visually remains in the bookshelf:The return value of
tryMoveInItem
is essential (it’s used byhopperPush
/hopperPull
), so I've added a copy before operating the sourceItemStack
to resolve this issue.Download the paperclip jar for this pull request: paper-11945.zip