TransWikia.com

Give a custom item_frame item a special ID I can later use to target with /data

Arqade Asked by ch4rl1e97 on August 2, 2021

I’m trying to /minecraft:give myself an item_frame item that has some sort of special id/name that I can later use /data (or /execute then data) on in order to switch specifically those item frames to being invisible (or visible).

That is to say, I should later on be able to run a command, and that specific set of item frames should react to it, leaving all "normal" frames intact. I’m doing this mostly because it can be difficult to tract down accidentally placed invisible item frames.

I can’t find a way to get the placed Item Frame entity to retain the name of the item, nor how to add such data to the item that will be passed along.

My latest effort was this:
/minecraft:give @s minecraft:item_frame{display:{Name:""Invisible Frame""},EntityTag:{Invisible:1b,CustomName:{"text":"InvisibleFrame"},CustomNameVisible:0b}} 1

Only the Invisible:1b is passed to the item frame entity, the rest doesn’t make it through. i have checked this with /data get.

What to do from here? And once I do have a custom name on it, how can I pick up that custom name with a specifier in @e[]?

One Answer

Your current data:

{
  EntityTag: {
    Invisible: 1b,
    CustomName: {
      text: "InvisibleFrame"
    }
  }
}

The correct data:

{
  EntityTag: {
    Invisible: 1b,
    CustomName: '{"text": "InvisibleFrame"}'
  }
}

The JSON text component is a String tag inside of NBT containing JSON. You therefore need to surround it in apostrophes.

In addition, you should never target an entity by its name. Give it a tag instead:

{
  EntityTag: {
    Invisible: 1b,
    CustomName: '{"text": "InvisibleFrame"}',
    Tags: ["invis"]
  }
}

@e[type=minecraft:item_frame,tag=invis]

Correct answer by ExpertCoder14 on August 2, 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