Minecraft 1.8.7, Minecraft 1.8.8, Minecraft 15w49b, Minecraft 15w50a, Minecraft 15w51b
Does not matter, reproduced on linux and windows with Java 7
When custom trades with villagers are created they can be cheated as the villager counts the total amount of items in the 2 slots together but does not do the same when removing items, then it treats the slots individually.
STEPS TO REPRODUCE:
1. Create a custom trade like my carrot one in the screnshot
2. Put in the items in reverse like seen in the 2nd screenshot You will notice that the emerald shows up and everything makes perfect sense.
3. Take out the emerald.
4. Instead of all the 65 carrots being removed you end up with screenshot 3
5. It removed the one carrot from the left slot because it was supposed to subtract by 64, so it removed the one carrot that was in that slot. In the right slot it only subtracted by 1 and we end up with 63 carrots left. Now I have only given away 2 of my carrots instead of the 65.
This bug is really severe in my case and other servers that use villagers for our trades as they can now very easily be exploited!