--- a/net/minecraft/world/item/ArmorItem.java
+++ b/net/minecraft/world/item/ArmorItem.java
@@ -1,12 +1,14 @@
 package net.minecraft.world.item;
 
 import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableMultimap.Builder;
 import com.google.common.collect.Multimap;
 import java.util.List;
 import java.util.UUID;
 import javax.annotation.Nullable;
 import net.minecraft.core.BlockPos;
 import net.minecraft.core.BlockSource;
+import net.minecraft.core.Direction;
 import net.minecraft.core.dispenser.DefaultDispenseItemBehavior;
 import net.minecraft.core.dispenser.DispenseItemBehavior;
 import net.minecraft.sounds.SoundEvent;
@@ -24,8 +26,13 @@
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.block.DispenserBlock;
 import net.minecraft.world.phys.AABB;
+// CraftBukkit start
+import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseArmorEvent;
+// CraftBukkit end
 
 public class ArmorItem extends Item implements Wearable {
+
     private static final UUID[] ARMOR_MODIFIER_UUID_PER_SLOT = new UUID[]{UUID.fromString("845DB27C-C624-495F-8C9F-6020A9A58B6B"), UUID.fromString("D8499B04-0E66-4726-AB29-64469D734E0D"), UUID.fromString("9F3D476D-C118-4544-8365-64846904B48E"), UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150")};
     public static final DispenseItemBehavior DISPENSE_ITEM_BEHAVIOR = new DefaultDispenseItemBehavior() {
         @Override
@@ -41,18 +48,46 @@
     private final Multimap<Attribute, AttributeModifier> defaultModifiers;
 
     public static boolean dispenseArmor(BlockSource pointer, ItemStack armor) {
-        BlockPos blockPos = pointer.getPos().relative(pointer.getBlockState().getValue(DispenserBlock.FACING));
-        List<LivingEntity> list = pointer.getLevel().getEntitiesOfClass(LivingEntity.class, new AABB(blockPos), EntitySelector.NO_SPECTATORS.and(new EntitySelector.MobCanWearArmorEntitySelector(armor)));
+        BlockPos blockposition = pointer.getPos().relative((Direction) pointer.getBlockState().getValue(DispenserBlock.FACING));
+        List<LivingEntity> list = pointer.getLevel().getEntitiesOfClass(LivingEntity.class, new AABB(blockposition), EntitySelector.NO_SPECTATORS.and(new EntitySelector.MobCanWearArmorEntitySelector(armor)));
+
         if (list.isEmpty()) {
             return false;
         } else {
-            LivingEntity livingEntity = list.get(0);
-            EquipmentSlot equipmentSlot = Mob.getEquipmentSlotForItem(armor);
-            ItemStack itemStack = armor.split(1);
-            livingEntity.setItemSlot(equipmentSlot, itemStack);
-            if (livingEntity instanceof Mob) {
-                ((Mob)livingEntity).setDropChance(equipmentSlot, 2.0F);
-                ((Mob)livingEntity).setPersistenceRequired();
+            LivingEntity entityliving = (LivingEntity) list.get(0);
+            EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(armor);
+            ItemStack itemstack1 = armor.split(1);
+            // CraftBukkit start
+            Level world = pointer.getLevel();
+            org.bukkit.block.Block block = world.getWorld().getBlockAt(pointer.getPos().getX(), pointer.getPos().getY(), pointer.getPos().getZ());
+            CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+
+            BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.v1_19_R1.entity.CraftLivingEntity) entityliving.getBukkitEntity());
+            if (!DispenserBlock.eventFired) {
+                world.getCraftServer().getPluginManager().callEvent(event);
+            }
+
+            if (event.isCancelled()) {
+                armor.grow(1);
+                return false;
+            }
+
+            if (!event.getItem().equals(craftItem)) {
+                armor.grow(1);
+                // Chain to handler for new item
+                ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+                DispenseItemBehavior idispensebehavior = (DispenseItemBehavior) DispenserBlock.DISPENSER_REGISTRY.get(eventStack.getItem());
+                if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != ArmorItem.DISPENSE_ITEM_BEHAVIOR) {
+                    idispensebehavior.dispense(pointer, eventStack);
+                    return true;
+                }
+            }
+
+            entityliving.setItemSlot(enumitemslot, CraftItemStack.asNMSCopy(event.getItem()));
+            // CraftBukkit end
+            if (entityliving instanceof Mob) {
+                ((Mob) entityliving).setDropChance(enumitemslot, 2.0F);
+                ((Mob) entityliving).setPersistenceRequired();
             }
 
             return true;
@@ -66,13 +101,14 @@
         this.defense = material.getDefenseForSlot(slot);
         this.toughness = material.getToughness();
         this.knockbackResistance = material.getKnockbackResistance();
-        DispenserBlock.registerBehavior(this, DISPENSE_ITEM_BEHAVIOR);
-        ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
-        UUID uUID = ARMOR_MODIFIER_UUID_PER_SLOT[slot.getIndex()];
-        builder.put(Attributes.ARMOR, new AttributeModifier(uUID, "Armor modifier", (double)this.defense, AttributeModifier.Operation.ADDITION));
-        builder.put(Attributes.ARMOR_TOUGHNESS, new AttributeModifier(uUID, "Armor toughness", (double)this.toughness, AttributeModifier.Operation.ADDITION));
+        DispenserBlock.registerBehavior(this, ArmorItem.DISPENSE_ITEM_BEHAVIOR);
+        Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder();
+        UUID uuid = ArmorItem.ARMOR_MODIFIER_UUID_PER_SLOT[slot.getIndex()];
+
+        builder.put(Attributes.ARMOR, new AttributeModifier(uuid, "Armor modifier", (double) this.defense, AttributeModifier.Operation.ADDITION));
+        builder.put(Attributes.ARMOR_TOUGHNESS, new AttributeModifier(uuid, "Armor toughness", (double) this.toughness, AttributeModifier.Operation.ADDITION));
         if (material == ArmorMaterials.NETHERITE) {
-            builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uUID, "Armor knockback resistance", (double)this.knockbackResistance, AttributeModifier.Operation.ADDITION));
+            builder.put(Attributes.KNOCKBACK_RESISTANCE, new AttributeModifier(uuid, "Armor knockback resistance", (double) this.knockbackResistance, AttributeModifier.Operation.ADDITION));
         }
 
         this.defaultModifiers = builder.build();
@@ -98,19 +134,20 @@
 
     @Override
     public InteractionResultHolder<ItemStack> use(Level world, Player user, InteractionHand hand) {
-        ItemStack itemStack = user.getItemInHand(hand);
-        EquipmentSlot equipmentSlot = Mob.getEquipmentSlotForItem(itemStack);
-        ItemStack itemStack2 = user.getItemBySlot(equipmentSlot);
-        if (itemStack2.isEmpty()) {
-            user.setItemSlot(equipmentSlot, itemStack.copy());
+        ItemStack itemstack = user.getItemInHand(hand);
+        EquipmentSlot enumitemslot = Mob.getEquipmentSlotForItem(itemstack);
+        ItemStack itemstack1 = user.getItemBySlot(enumitemslot);
+
+        if (itemstack1.isEmpty()) {
+            user.setItemSlot(enumitemslot, itemstack.copy());
             if (!world.isClientSide()) {
                 user.awardStat(Stats.ITEM_USED.get(this));
             }
 
-            itemStack.setCount(0);
-            return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
+            itemstack.setCount(0);
+            return InteractionResultHolder.sidedSuccess(itemstack, world.isClientSide());
         } else {
-            return InteractionResultHolder.fail(itemStack);
+            return InteractionResultHolder.fail(itemstack);
         }
     }
 
