Updated:
1. Build a glass arena
/fill ~5 ~-1 ~-6 ~17 ~4 ~6 minecraft:glass hollow
hollow builds only the outer shell, so you can watch safely from outside. See the fill command.
2. Summon the fighters
/summon minecraft:zombie ~8 ~ ~ {PersistenceRequired:1b,Tags:["red"]}
/summon minecraft:skeleton ~14 ~ ~ {PersistenceRequired:1b,Tags:["blue"]}
Skeletons burn in daylight, so run /time set night first.
3. Start the fight
/damage @e[tag=red,limit=1] 1 minecraft:mob_attack by @e[tag=blue,limit=1]
/damage @e[tag=blue,limit=1] 1 minecraft:mob_attack by @e[tag=red,limit=1]
Each mob now thinks the other attacked it and goes after it. See the damage command.
4. Team battles
execute as @e[tag=red] at @s run damage @s 1 minecraft:mob_attack by @e[tag=blue,limit=1,sort=nearest]
execute as @e[tag=blue] at @s run damage @s 1 minecraft:mob_attack by @e[tag=red,limit=1,sort=nearest]
Every mob targets the nearest enemy on the other team.
5. Show the winner
execute unless entity @e[tag=red] if entity @e[tag=blue] run title @a title {"text":"Blue wins!","color":"blue"}
execute unless entity @e[tag=blue] if entity @e[tag=red] run title @a title {"text":"Red wins!","color":"red"}
6. Natural enemies
- Iron golem and zombies: golems attack hostile mobs on their own (golem commands).
- Wolves and skeletons: wolves hunt skeletons.
- Axolotls and drowned: axolotls attack drowned underwater.
Troubleshooting
- Mobs stop fighting: run step 3 again if they lose track.
- Mobs vanish: hostile mobs despawn on Peaceful.
- Bedrock: write
/damage @e[tag=red,c=1] 1 entity_attack entity @e[tag=blue,c=1]; some mobs may not fight back.
Check your command
The Command Error Doctor checks common syntax mistakes in your browser.