mojira.dev
MC-135247

Phantom attack damage attribute cannot be modified using the /data command

The bug

When attempting to modify a phantom's attributes with the /data command, changes do not take place. Other functions of the /data command work fine, such as changing its current health, size, etc. but attributes such as attack damage and follow range are not affected.

How to reproduce

  1. Summon a phantom

  2. Run the command (The base modifier can be any number. It makes no difference): 

    /data merge entity @e[type=minecraft:phantom,limit=1] {Attributes:[{Name:generic.attackDamage,Base:0}]}
  3. The server will say the mob has been modified, but checking using the following command reveals that no change has occurred:

    /data get entity @e[type=minecraft:phantom,limit=1]

The commands used above function correctly for all other mobs I have tested.

Code analysis

From 18w31a's source:

Method ang.l() will directly set the phantom's generic.attackDamage to a hard-coded 6, plus the value from their Size tag, which overrides whatever Base was previously specified. This method is called when the entity has its data set from NBT (whether it's via command or via chunk loading).

Linked issues

Comments 7

Did you try to put the attribute name in quotes?

/data merge entity @e[type=minecraft:phantom,limit=1] {Attributes:[{Name:"generic.attackDamage",Base:0}]}

Can confirm for 18w30b. Using quotes did not help.

@kumasasa The command functions properly when used on all other mobs I have tested. Adding quotes did not resolve the issue.

Confirmed for 18w32a

Confirmed for 18w33a

Confirmed for 1.13.1-pre1

Fixed in 19w08a. However, if the phantom's size is not 0, then the attribute does still reset on reloading the world (I've created MC-181823 for that).

Note that I could only reproduce in 1.13 and 19w07a with the generic.attackDamage attribute; generic.followRange did not get reset at all. This is consistent with my understanding of the relevant code.

Skylar Rose

(Unassigned)

Confirmed

(Unassigned)

Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 18w32a, Minecraft 18w33a, Minecraft 1.13.1-pre1, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 19w03b, Minecraft 19w03c

Minecraft 19w08a

Retrieved