Reproduction
Default modifiers refers to attributes on default items. These modifiers can be detected based on their modifier data, such as name, value, or UUID.
In 1.8.8, the following can be used and will correctly detect a player holding any of the default tools (pickaxes, axes, etc). Default tools have a hidden modifier with the name "Tool modifier", which is then applied to the player's attributes:
/testfor @a {Attributes:[{Modifiers:[{Name:"Tool modifier"}]}]}
However, in 15w47a, attempting to use the same command on a clock will not properly detect the modifier. The modifier is only detected for a single tick, which is when the player deselects the tool, and not when the player is ever holding it. The same occurs for any custom modifiers as well.
Cause
Using MCP for 1.10, in method net.minecraft.entity.EntityLivingBase.writeEntityToNBT()
, the attribute modifiers from the entity's equipment are being removed before writing to the Attributes
NBT list, essentially meaning that modifiers are never saved to NBT. I am not sure why this is done. Fixing this report involves removing the impeding lines:
...
//for (EntityEquipmentSlot entityequipmentslot : EntityEquipmentSlot.values())
//{
// ItemStack itemstack = this.getItemStackFromSlot(entityequipmentslot);
//
// if (itemstack != null)
// {
// this.getAttributeMap().removeAttributeModifiers(itemstack.getAttributeModifiers(entityequipmentslot));
// }
//}
compound.setTag("Attributes", SharedMonsterAttributes.writeBaseAttributeMapToNBT(this.getAttributeMap()));
//for (EntityEquipmentSlot entityequipmentslot1 : EntityEquipmentSlot.values())
//{
// ItemStack itemstack1 = this.getItemStackFromSlot(entityequipmentslot1);
//
// if (itemstack1 != null)
// {
// this.getAttributeMap().applyAttributeModifiers(itemstack1.getAttributeModifiers(entityequipmentslot1));
// }
//}
...
However, if the lines were added to fix a different bug, that bug may re-appear if it wasn't fixed elsewhere. Unfortunately I don't know if it was a fix for another bug, nor what bug that would be if so.
Can Confirm in 1.19.3 Release Candidate 3, function writeEntityToNBT is written with the incorrect order wiping the data erroneously.
The new command for the latest versions of Minecraft Java:
Command does not run with a default tool dropped to the ground or held by a player.