Bukkit/CraftBukkit — pull request #925 by jrtc27 (2012-11-08 07:52:57+00:00)
Title: Fixed dispensor behaviour chaining

If you have a plugin which calls `event.setItem(new ItemStack(Material.MINECART));` in a BlockDispenseEvent handler, the minecart is dispensed as an item rather than a vehicle, despite there being track. The same is true for buckets, boats, projectiles etc., so long as the item in the dispenser does not have the same behaviour as the one you set it to.

The issue is caused by the behaviour 'chaining' which takes place, as the ItemStack passed in to the dispense method is used to obtain the behaviour, rather than the event's ItemStack. However, when this is changed, it creates a bug whereby both the item and the entity are dispensed, as ,`world.addEntity` is called regardless of whether it's going to use a different behaviour or not, which this also fixes.

Ticket: https://bukkit.atlassian.net/browse/BUKKIT-2886