
Shopkeepers don't let you trade.
ReddoMC opened this issue ยท 4 comments
I have a shopkeeper with custom pickaxes in them that have NBT data and custom break speed on them. Sometimes a player tells me they can't do the trade, then when i grab an exact copy of their items and do the trade, it works. Or sometimes it's the other way around, i can't do the trade but my friend can.
Even when grabbing a copy of the player's pickaxe and replacing the item in the shopkeeper with that item, the issue still stays, and sometimes it also magically goes away.
We recently changed our pickaxes to look nicer and work better by adding NBT tags to them, and that's when this issue started happening.
Here is a video from one of my friends: https://github.com/user-attachments/assets/7553ba1e-9505-463b-9f43-6a15d36752a4
Since the result item shows up, my current guess would be that there is maybe some discrepancy between the client-side and server-side, usually caused by other plugins interfering with the item data packets sent by the server to the client.
Therefore, once you have some item combination identified that does not work, try to reproduce your issue on a normal and up-to-date Spigot server, without other plugins, and without any client-side mods if any. Then step-by-step make changes towards your actual setup until you can reproduce the issue again. This should help you identify which component (e.g. other plugin) is involved.
Additionally, you can also check the wiki https://github.com/Shopkeepers/Shopkeepers-Wiki/wiki/Known-Issues if you are using any of the plugins mentioned there. Check especially for item and protocol related plugins.
Additionally, you can also temporarily turn on the debug mode when the issue occurs, reproduce the issue, and then check the server log. Maybe the log messages yield some additional information.
And you can use Minecraft's /data ...
command to inspect and manually compare the NBT data of items on the server side. Maybe this also helps identifying and differences.
I used debug mode and checked what the console was saying.
It says this:
[14:59:15 INFO]: [Shopkeepers] Inventory click: player=ReddoMC, view-type=MERCHANT, view-title=?2Shopkeeper, raw-slot-id=2, slot-id=2, slot-type=RESULT, shift=false, hotbar key=-1, left-or-right=left, click-type=LEFT, action=NOTHING, time: 37828069655
[14:59:15 INFO]: [Shopkeepers] Shopkeeper 53: Not handling trade: There is no item in the clicked result slot (no trade available).
Even though the result item is visible, it just cancels it going into your inventory.
We have Citizens and ItemsAdder, but we are not getting any Citizens error and this isn't an ItemsAdder item.
I also noticed a small different in the nbt of the working item, and the broken item. But i don't know if this helps.
Also, just for some extra context. We are using a paper server on version 1.20.6. Though we have ViaVersion and most players play on 1.21.4.
Not handling trade: There is no item in the clicked result slot (no trade available).
This indicates that there is a discrepancy between the server and the client state: The client sees a result item, but on the server there is no result item because the server thinks that the traded items are not compatible. This usually occurs if one of the other plugins installed on your server messes with the item packets being sent between the server and the client.
If you check the "Known Issues" page linked above, both ViaVersion and ItemsAdder are known to have caused issues in this area in the past, so they are strong contenders for interfering with the item packets and therefore the trading.
Try to reproduce your issue without any plugins that might interfer with the item packets or items.
I also noticed a small different in the nbt of the working item, and the broken item.
Items that are not perfectly equal in their data are not be accepted in villager trades.
Make sure that you / your plugins create these items consistently with the same internal data everywhere. If one of your other plugins after some update changed how they create these custom items, newly created items might no longer work with items previously created and stored in shopkeepers. You will then need to report this to them, or update the shopkeepers to use the new item format, and maybe also offer players some shopkeeper to trade in their old items and replace them with corresponding new ones. There is no utility I am aware of that would be able to replace all items on the server automatically in one go (inside shopkeepers, but also inside player inventories and inside the world, chests, etc.).
There also have been changes to the item data of attribute modifiers in MC 1.21.+ https://minecraft.wiki/w/Attribute#History
Maybe ViaVersion is trying to dynamically convert between the attribute modifier formats of the different MC versions and thereby interfering in some way.