mojira.dev
MC-54584

Crash when creating an item with an AttributeModifier with an Operation of > 2

I was trying to figure out how to correctly do AttributeModifiers, but in the process I accidentally set Operation to 3, which isn't a valid Operation. Just having the item in my inventory caused the game to crash. I kept having to delete the item using NBTExplorer in order to load the world again without crashing. I eventually realized my mistake and set Operation to 1.

Here's the command I used:

/give @p beef 1 0 {AttributeModifiers:[{AttributeName:generic.attackDamage,Name:noDamage,Amount:-1d,Operation:3,UUIDMost:20l,UUIDLeast:10l}]}

Attachments

Comments 6

I don't think you can really work around a bug like this, because Minecraft will keep trying to calculate the base of the attribute, until it crashes itself. Unless they add a operation for operation numbers from 3-infinity to neglect this.
And, just interested, what's the "d" doing behind "-1" in the "Amount" tag?

@ Samuel Klumpers:

This can be worked around by checking if an item has an invalid Operation and delete the AtrributeModifier.

The "d" is a tag label. It has to be there in order for the tag to be created as a Double instead of an Int. The UUIDMost and UUIDLeast tags are also labeled, as "l" (Long); same goes for them. If those tags aren't labeled, they get created as Ints and the whole AttributeModifier doesn't work.

I never had any problems working around with Attributes without using "d"'s and "l"'s.

@ Samuel Klumpers

Hm. When I looked at my inventory data after first time it crashed (happened 4 times), those tags were Ints.

Also, someone on Reddit said it wasn't working for them; they didn't label the tags.

Is this still a concern in the current Minecraft version 14w30c or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Nope, it's fixed in 14w31a.

BoxFigs

(Unassigned)

Unconfirmed

AttributeModifiers, attribute, crash, item, modifier, operation

Minecraft 1.7.9

Minecraft 14w31a

Retrieved