Locking Unlocking Recipes - ShaneBeee/SkBee GitHub Wiki

So you created a bunch of new recipes, now you need to unlock the recipes for the players, or maybe you want to lock them back up, we can do just that.
Vanilla Minecraft recipes will automatically unlock as players finish certain tasks, custom recipes though, we will need to unlock them ourself.

Here are the syntaxes:

(discover|unlock) [(custom|(mc|minecraft)] recipe[s] [with id[s]] %strings% for %players% 
(undiscover|lock) [(custom|(mc|minecraft)] recipe[s] [with id[s]] %strings% for %players%

Let's break it down:

Lock/Unlock:

If a recipe is locked a player will not see it in their crafting recipe book. The player will still be able to craft the item, they just won't see the recipe.
If you don't want your player's to be able to craft recipes that are locked, you can enable the limited crafting game rule on your server with /gamerule doLimitedCrafting true

Custom or MC recipe:

[(custom|(mc|minecraft)]

Here we can decide if we are going to lock/unlock a custom recipe (one which you created) or a vanilla Minecraft recipe.

IDs for recipes:

recipe[s] [with id[s]] %strings%

Each recipe on the server has an ID (namespace key). When you create a recipe you also create an ID for that new recipe. Vanilla Minecraft recipes also have IDs. There are a few ways you can find these, 1 easy way is to run the command /minecraft:recipe player_name and you will see all the available recipe names. Minecraft recipes will start with minecraft: and all custom recipes will start with skrecipe: (keep in mind, you will not need to put "minecraft:" or "skrecipe:" into this syntax. Here are some visual representations to show of IDs in the client:
Minecraft Recipes:

Custom Recipes:

For whom:

for %players% 

Who are we unlocking recipes for? You can use a specific player or all players

Let's put it all together

Once we created recipes, we now need to unlock them for players. We can do this in any event, here are some examples

# These recipes will be unlocked when the player joins the server
# If the recipe is already unlocked these will be ignored
on join:
    unlock recipe "cutting_oak" for player
    unlock recipe "cutting_birch" for player
    unlock recipe "cutting_spruce" for player
    unlock recipe "cutting_jungle" for player

# In this example a recipe will unlock for the player when they pick up certain items
on player pickup:
    if event-item is a diamond:
        unlock recipe "strong_sword" for player
    else if event-item is an emerald:
        unlock recipe "emerald_sword" for player

Visual representation:

You will see that when a player picks up the diamond, the recipe will be unlocked and they will receive a toast notification letting them know the recipe was unlocked.