ItemStack Components added to ItemStack.Empty when dropped
biom4st3r opened this issue ยท 2 comments
This happens on both Dynocaps and XP storage. I assume it happens with all ItemStack Components
https://gitlab.com/biom4st3r/dynocaps
https://github.com/sf-inc/xp_storage
https://user-images.githubusercontent.com/37042156/108777471-73181880-7529-11eb-8334-ce1f22c4e9a6.mp4
Initially you'll see that there are just normal Empty itemstacks in the villager data
After my orange dynocaps is dropped that data from my cap gets added to all the air itemstack in the villager data
it is updateded to the most recently dropped Component itemstack as you can see after I drop the blue dynocap that name in the villager data is changed to Blue
This happens on drop, not on pickup
The data persists on air until the client is relaunched
Tested on Minecraft 1.16.4, CCA 2.7.12 and CCA 2.7.9.
So the issue is when the ItemStack is copied.
if count < 0: isEmpty() -> true
if isEmpty: getItem() -> Items.AIR
if isEmpty: copy() -> ItemStack.EMPTY;
on copy: CCA copies components to the itemstack returned from copy()
I was able to fix this by setting the ordinal of MixinItemStack#copy() to 1 to avoid copying when EMPTY is returned.
It could also be accomplished with a check for isEmpty in CardinalItemInternals#copyComponents.
LMK if you'd like me to pr