Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Make PlayerPurchaseEvent respect result item

Open fr3qu3ncy-dev opened this issue 2 years ago • 5 comments

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.

fr3qu3ncy-dev avatar Jan 02 '23 01:01 fr3qu3ncy-dev

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 avatar Jan 02 '23 02:01 Machine-Maker

@Machine-Maker Also tested with shift clicking, working fine.

fr3qu3ncy-dev avatar Jan 02 '23 02:01 fr3qu3ncy-dev

@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 avatar Jan 02 '23 19:01 Machine-Maker

@Machine-Maker What did you set the recipe to? villager_working

fr3qu3ncy-dev avatar Jan 03 '23 19:01 fr3qu3ncy-dev

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.

Machine-Maker avatar Jan 03 '23 20:01 Machine-Maker