TransWikia.com

Changing NBT of an item in a container in 1.17

Arqade Asked on August 14, 2021

I’m looking to add nbt to an item that’s inside a dropper. For example: there’s a wooden sword in the middle slot. First you add +10 Damage and +1 Attack speed to it. Then you add Fire Aspect II on it. And last you add a tag "Level3" and lore saying "Wildfire" to it.

I haven’t done this before so I’m going to need a lot of explanation.

I had a question a lot like this one, but it’s not for 1.17 and I can’t get it to work.

One Answer

This would require a lot of NBT modification. Let's look at what the completed NBT of your item should look like:

{
  AttributeModifiers: [
    {
      AttributeName: "generic.attack_damage",
      Slot: "mainhand",
      Operation: 0,
      Amount: 10.0d,
      UUID: [I;382757,9285892,28488284,19948385]
    },
    {
      AttributeName: "generic.attack_damage",
      Slot: "mainhand",
      Operation: 0,
      Amount: 10.0d,
      UUID: [I;382757,9285892,28488284,19948387]
    }
  ],
  Enchantments: [
    {id: "minecraft:fire_aspect", lvl: 2}
  ],
  display: {
    Lore: ['"Wildfire"']
  },
  Level3: 1b
}

You can modify the data of an item in the dropper using the following command:

data modify block ~ ~ ~ Items[{Slot:4b}].tag merge value …

From there, insert the NBT data I placed above.

Correct answer by ExpertCoder14 on August 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP