#Change CustomName color without changing words

1 messages · Page 1 of 1 (latest)

abstract holly
#

I have an item display entity and I would like to change its custom name color without changing the actual words in the name 1.21

spark boltBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

uncut bison
#

Not sure if i understand you correctly, but i think you can just use data merge entity @e[type=item_display] {CustomName:{"color":"dark_aqua"}}

abstract holly
#

It does not change

uncut bison
#

I can't test rn, what does /data get do?

abstract holly
faint wind
#

Which version are you on?

#

Ah 1.21

#

Yeah you can't directly do that then

#

Probably what you'll have to do is copy the name to an item, then use an item modifier to set the colour, then copy it back

abstract holly
faint wind
#

You can essentially copy the existing name while changing the colour. Here's an example from a datapack I made a while ago:

{
  "function": "set_name",
  "entity": "this",
  "target": "custom_name",
  "name": {
    "color": "aqua",
    "nbt": "SelectedItem.components.minecraft:custom_name",
    "entity": "@s",
    "interpret": true
  }
}
#

Basically, it copies the previous custom name but with a new coluor (aqua in this case, but it can be whatever)

abstract holly
rotund gyro
#

it's all a single step. It copies the name with a different color from itself to itself.

abstract holly
rotund gyro
#

item displays have an item inside them

abstract holly
#

So item modify entity @s ??? Namespace:change_name

#

@rotund gyro

rotund gyro
#

content

#

item frames, item displays, and all those things use the content slot

abstract holly
rotund gyro
#

What did you check in mcstacker?

#

there is no place on mcstacker where you would use/check that

#

if you use the item command in mc it should even suggest that as an option

abstract holly
#

it shows up in-game, tysm!

spark boltBOT
#
Question Closed

Your question, #1387310364458225695 (Change CustomName color without changing words), was resolved!

Original Message

#1387310364458225695 message

Duration open

2d2m

abstract holly
#
  "function": "set_name",
  "entity": "this",
  "target": "custom_name",
  "name": {
    "color": "green",
    "nbt": "SelectedItem.components.minecraft:custom_name",
    "entity": "@s",
    "interpret": true
  }
}```
#

Am I doing something wrong?

#

It's still aqua

abstract holly
#

It is the item display itself that has the name "Water"

rotund gyro
#

Yeah, you only modified the name in the item. The item modifier does copy the name that it modifies to itself but you still have to copy it over to the entity.

abstract holly
#

data modify entity @s CustomName set from entity @s Item.components."minecraft:custom_name"

rotund gyro
#

yes

abstract holly
#

I'm not sure what is different, but now it does this

#
  "function": "set_name",
  "entity": "this",
  "target": "custom_name",
  "name": {
    "color": "green",
    "nbt": "SelectedItem.components.minecraft:custom_name",
    "entity": "@s",
    "interpret": true
  }
}```
#

/execute as @n[type=minecraft:item_display] run data modify entity @s CustomName set from entity @s Item.components."minecraft:custom_name"

#

And when I run this ^ command it does nothing

faint wind
#

Ah if you're changing the contents rather than the mainhand of an entity, you need to change the item modifier slightly

#

Instead of SelectedItem.components, it needs to be item.components. That will copy the name from the item held by the item display

abstract holly
#

It does not work 😦

spark boltBOT
# spark bolt <@&1201956957406109788>

<@&1166082198152159386> <@&1202694677766348840>

🙇 Helpers Arise!

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

faint wind
#

Oh well if there's no name in the first place, then yeah it can't copy the name

#

You need to copy the entity name to the item name first

#

Actually you just need to modify the item modifier a bit again. Replace item.components.minecraft:custom_name with CustomName

abstract holly
#

After some attempts, I realised that it is getting a color without a custom name

#

So its not copying the custom name of the item display

abstract holly
#

I still can't get it to work

#

Someone help pls

faint wind
#

Can you share the code you currently have?

faint wind
#

Looks like you're missing "interpret": true in your item modifier. Not sure if that's what's causing the issue

#

I'll try to test today on my computer to see if I can get it working

abstract holly
#

What does interpret do?

faint wind
#

The custom name looks something like this: {"text": "Water", "color": "green"}. Interpret basically means instead of reading that string as it is, it tries to understand what it means (in this case the text is "Water" and the colour is green). Then it can properly apply transformations without breaking the existing data (so the colour changes to aqua but the text stays as "Water")

abstract holly
#

It unfortunately still has no effect

faint wind
#

Yeah I couldn't get it to work. Maybe that code is from a previous version

#

I'm not sure if there's another way to do it

abstract holly
#

Ok, thanks for your time and effort!

spark boltBOT
#
Question Closed

Your question, #1387310364458225695 (Change CustomName color without changing words), was resolved!

Original Message

#1387310364458225695 message

Duration open

5d15h37m