When spawning an item with an equippable component with equip_on_interact set to true, you can click most mobs, for example a zombie or skeleton, to equip it just fine, but clicking onto a villager with this item will open its trade menu instead, or cause the villager to shake its head if it has no trades.
The below command will spawn a dripleaf that can be placed on any mob’s head by clicking that mob. (It can’t be swapped onto the players head, to prevent the player accidentally equipping it on themselves.)
/give @s minecraft:big_dripleaf[minecraft:equippable={equip_on_interact:true,slot:head,swappable:false}]Even using this command with an argument which specifies that only a villager can wear the item, the equipping interaction still doesn’t work.
/give @s minecraft:big_dripleaf[minecraft:equippable={equip_on_interact:true,slot:head,swappable:false,allowed_entities:"minecraft:villager"}]
Based on the code analysis, it's only possible if:
The villager is sleeping
The villager is making is trading
Or, the item is a
villager_spawn_eggIt's also necessary that the item doesn't have any other effect when interacting with the villager. For example, if it's a villager spawn egg by default, it will summon a baby villager, but it's possible to remove
minecraft:entity_data.Try using, for example: