mojira.dev
MC-188379

Attribute command doesn't work in mcfunction files

I tried adding the attribute command to my datapack and when I did, the MCFUNCTION file with the attribute command failed to load. I am loading this file using the minecraft:tick tag.

I found this by first testing if the file would load with the commands inside. After finding that it wouldn't load, I searched through the file and tried removing different elements based on the changes I made before testing. Once I removed the lines with the attribute commands, the file worked as intended (of course without the attribute changes i intended to add).

Attachments

Comments 3

Could you attach the datapack?

From the game log:

java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 7: Incorrect argument for command at position 48: ...elected4] <--[HERE]

You have two commands on a single line that need to be split up

team join Cleric @a[team=!Cleric,tag=Selected4] attribute @a[tag=!Done,tag=Selected1] minecraft:generic.max_health base set 22

team join Cleric @a[team=!Cleric,tag=Selected4]
attribute @a[tag=!Done,tag=Selected1] minecraft:generic.max_health base set 22

After fixing that:

java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 8: Only one entity is allowed, but the provided selector allows more than one at position 0: <--[HERE]

/attribute only allows a single target, you need to rewrite each of them like so:

attribute @a ...
execute as @a run attribute @s ...

From there, the pack is fine. In the future, please use a resource like /r/MinecraftCommands for datapack assistance, rather than the bug tracker. Thanks!

James Johnson

(Unassigned)

Unconfirmed

(Unassigned)

1.16 Pre-release 2

Retrieved