Giving Books to New Players
Patchouli does not have native functionality to give books to players as they join. However, this functionality is easily replicated using vanilla advancements.
What we will do is to provide a hidden advancement that triggers for a player immediately whose reward is the book. Advancement rewards are one-time-only, so unless the advancement is revoked from the player, this should happen once, immediately when the player joins the world for the first time.
Please check the vanilla wiki for details.
Below is a brief example:
Replace yourbooknamespace
with the namespace part of your book ID (see Getting
Started) for information about your book ID.
{
"criteria": {
"tick": {
"trigger": "minecraft:tick"
}
},
"rewards": {
"loot": [
"yourbooknamespace:grant_book_on_first_join"
]
}
}
{
"type": "advancement_reward",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "item",
"name": "patchouli:guide_book",
"functions": [
{
"function": "set_nbt",
"tag": "{\"patchouli:book\": \"YOURBOOKIDHERE\"}"
}
]
}
]
}
]
}
Fill in your book ID where it says to. Modders: if you have a custom book item, obviously replace the item id and delete the function.