r/MinecraftCommands • • 10d ago

Help | Java 1.21.5-1.21.10 Villager Assigning

Hi All,

Currently a tag ownership of a villager to a player via:

advancement revoke  only citizen:interact
tag  add this


# execute if entity [type=villager,distance=..2, nbt={VillagerData:{profession:"minecraft:none"}}] run tellraw  "Villager has not been specialised"


execute if entity [type=villager,distance=..2, nbt={Xp:0}] run execute if entity [type=villager,distance=..2, nbt=!{VillagerData:{profession:"minecraft:nitwit"}}] run tellraw  "Villager has not been specialised"


execute if entity [type=villager,distance=..2, nbt=!{Xp:0}] run execute positioned ^ ^ ^2 as [type=villager,distance=..2,] run function citizen:check
execute if entity [type=villager,distance=..2, nbt={VillagerData:{profession:"minecraft:nitwit"}}] run execute positioned ^ ^ ^2 as u/n[type=villager,distance=..2,] run function citizen:check


tag  remove this

Is there a way to tag it to a Minecraft team instead of a single player so that multiple players can contribute to the same team? or is this outside the capabilities of datapack?

2 Upvotes

2 comments sorted by

2

u/GalSergey Datapack Experienced 10d ago

You can check which team a player is on and execute commands for all players in the specified team.

execute if entity @s[team=red] as @a[team=red] run function ...
execute if entity @s[team=green] as @a[team=green] run function ...
execute if entity @s[team=blue] as @a[team=blue] run function ...

1

u/AutomaticBear3968 6d ago

Thank you 🙏