r/MinecraftCommands • • Feb 09 '23

Tutorial | Java [Java 23w06a] The new damage command can be used to make a mob to attack other entity (RIP Snowball trick)

466 Upvotes

19 comments sorted by

35

u/alderski Feb 09 '23
/damage @e[type=minecraft:iron_golem,sort=nearest,limit=1] 0.0 minecraft:mob_attack by @e[type=minecraft:sheep,sort=nearest,limit=1]

or in other words

/damage <single_attacker_mob_selector> 0.0 minecraft:mob_attack by <single_target_entity_selector>

1

u/meleshik Feb 09 '23

is the sort or limit needed or was this just for experiment, just curios

8

u/alderski Feb 09 '23

You must pass single entity selectors to this command, just like when you do data get entity etc

6

u/timen_lover Feb 09 '23

You could already do this using the AngryAt tag

23

u/alderski Feb 09 '23

Only some neutral mobs have this tag. You couldn’t do this for hostile mobs for example without doing the snowball trick.

4

u/timen_lover Feb 09 '23

Didn’t know, thanks

2

u/[deleted] Feb 09 '23

This is much more streamlined with nigh-universal application, though. =)

1

u/timen_lover Feb 10 '23

Since you’re doing damage I’d say it’s pretty ugly. At least personally I couldn’t put it on my server without camouflaging the damage effects. If the AngryAt tag was present in all mobs and wasn’t buggy, it would be a much nicer way.

66

u/GanoXD Knows a lot Feb 09 '23

The fact that you didnt put two iron golems up against each other is a crime.

10

u/Bylakuppe77 Feb 09 '23

The mob wars, begun they have...

3

u/XTT9 Feb 10 '23

Execute datapack 66

9

u/[deleted] Feb 09 '23

That insane I Always wanted to make a War Arena

7

u/[deleted] Feb 10 '23

I’ve been waiting for this, finally! I can tag my spells as player damage so mobs will become aggressive and drop xp

5

u/MrRainbow07 Java datapack-er and command-er Feb 09 '23

Is there a way to make them not flash red?

3

u/non-taken-name Feb 09 '23

I doubt it without a resource pack

2

u/Darkiceflame Data Pack Engineer Feb 11 '23

I doubt it even with a resource pack. Unless it uses optifine, maybe.

2

u/HeilUsona Feb 10 '23

I never thought I'd see a golem kill a villager