Minecraft – way to make villagers aggressive against the player in vanilla Minecraft

minecraft-commandsminecraft-java-edition

I'm looking into making some minigames, and I'm not sure how it would work, but Is it possible to make villagers aggressive/evil in vanilla Minecraft?. I'm looking for hurting the player, but also other traits that will give the player the impression that the villagers are unfriendly.

I cannot think how this would be accomplished, but I have seen other seemingly impossible tasks answered here. Any ideas for how I might get this to work, or at least to get me started?

Best Answer

As of 1.9, if a mob is the passenger of another mob, it will take over pathfinding. For example, the following summons a creeper riding a villager, in which the creeper will cause the villager to pathfind towards the player as its target:

/summon Villager ~ ~1 ~ {Passengers:[{id:"Creeper"}]}

If the creeper itself is capable of attacking, it will attempt to when within range. This only affects pathfinding and the villager itself will not do any attacking.

Another example, using an invisible creeper:

/summon Villager ~ ~1 ~ {Passengers:[{id:"Creeper",ActiveEffects:[{Id:14b,Duration:2147483647,ShowParticles:0b}]}]}