TransWikia.com

Why is /data modify not editing signs correctly?

Arqade Asked on August 13, 2021

I have the following commands:

data modify block -107 78 -525 Text1 set from entity @e[limit=1,tag=test] CustomName
data modify block -107 78 -525 Text2 set from entity @e[limit=1,tag=test] Health
data modify block -107 78 -525 Text3 set from entity @e[limit=1,tag=test] Attributes[0].Base
data modify block -107 78 -525 Text4 set from entity @e[limit=1,tag=test] HurtTime

Those are just examples but for some reason, only the CustomName works. None of the other commands work, although I have no idea why.

I’m playing on a server and I was using a pig to test this.

One Answer

As you may or may not know, the text tags of signs are JSON text tags, meaning they have to be entered in a certain format. The only reason the custom name works is because it is also a JSON text tag. The others are not JSON text tags, so they can't be written directly to the sign text tags.

The only alternative is to use the raw JSON text nbt element which tells the JSON text reader to check for NBT and render it. Try this:

data modify block -107 78 -525 Text2 set value '{"nbt":"Health","entity":"@e[limit=1,tag=test]"}'
data modify block -107 78 -525 Text3 set value '{"nbt":"Attributes[0].Base","entity":"@e[limit=1,tag=test]"}'
data modify block -107 78 -525 Text4 set value '{"nbt":"HurtTime","entity":"@e[limit=1,tag=test]"}'

Note that in order to correctly render the nbt element, the system has to convert them into text elements instead with the correct value. This is called component resolution. This resolution can only happen with signs, and some select other areas.

Answered by ExpertCoder14 on August 13, 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