Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-271974

Wolf armor spawns at wolves' feet when their armor is sheared

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 23w51a, 1.20.6, 24w19b, 24w20a, 24w21b
    • None
    • Confirmed
    • Items
    • Low
    • 1236106
    • Expansion A

      The Bug:

      Wolf armor spawns at wolves' feet when their armor is sheared.

      The wolf armor technically spawns below its visual model which isn't correct and I believe it should instead spawn higher up, possibly at the top of the wolf's bounding box

      Steps to Reproduce:

      1. Tame the wolf, equip it with some wolf armor, and obtain some shears.
      2. Freeze the world so you can easily observe where the wolf armor item spawns by using the command provided below.
        /tick freeze
      3. Shear the wolf and observe where the wolf armor spawns.

      Observed Behavior:

      The wolf armor item spawns at the bottom of the wolf's bounding box.

      Expected Behavior:

      The wolf armor item would spawner higher up.

      Code Analysis:

      Code analysis by Avoma can be found below.

      The following is based on a decompiled version of 24w21b using Mojang mappings.

      net.minecraft.world.entity.animal.Wolf.java
      public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder<Holder<WolfVariant>> {
         ...
         public InteractionResult mobInteract(Player player, InteractionHand interactionHand) {
            ...
            if (this.isTame()) {
               ...
               if (itemStack.is(Items.SHEARS) && this.isOwnedBy(player) && this.hasArmor() && (!EnchantmentHelper.has(this.getBodyArmorItem(), EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE) || player.isCreative())) {
                  itemStack.hurtAndBreak(1, player, Wolf.getSlotForHand(interactionHand));
                  this.playSound(SoundEvents.ARMOR_UNEQUIP_WOLF);
                  ItemStack itemStack2 = this.getBodyArmorItem();
                  this.setBodyArmorItem(ItemStack.EMPTY);
                  this.spawnAtLocation(itemStack2);
                  return InteractionResult.SUCCESS;
               }
               ...

      If we look at the above class, we can see that when a wolf wearing wolf armor is sheared, the wolf armor spawns at the wolf's position. This is evident through the following line of code:

      this.spawnAtLocation(itemStack2);

            Unassigned Unassigned
            Avoma [Mod] Avoma
            Votes:
            4 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: