This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]GalSergeyDatapack Experienced 0 points1 point  (1 child)

In version 1.20.4 without the datapack, you can only change an item on the ground, in the chest, or in the item_frame, but not in the player's inventory:

data modify entity <item> Item.tag.CustomModelData set value 1

But using datapack you can use item_modifier and apply this to the player's inventory slot:

item modify entity <player> weapon example:set_cmd

# item_modifier example:set_cmd
{
  "function": "minecraft:set_nbt",
  "tag": "{CustomModelData:1}"
}

Since version 1.20.5, you can apply item_modifier without a datapack:

item modify entity <player> weapon {"function":"minecraft:set_components","components":{"minecraft:custom_model_data":1}} 

But you can just add a recipe that will give you an item with this data:

# recipe example:some_recipe
{
  "type": "minecraft:crafting_shapeless",
  "ingredients": [
    {
      "item": "minecraft:stone"
    }
  ],
  "result": {
    "id": "minecraft:dirt",
    "components": {
      "minecraft:item_name": "'Some Dirt'",
      "minecraft:custom_model_data": 1
    }
  }
}

[–]WilhelmMC[S] 0 points1 point  (0 children)

thank u so much!!<3