Hello all. I'm not sure if this is the right place to post this but I'm also not sure where else to, so sorry if I'm in the wrong place :)
I'm trying to print some block data to the chat with /tell, /say, or /tellraw, but I can't figure out how to get the data from one command to the other.
The exact scenario is that I have a lectern with a book on it, and I want to print whatever text is on the book's first page to the chat.
I can get the data with
but I can't figure out how to get the result to print out to the chat. Any help would be appreciated :(
I'm trying to print some block data to the chat with /tell, /say, or /tellraw, but I can't figure out how to get the data from one command to the other.
The exact scenario is that I have a lectern with a book on it, and I want to print whatever text is on the book's first page to the chat.
I can get the data with
/data get block ~1 ~ ~ Book.tag.pages[0]
but I can't figure out how to get the result to print out to the chat. Any help would be appreciated :(
Create an account or sign in to comment.
2
2
You can get blockdata directly in the /tellraw command using a nbt component:
tellraw @a {"nbt":"Book.tag.pages[0]", "block":"~1 ~ ~"}
If you want to add some text before or after the text, you can either use a second /tellraw like this:
tellraw @a {"text":"text from page 1:"}
tellraw @a {"nbt":"Book.tag.pages[0]", "block":"~1 ~ ~"}
Or add them together like this:
tellraw @a [{"text":"text from page 1:\n"}, {"nbt":"Book.tag.pages[0]", "block":"~1 ~ ~"}]
NOTE: If there is no lectern at the given location, the tellraw command will work and just return an empty string for that part.
NOTE #2: For some reason there is some weird char in front of the 0, if I copy and paste the commands. If that also happens to you, you'd have to remove that for the command to work.
tellraw @a {"nbt":"Book.tag.pages[0]", "block":"~1 ~ ~"}
If you want to add some text before or after the text, you can either use a second /tellraw like this:
tellraw @a {"text":"text from page 1:"}
tellraw @a {"nbt":"Book.tag.pages[0]", "block":"~1 ~ ~"}
Or add them together like this:
tellraw @a [{"text":"text from page 1:\n"}, {"nbt":"Book.tag.pages[0]", "block":"~1 ~ ~"}]
NOTE: If there is no lectern at the given location, the tellraw command will work and just return an empty string for that part.
NOTE #2: For some reason there is some weird char in front of the 0, if I copy and paste the commands. If that also happens to you, you'd have to remove that for the command to work.
2
thank you so much!