3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 11:00:06 +01:00
Paper/patches
Bjarne Koll 7ae2c671c6
Keep components using single items in creative (#10664)
The craftbukkit implementation stores the old and new data patch of an
item during ItemStack#useOn(UseOnContext) to properly cancel events via
comparison and change detection of the component patch.

However, it uses #getComponentsPatch to fetch the new stack component
patch, which always yields an empty patch set if an itemstack is
considered empty by the game.
As the restoration of an itemstack's count to its previous state is
handled after the entire ItemStack#useOn method, items used in creative
mode temporarily have a count of zero, which causes craftbukkit to
consider their new component patch as EMPTY even tho said item may have
data.
The new patch is applied and, after useOn completes, the count is reset
if the player is in creative mode, leading to lost data.

This commit fixes said inconsistency by directly accessing the
components of the item via components#asPatch, storing the proper
component patch even for an item that temporarily has a count of zero.
2024-05-05 11:40:36 +02:00
..
api add RegistryAccess for managing registries (#10154) 2024-05-04 11:22:35 -07:00
server Keep components using single items in creative (#10664) 2024-05-05 11:40:36 +02:00