2

For example, I am wearing a netherite chestplate with Protection IV and renamed to "Wing". I would like to replace the netherite chestplate that I am wearing with an elytra but it keeps the enchantment and name. So now I will be wearing an elytra that has Protection IV on it and also named as "Wing".

I was thinking about the /item command and its "item modifier" thingy that was added in 1.17, perhaps it can do the trick but I'm not sure how to do that exactly. Is it even possible?

2
  • 1
    It should be fairly easy to copy the NBT data from one item to another, although it's been so long since I looked at doing something like this that I can't give any implementation details. I have a feeling that you're going to have to create the elytra, transfer the data and then destroy the chestplate, and this probably can't happen when the elytra are in the player's inventory.
    – MBraedley
    Commented Jun 24, 2021 at 15:27
  • Is this using command blocks or a data pack w/ functions?
    – One 2 Many
    Commented Jun 24, 2021 at 18:13

1 Answer 1

2

Item modifiers are not for changing the type of an item. Instead, a loot table should be used that copies the item NBT from the old item.

Such a loot table would look like this:

{
  "type": "minecraft:generic",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:elytra",
          "functions": [
            {
              "function": "minecraft:copy_nbt",
              "source": "this",
              "ops": [
                {
                  "source": "Inventory[{Slot:102b}].tag",
                  "target": "{}",
                  "op": "merge"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

A command to do this would look like:

loot replace entity @s armor.chest 1 loot LOOT_TABLE_ID
1
  • It works perfectly! Thank you so much!
    – Bluecap MC
    Commented Jun 25, 2021 at 9:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .