TransWikia.com

How to make a wolf angry at a nearby player

Arqade Asked by Hydra on April 28, 2021

I am in 1.14 and I want to summon in wolves that are angry. summon wolf ~ ~ ~ {Angry:1} Doesn’t work, since the wolf must have a specific player to be angry at, which is stored in UUID’s I believe. This behavior is unlike Zombie Pigmen, which when set angry become agro at all players. I thought about detecting if a player gets near a wolf, say within 10 blocks, that wolf automatically becomes hostile to that specific player. Is there a way to do this?

One Answer

Who a wolf is angry at is not saved in its NBT. I've created this bug report for it now: https://bugs.mojang.com/browse/MC-155036

But you can still do what you want to do, because wolves really don't like snowball fights.
Let's say the player who should be attacked has the tag "attackMe", just to have something to differentiate them. Then you can summon a snowball above the wolf and make that snowball pretend to have been thrown by that player:

execute at @e[type=wolf] run summon snowball ~ ~2 ~
execute at @e[type=wolf] run data modify entity @e[type=snowball,sort=nearest,limit=1] owner.L set from entity @p[tag=attackMe] UUIDLeast
execute at @e[type=wolf] run data modify entity @e[type=snowball,sort=nearest,limit=1] owner.M set from entity @p[tag=attackMe] UUIDMost

Of course you'll probably narrow the selector @e[type=wolf] further, currently this system makes every wolf in the loaded area angry at you.

Correct answer by Fabian Röling on April 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP