Knowledge Book - ShaneBeee/SkBee GitHub Wiki
So you created some custom recipes, and you want a fun new way to unlock these recipes for players? Well you are just in luck then, because we can add those recipes to a Knowledge Book. When the player receives this book, they just need to right click it and the recipes will be unlocked, the player will also receive a toast message when the recipe is unlocked.
Here is the basic syntax:
add [(custom|(mc|minecraft))] [recipe[s]] [with id[s]] %strings% to %itemtype%
remove [(custom|(mc|minecraft)] [recipe[s]] [with id[s]] %strings% from %itemtype%
Let's break it down:
Add or remove:
This is simple. You can add recipes to a book, and you can remove them. Obviously a new book won't have recipes to remove, so we will need to add some first.
Custom or MC recipe:
[(custom|(mc|minecraft)]
Here we can decide if we are going to add 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:
The book:
to %itemtype%
This is the item you are adding recipes to. This will obviously need to be a knowledge book, any other item will just do nothing.
Let's put it all together:
command /book:
trigger:
set {_i} to a knowledge book named "&aServer Recipes"
set lore of {_i} to "&7Our server's recipes", " ", "&bRecipe:", "&7 - Cutting oak", "&7 - Cutting birch", "&7 - Cutting spruce", "&7 - Cutting jungle"
add custom recipe "cutting_oak" to {_i}
add custom recipe "cutting_birch" to {_i}
add custom recipe "cutting_spruce" to {_i}
add custom recipe "cutting_jungle" to {_i}
give player 1 of {_i}
I added some lore to the book for funnsies, just so the player knows which recipes are included.
Visual representation:
When the player right-clicks whilst holding the book it will be removed from their inventory and they will receive a toast message letting them know the recipes were unlocked