Wolf armor spawns at wolves' feet when their armor is sheared
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:
- Tame the wolf, equip it with some wolf armor, and obtain some shears.
- Freeze the world so you can easily observe where the wolf armor item spawns by using the command provided below.
/tick freeze
- 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 [Mod] 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);
2024-05-13, 07:37 PM
2024-06-07, 07:10 AM
2024-06-07, 07:10 AM
4
5
1236106
-