mojira.dev
MC-306588

Items with the Equippable Component and equip_on_interact set to true can not be applied to villagers, even if they're in the allowed_entities list.

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"}]

Comments 1

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_egg

It'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:

/give @s minecraft:villager_spawn_egg[minecraft:equippable={equip_on_interact:true,slot:head,swappable:false},!minecraft:entity_data,minecraft:item_model=big_dripleaf,minecraft:item_name={translate: "block.minecraft.big_dripleaf"}] 1

Watermelon_Sir

(Unassigned)

Confirmed

(Unassigned)

1.21.11

Retrieved