2

I am working on a datapack with custom items, one of which summons aggressive wolves to fight for the player. The summoning works without problems but I cannot get the wolves to be aggressive towards enemies.

The function I am using to set aggro is as foll

execute as @e[tag=hunt] run data modify entity @s AngryAt set from entity @e[type=!wolf,type=!player,sort=nearest,distance=..50,limit=1] UUID

This command works fine when run from a commandblock ingame but does not work when run from a function. I should note that the function file itself runs fine (i.e., substituting the command with something like 'say doot' works fine) so it is not a tick issue.

Does anyone know how to fix this?

1 Answer 1

2

datapacks run commands without a position while command blocks use their block's position as reference.

Try adding at @s right after the at @e[tag=hunt]. That way the rest of the command should work. You can also shorten it a bit using @n.

Here is the full command:

execute as @e[tag=hunt] at @s run data modify entity @s AngryAt set from entity @n[type=!wolf,type=!player,distance=..50] UUID
1
  • Brilliant! This was the fix I was looking for Commented Oct 6 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.