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

Multiple functions in an item modifier cannot "see" each other's changes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 1.19.2
    • None
    • Confirmed
    • (Unassigned)

      The bug

      An item modifier that has multiple item functions to modify an item in your mainhand, cannot have the second function depend on the first. They behave as if their effects are buffered until all are finished.

      The only way I could get this to work is by splitting the two functions into separate modifier files, and running both with separate commands.

      How to reproduce

      Save the following item modifier:

      [{
          "function": "minecraft:set_nbt",
          "tag": "{PageContent: '\"Hello World\"'}"
      },
      {
          "function": "minecraft:copy_nbt",
          "source": "this",
          "ops": [
              {
                  "source": "SelectedItem.tag.PageContent",
                  "target": "pages",
                  "op": "append"
              }
          ]
      }]
      

      And run these commands:

      item replace entity @p weapon.mainhand with minecraft:written_book{pages:[], PageContent:"default"}
      item modify entity @p weapon.mainhand namespace:item_modifier
      

      (substituting namespace:item_modifier for the appropriate location of the file)
      Notice that the resulting book contains the text "default" when you open it.

      Expected behaviour:

      When the first item function modifies the value of the custom NBT field, I was expecting the second item function to be able to copy the resulting value into the page list of the book.

      Actual behaviour:

      What happens is that the second item function copies the default text set by the parent command, instead of the value that the first item function changed it to.

            Unassigned Unassigned
            Jack_McKalling [Helper] Jack McKalling
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: