Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-92921

Delayed application/detection of attribute modifiers (default & custom)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 15w47a, Minecraft 15w47b, Minecraft 15w47c, Minecraft 15w49a, Minecraft 15w49b, Minecraft 15w50a, Minecraft 15w51a, Minecraft 15w51b, Minecraft 16w02a, Minecraft 16w03a, Minecraft 16w04a, Minecraft 16w05a, Minecraft 16w05b, Minecraft 16w06a, Minecraft 16w07a, Minecraft 16w07b, Minecraft 1.9 Pre-Release 1, Minecraft 1.9 Pre-Release 2, Minecraft 1.9 Pre-Release 3, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 2, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.3 Pre-Release 3, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 1.11.2, Minecraft 1.12 Pre-Release 6, Minecraft 1.12.2, Minecraft 1.13-pre1
    • Fix Version/s: None
    • Labels:
      None
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              skylinerw [Mod] Skylinerw
            • Votes:
              8 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                CHK:

                Potential Duplicates