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

Datapack Item Modifiers cannot modify existing Components

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.21
    • None
    • Unconfirmed
    • (Unassigned)

      When switching over to the component system, the item modifier "set_nbt" function was replaced with "set_components" and "set_custom_data". However, some functionality was lost here because setting a component replaces the whole component instead of a specific field, and set_custom_data only works on the custom_data component.

      This means that an item modifier cannot selectively modify only some fields of a non-custom component, so a lot of useful behavior is lost. Consider an item modifier that alters any spawn egg the player is holding to spawn the mob on the player's team. Before 1.20.5, you could use the modifier:

      [
        {
          "function": "minecraft:set_nbt",
          "tag": "{EntityTag:{Team:\"team_1\"}}",
          "conditions": [
            {
              "condition": "minecraft:entity_properties",
              "entity": "this",
              "predicate": {
                "team": "team_1"
              }
            }
          ]
        }
      ]
      

      However, a modifier like this is impossible to make in 1.20.5+ because both the team and the mob id are fields in the entity_data component, so the team can't be changed without also changing the entity that is spawned.

      In order to fully replace the "set_nbt" function, either the functionality of "set_components" has to be extended, or another function could be added that is similar to "set_custom_data", but for any component.

            Unassigned Unassigned
            WorstPacifist Leo Epperson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: