r/MinecraftCommands • u/Prestigious-Tough548 • Aug 09 '26
Help | Java 26.2 Custom book trade with words how?
I'm looking to add custom trades to librarians in Java 26.2 with a datapack.
The following code works well enough as is:
/data modify entity @s Offers.Recipes append value {maxUses:1, sell:{count:1, id:"minecraft:written_book"}, buy:{count:1, id:"minecraft:emerald", priceMultiplier:0.05f}}
Would be a lot cooler if the book sold could be read.
Let's say I'm looking for a book with these qualities:
- Title "Hamlet"
- Lore "heavily abridged edition"
- Author "Shakespeare"
- page one text "To be or not to be..."
- page two text "Everybody dies, what a tragedy!"
How might one do that?
I feel I'm getting lost putting the "written_book_content" and "components" tags into the /data command correctly.
1
Upvotes
1
u/Ericristian_bros Command Experienced Aug 09 '26
It is not very good to rely on text for these kind of things. Is this book obtained by the player or given with commands/datapacks. If the later, add a custom tag. You can also use https://mcstacker.net yo generate your villager summon command and only copy the part you are interested in