Strange Issue while get data from an Item

Hello,
I have a plugin who set custom data to an Item, then read them when you hit something with it to apply an effect. And It works ! But if I drop it or look at it in my inventory, and hit again I cant read them anymore.(my map with my data is empty)
here is the code where I get the data :

Optional<Map<PotionEffectType,Integer>>  dataOpt = item.get(HeKeys.HIT_EFFECT);
           if(dataOpt.isPresent()) {
               List<PotionEffect> potionEffects = new ArrayList<>();
               logger.info("item effect data [{}]", dataOpt.get());

below there is the console with the data get from the item before and after.

[14:11:21 INFO] [effectsmith]: item effect data [{net.minecraft.potion.Potion@3063be68=3}]
[14:11:52 INFO] [effectsmith]: item effect data [{}]

And here we can see two instance of the same item data. The first is after a look in my inventory and the second is a fresh given :


I’m on the recommended build of spongevanilla (7.1.5) .
the link to my datamanipulator maybe I missed something important.

I hope some one have any idea about this strange behaviour.

You need to override toContainer in your immutable variant as well, since this is the one in ItemStackSnapshots which are used in inventories. That should probably fix the looking at it in the inventory thing. It may or may not fix the dropped as item thing. If it doesn’t, then try using SpongeForge and report back whether it worked there or not.

Thank you for your answer,
after a couple of changes on the datamanipulator it works with inventories! (the mistake was that a map of potion effect type which can’t be parsed so I replaced it by string).
Whereas, tested on both vanilla and forge the Issue still occur when I drop the item only in vanilla , (it works well on forge).
More precision , on vanilla when I drop the item, item.get(HeKeys.HIT_EFFECT) return an optional empty not an empty map (data are still present, checked with ntb edit). And another strange things, It work again when I reconnect.

Yep, that’s the bug then.

OK, thank you for the support, I subscribed to the issue :wink: