Paper
Paper copied to clipboard
Make PlayerPurchaseEvent respect result item
When modifying a trade using setTrade() in PlayerPurchaseEvent or PlayerTradeEvent, the result item of that new trade is completely ignored. With this change, you can easily manipulate villager trading from within these events, because it sets the clicked item (which is the result item in MerchantResultSlot) to the new result item.
I think this won’t work for some inventory actions. Like shift clicking? Just mutating the stack object isn’t enough for that.
@Machine-Maker Also tested with shift clicking, working fine.
@fr3qu3ncy-dev shift clicking did not work at all. I set the trade to a custom trade in PlayerTradeEvent, shift-clicked the result slot to move the result into my inventory, and the server actually hung in an infinite loop somewhere.
EDIT: This is also broken if I click on the result item with the same item already in my cursor. It just adds to the stack in the cursor instead of giving me the new item.
@Machine-Maker What did you set the recipe to?
Set it to something that doesn’t consume the ingredients. I basically changed all trades to diamond for a dirt. Put in emeralds, and shift clicking out didn’t work.