
Fast Trade Glitch
Closed this issue ยท 2 comments
Hey, recently I've discovered a pretty annoying thing which is when fast trading with a shopkeeper it does not check if the item that is getting put inside the trading menu is the same item we need there.
My server specs:
This server is running Paper version 1.21.4-68-main@9298f59 (2024-12-30T20:42:05Z) (Implementing API version 1.21.4-R0.1-SNAPSHOT)
You are 164 version(s) behind
Download the new version at: https://papermc.io/downloads/paper
Shopkeepers version: Shopkeepers-2.23.8
To reproduce the issue create a shopkeeper with on the cost put in stripped spruce wood (or any material) and to the reward place put the same material but with some other metadata (I have unbreaking 10 on it).
Grab some stripped spruce wood in your inventory and click on the trade trading entry? (Shown in the image).
Now claim that piece that the shopkeeper rewards you with, and press space (It refills the material you need as cost from your inventory) and voila, it didn't put in the required cost, but the enchanted form you got as reward the last time.
Now I would highly appreciate if you could patch this issue in the nearest patch.
And here is a video that was originally provided to me.
2025-06-26.18-25-08.mp4
The behavior in question is inteded and matches how trades work in vanilla Minecraft: The trade specifies that a certain item with certain metadata is required, and as long as the item provided by the player matches these requirements, it is allowed to be traded. In your case, the trade specifies "give me any stripped wood", so the player is allowed to use the enchanted wood for this trade. Additional metadata of the passed items is ignored.
There is a setting in the config use-strict-item-comparison
: When enabled, trades are prevented unless the items perfectly match. However, note that this will result in client-side "glitches": The item in the result slot will still show up (there is no way for me to easily prevent this on the server side). So for the player it looks like they might be able to trade, but once they actually try to pickup the result item, the shopkeepers plugin cancel the trade.
Edit: There is one thing I could consider doing though: Currently, when you shift trade, the shopkeepers plugin continues processing trades as long as Minecraft inserts further compatible items into the trade input slots. However, to avoid accidentally consuming other items from the player's inventory, I could check if the items in the input slots have changed and then abort the processing of further trades. I still have to test this, but depending on how the items are ordered inside the player inventory, this might then end up aborting the automatic shift trading earlier then the player might expect it, i.e. there might be further stripped wood items in the inventory, but the shift trading is aborted because minecraft decided to continue the trade with the enchanted items that happen to be stored in a lower inventory slot. But either way, I certainly don't want to reimplement this vanilla logic of how Minecraft inserts items into the trade input slots.
Update: The behavior in question is intended.
Regarding the idea of manually aborting the shift trading: I misread the original message and now did some additional testing, and I didn't notice that the items are not moved to the input slots automatically by Minecraft during a single shift-click trade, but only in reaction to the player clicking the spacebar. I do not want to try to make changes to this vanilla logic.
This is vanilla logic. If some server wants to make changes to that, this could also be implemented as a different plugin.
However, this might actually be a bit tricky to implement for plugins, since from the server's perspective there is no clear way to differentiate whether the items are inserted by Minecraft due to pressing the space bar vs the player themselves manually moving the items into the input slots.
If you want the shopkeeper trading to only trade if the items are perfectly matching, there is already the above mentioned config setting for that. But this will still allow player's to move then incompatible items to the input slots via spacebar, since the Minecraft client expects those items to be valid for the trade.