#Change CustomName color without changing words
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 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
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"}}
It does not change
I can't test rn, what does /data get do?
The full json with the text and color combined
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
How would I set the custom name color using an item modifier without changing the name?
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)
How would I copy it back?
it's all a single step. It copies the name with a different color from itself to itself.
But this is an item modifier, how would it work on a display
item displays have an item inside them
I'll practically check in mc, but content does not seem to appear on mcstacker
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
it shows up in-game, tysm!
Your question, #1387310364458225695 (Change CustomName color without changing words), was resolved!
#1387310364458225695 message
2d2m
"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
It is the item display itself that has the name "Water"
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.
Would something like this work?
data modify entity @s CustomName set from entity @s Item.components."minecraft:custom_name"
yes
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
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
It does not work 😦
<@&1166082198152159386> <@&1202694677766348840>
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)
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
That breaks it
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
Can you share the code you currently have?
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
What does interpret do?
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")
It unfortunately still has no effect
Any luck?
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
Ok, thanks for your time and effort!
Your question, #1387310364458225695 (Change CustomName color without changing words), was resolved!
#1387310364458225695 message
5d15h37m