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

Loot tables can no longer copy block entity data into the dropped item

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • None
    • 1.20.5, 1.20.6 Release Candidate 1, 1.21
    • Windows 10, JRE 21
    • Confirmed
    • Data Packs, Loot tables

      Previous to 1.20.5, you could copy nbt from the mined block to the dropped block, so I could for instance, make a monster spawner drop a mosnter spawner item with the nbt that specified the mobs inside the spawner, so when you placed it in creative mode, it would still have those mobs inside. The loot table would look like this:

      {
        "pools": [
          {
            "rolls": 1,
            "entries": [
              {
                "type": "minecraft:item",
                "name": "minecraft:spawner",
                "functions": [
                  {
                    "function": "minecraft:copy_nbt",
                    "source": "block_entity",
                    "ops": [
                      {
                        "source": "{}",
                        "target": "BlockEntityTag",
                        "op": "merge"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
      

      In 1.20.5, the nbt needs to be copied to the Item.components path for the spawner item to work as intended in my example. The new item modifier that replaced "minecraft:copy_nbt" is "minecraft:copy_custom_data", but this item modifier copies the provided nbt to the item in the following path: Item.components."minecraft:custom_data". So now it is not possible to do what I previously described with this item modifier.

      The new "minecraft:copy_component" item modifier allows you to copy item components from the mined entity block to the Item.components path of the item, but that won't work either as entity blocks don't have item components, at least not the monster spawner entity block with an entity inside, as one can see by doing /data get block <coords of the spawner>, so there's nothing to include or to copy.

      I have not found a way to do what I could prevously do.

      I have attached 3 images of me mining a spawner in 1.20.4 with a datapack that contains the loot table I wrote at the start of this post. The datapack is also attached here. That dropped spawner item, when put in creative, it will still contain the mob inside (in this case, a zombie). The other 3 images are me mining a spawner in 1.20.5 with a datapack containing a loot table using item modifier "minecraft:copy_custom_data". The datapack is also attached. As you can see in the images, the nbt gets copied to Item.components."minecraft:custom_data", the tooltip doesn't say that it contains a zombie, and when put in creative mode, the spawner will be empty

        1. 2024-04-27_16.33.23.png
          2024-04-27_16.33.23.png
          411 kB
        2. 2024-04-27_16.33.41.png
          2024-04-27_16.33.41.png
          313 kB
        3. 2024-04-27_16.33.13.png
          2024-04-27_16.33.13.png
          539 kB
        4. spawner_1_20_4.zip
          1 kB
        5. 2024-04-27_16.44.08.png
          2024-04-27_16.44.08.png
          289 kB
        6. 2024-04-27_16.43.56.png
          2024-04-27_16.43.56.png
          524 kB
        7. 2024-04-27_16.44.21.png
          2024-04-27_16.44.21.png
          426 kB
        8. spawner_1_20_5.zip
          1 kB
        9. spawner_1_21.zip
          0.5 kB

            Unassigned Unassigned
            katanya04 katanya04
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: