1
How to detect a player name written on a book
hi i would like to know how to detect if a player name is written on a book
so like if i type in player 556 in the book how would you make that player be detected
so like if i type in player 556 in the book how would you make that player be detected
Create an account or sign in to comment.
3
1
Regardless of the strings being inside titles or sentences, strings are locked in the snbt and splitting it up is impossible in minecraft without the use of a complicated datapack that parses strings for you.
https://github.com/McTsts/Minecraft-String-Utilities
You then need to detect if characters of the string matches a name. Differentiating between normal text and the body oaragraph especially when you're not looking in the author section is borderline impossible.
This would be the case if you're not looking for a specific player in the author or you're looking for a player name embedded in the book pages with other words around it
https://github.com/McTsts/Minecraft-String-Utilities
You then need to detect if characters of the string matches a name. Differentiating between normal text and the body oaragraph especially when you're not looking in the author section is borderline impossible.
This would be the case if you're not looking for a specific player in the author or you're looking for a player name embedded in the book pages with other words around it
1
Two extra things needed to answer this question:
- Are you trying to detect when the player name is on the title of a book or the description of the book?
- Where are you trying to detect this book? Anywhere in the player inventory, only their selected slot, or a lectern?
This command gives an output if the item the player is holding is a written book with a certain title (I used "Steve" as the player)
/execute if entity @s[nbt={SelectedItem:{id:"minecraft:written_book",tag:{title:"Steve"}}}] run say Steve is the title of this book.
This command gives an output if the item the player is holding is a written book with the name of a player is written on any page of the book (It does have to be the ONLY thing on that page, though)
/execute if entity @s[nbt={SelectedItem:{id:"minecraft:written_book",tag:{pages:['{"text":"Steve"}']}}}] run say Steve is written in this book.
- Are you trying to detect when the player name is on the title of a book or the description of the book?
- Where are you trying to detect this book? Anywhere in the player inventory, only their selected slot, or a lectern?
This command gives an output if the item the player is holding is a written book with a certain title (I used "Steve" as the player)
/execute if entity @s[nbt={SelectedItem:{id:"minecraft:written_book",tag:{title:"Steve"}}}] run say Steve is the title of this book.
This command gives an output if the item the player is holding is a written book with the name of a player is written on any page of the book (It does have to be the ONLY thing on that page, though)
/execute if entity @s[nbt={SelectedItem:{id:"minecraft:written_book",tag:{pages:['{"text":"Steve"}']}}}] run say Steve is written in this book.
1
when you like when you open the book and write the person name in the pages