const tome = Item.of('akashictome:tome', '{"akashictome:data":{alexscaves:{Count:1b,id:"alexscaves:cave_book"},botania:{Count:1b,id:"botania:lexicon"},hexcasting:{Count:1b,id:"patchouli:guide_book",tag:{"patchouli:book":"hexcasting:thehexbook"}},patchouli:{Count:1b,id:"patchouli:guide_book",tag:{"patchouli:book":"patchouli:pwb_guide"}}}}')

ServerEvents.recipes(recipes => {
	recipes.shapeless(
        tome,
        [ 'minecraft:stick' ]
    )
})

const givenTomeAdvancement = "pwb:guide"

LootJS.modifiers(event => {
    event
        .addLootTypeModifier(LootType.CHEST)
        .playerPredicate(player => {
            let advancement = player.server.getAdvancement(givenTomeAdvancement).advancement
            let hasNotFound = !player.advancements.getOrStartProgress(advancement).done

            if(hasNotFound) {
                player.unlockAdvancement(givenTomeAdvancement)
            }

            return hasNotFound
        })
        .addLoot(tome)
        .addLoot('origins:orb_of_origin')
})