Mojira Archive
MC-114106

Dispenser plays failed sound when equipping a single pumpkin or skull

The bug

Dispensers play the dispensing failed sound when they equip a single pumpkin or skull.

How to reproduce

  1. Activate subtitles
  2. Put a stack of multiple pumpkins or skulls in a dispenser
  3. Stand in front of the dispenser and activate it
    It will play the sound when an item was successfully dispensed and show the subtitle "Dispensed item"
  4. Put only a single pumpkin or skull in the dispenser and unequip the one you are currently wearing
  5. Stand in front of the dispenser and activate it
    It will play the sound when an item was not successfully dispensed and show the subtitle "Dispenser failed"

Code analysis

Based on 1.11.2 decompiled using MCP 9.35 rc1

The respective methods set the field net.minecraft.init.Bootstrap.BehaviorDispenseOptional.successful to false it the item returned after dispensing is "empty". Instead they should set it to false only if the count did not change.
Additionally the method net.minecraft.item.ItemArmor.dispenseArmor(IBlockSource, ItemStack) should probably return the item if not entity can be equipped instead of returning an empty item.
The method net.minecraft.item.ItemArmor.DISPENSER_BEHAVIOR.new BehaviorDefaultDispenseItem() {...}.dispenseStack(IBlockSource, ItemStack) should then test as well if the count did not change.