Recipe Manager (1.13.2+ ONLY)

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

ShaneBee

Supporter +
Addon Developer
Sep 7, 2017
2,247
241
73
Vancouver, Canada
I just wanted to share some custom recipe effects I created.
These will ONLY work on Spigot/Paper 1.13.2+ (Due to the custom ingredient methods added to the BukkitAPI in 1.13.x)

All of these require Skript-Mirror to work. As per usual, place these custom effects at the top of the script you will be using it in, or place it in another script that loads before the one you are using (spoiler alert: scripts load in alphabetical order)

Note: You may be looking thru these and wondering "Hey Shane, why do I need an ID for my recipe?" Well, I am glad you asked. I did this for a few reasons.
1) When the recipe is registered it is given an ID. You can use this ID for unlocking recipes for players, also you can run them in the console, like:
code_language.skript:
/recipe give ShaneBee skript:emerald_sword
The pattern will always start with 'skript:' followed by the ID you put. (This is because the recipes are registered per plugin, and in this case, to Skript)
2) I originally created a randomized ID system so you wouldn't have to worry about it. The problem with that was, each time your server loads it technically creates a NEW recipe (and disposes of the old ones), therefore a player would have to unlock the recipe every time the server restarted.

Custom Shaped Recipe - This includes a custom item result (item with name, lore, enchantments, etc) as well as custom ingredients.
code_language.skript:
import:
    org.bukkit.Bukkit
    org.bukkit.inventory.ShapedRecipe
    org.bukkit.inventory.RecipeChoice$ExactChoice
    org.bukkit.NamespacedKey

#! Register shaped recipe with custom ingredients !#
effect register [new] shaped recipe for %item% using %items% with id %string%:
    trigger:
        set {_ing::*} to expressions-2
        loop 9 times:
            if {_ing::%loop-number%} is not set:
                set {_ing::%loop-number%} to air
        #! ID + NamespacedKey !#
        set {_id} to expression-3
        replace all " " with "_" in {_id}
        set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_id})
        #! Create Recipe !#
        set {_recipe} to new ShapedRecipe({_key}, expression-1)
        loop 9 times:
            set {_choices::%loop-number%} to new ExactChoice({_ing::%loop-number%})
        #! Ingredients !#
        {_recipe}.shape("123","456","789")
        loop {_ing::*}:
            {_recipe}.setIngredient(loop-index, {_choices::%loop-index%})
        Bukkit.addRecipe({_recipe})

Custom Shapeless Recipe - This includes a custom item result (item with name, lore, enchantments, etc) but with only vanilla ingredients (As of right now the API does not support custom ingredients on shapeless recipes. If you require custom ingredients, use the shaped recipes)
code_language.skript:
import:
    org.bukkit.Bukkit
    org.bukkit.inventory.ShapelessRecipe
    org.bukkit.inventory.RecipeChoice$ExactChoice
    org.bukkit.NamespacedKey

#! Register shapeless recipe, no custom ingredients !#
effect register [new] shapeless recipe for %item% using %items% with id %string%:
    trigger:
        set {_ing::*} to expressions-2
        set {_id} to expression-3
        replace all " " with "_" in {_id}
        set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_id})
        set {_recipe} to new ShapelessRecipe({_key}, expression-1)
        loop {_ing::*}:
            {_recipe}.addIngredient(new ExactChoice(loop-value))
        Bukkit.addRecipe({_recipe})

Custom Furnace Recipe - This includes a custom item result (item with name, lore, enchantments, etc) as well as a custom ingredient. It also includes an optional ability to set the experience a player gains when smelting this item (default=0) and cook time (in ticks, default=200)
code_language.skript:
import:
    org.bukkit.Bukkit
    org.bukkit.inventory.FurnaceRecipe
    org.bukkit.inventory.RecipeChoice$ExactChoice
    org.bukkit.NamespacedKey

#! Regsiter furnace recipe (not sure yet about custom ingredients) !#
effect register [new] furnace recipe for %item% using %item% with id %string%[([ and] with|,) experience %integer%][([ and] with|,) cook[ ]time %integer%]:
    trigger:
        set {_result} to expression-1
        set {_ing} to expression-2
        set {_id} to expression-3
        set {_exp} to expression-4 ? 0
        set {_cookTime} to expression-5 ? 200
        set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript") and {_id})
        if name of {_ing} is set:
            set {_recipe} to new FurnaceRecipe({_key}, {_result}, new ExactChoice({_ing}), {_exp} and {_cookTime})
        else:
            set {_recipe} to new FurnaceRecipe({_key}, {_result}, {_ing}.getType(), {_exp} and {_cookTime})
        Bukkit.addRecipe({_recipe})

When recipes are added to the server, they are not automatically unlocked for players. For some silly reason, unlike other items in the recipe book, players cannot seem to unlock recipes in-game until they have crafted said item. Silly right!?! So I added another syntax for you to unlock (discover) recipes for players however you see fit (See examples)

Discover Recipes for Players
code_language.skript:
#! Unlock a recipe for a player !#
effect [(1¦un)]discover recipe %string% for %players%:
    trigger:
        set {_string} to expression-1
        replace all " " with "_" in {_string}
        set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_string})
        loop expressions-2:
            if parse mark is 1:
                loop-expression.undiscoverRecipe({_key})
            else:
                loop-expression.discoverRecipe({_key})

Here are some examples. Just a heads up, its best to load new recipes on a 'on skript load' event. Also take note that if you load a recipe whilst a player is on the server, they won't see the new recipe in their book until after they log out/log in again.

Registering Recipe Examples - Here I have created 3 examples to show how you can create a custom shaped recipe with a custom result as well as custom ingredients. Take note to put the ingredients in order as the would appear in a crafting grid. (Supports only a crafting table) You should include all 9 ingredients, but if you miss one, the code will automatically fill the rest with air.
In the example for shapeless you will notice the ingredients are just vanilla ingredients but the output item can be a custom item. Shapless recipes can have their incredients in any order. If there are 4 or less ingredients these recipes will work in the players crafting grid, 5 or more will require the crafting table.
In the example for furnace recipes, you will notice I have used a custom ingredient and custom result. Wahoo, supports both!
code_language.skript:
#! Examples !#
on skript load:
    set {_item} to diamond sword of sharpness 10 and mending named "&5POWERFUL EMERALD SWORD"
    set {_ing} to diamond sword of sharpness 5 named "&aEMERALD SWORD"
    register new shaped recipe for {_ing} using air, emerald, air, air, emerald, air, air, stick and air with id "emerald_sword"
    register new shaped recipe for {_item} using air, air, air, air, {_ing}, air, air, air and air with id "powerful_emerald_sword"

    set {_elytra} to elytra named "&aFAST ELYTRA"
    set {_felytra} to elytra named "&dFASTER ELYTRA"
    register new shapeless recipe for {_elytra} using elytra with id "elytra"
    register new shapeless recipe for {_felytra} using elytra and elytra with id "fast_elytra"

    set {_egg} to egg named "&cHOT EGG"
    set {_begg} to egg named "&4BOILING EGG"
    register new furnace recipe for {_egg} using egg with id "hot_egg", experience 10, cook time 20
    register new furnace recipe for {_begg} using {_egg} with id "boiling_egg", experience 10, cook time 200

Unlocking Recipes for Players - As stated above recipes don't seem to unlock naturally for players, maybe this is because of the custom items. But you can simply create events for the players to unlock recipes. Like where I have used the pickup emerald event to give the player the emerald sword recipe. Even if you don't give them the recipe they can still craft the item, they just won't see it in their recipe guide.
code_language.skript:
on join:
    discover recipe "emerald_sword" for player
    discover recipe "powerful_emerald_sword" for player

on pickup of elytra:
    discover recipe "elytra" for player
    discover recipe "fast_elytra" for player

on pickup of emerald:
    discover recipe "emerald_sword" for player
[doublepost=1552851982,1548060972][/doublepost]Updated furnace recipe thing.
I wrote something wrong with totally screwed it up.... if you are using it, please update :emoji_slight_smile:
 
Last edited:
"When recipes are added to the server, they are not automatically unlocked for players. For some silly reason, unlike other items in the recipe book, players cannot seem to unlock recipes in-game until they have crafted said item. Silly right!?! So I added another syntax for you to unlock (discover) recipes for players however you see fit (See examples)"

I think this is related to the advancements / recipes.

Maybe you need to edit the .json files inside the server .jar to add these recipes as default, then, all players will have them.

Thanks for the snippet.
[doublepost=1566886668,1566885165][/doublepost]Also, got this when using the shaped recipe:

wVv0oHM.png
 
"When recipes are added to the server, they are not automatically unlocked for players. For some silly reason, unlike other items in the recipe book, players cannot seem to unlock recipes in-game until they have crafted said item. Silly right!?! So I added another syntax for you to unlock (discover) recipes for players however you see fit (See examples)"

I think this is related to the advancements / recipes.

Maybe you need to edit the .json files inside the server .jar to add these recipes as default, then, all players will have them.

Thanks for the snippet.
[doublepost=1566886668,1566885165][/doublepost]Also, got this when using the shaped recipe:

wVv0oHM.png
Those are just general Skript warnings, you can turn off the and/or warnings in your Skript config if you so choose to ignore those warnings.
 
Any idea on why this is not working? (no errors, but won't craft in craft table):

Code:
on skript load:
  set {_nbt} to "{SkullOwner:{Id:""04049c90-d3e9-4621-9caf-000000aaa218"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGQxZDhjNTA0ODY3OTMzNzAzZGEzNmVjMTFmNTM4ZjYyNjVmOTg0NDFkODgxZWFjNDhlZjJjNDkzNGMxYiJ9fX0=""}]}},display:{Lore:['{""text"":""§aToca-Discos""}'],Name:'{""text"":""§9Jukebox""}'},Damage:3}"
  set {_item} to player head
  set nbt of {_item} to {_nbt}
  set {_nbt} to "{HideFlags:47,display:{Lore:['{""text"":""§eTítulo - 64x §6AesCoins""}'],Name:'{""text"":""§6AesCheque""}'},Enchantments:[{lvl:1s,id:""minecraft:unbreaking""}]}"
  set {_ing} to paper
  set nbt of {_ing} to {_nbt}
  register new shaped recipe for {_item} using plank, plank, plank, plank, {_ing}, plank, plank, plank and plank with id "jukebox"

I want to add a recipe for crafting a custom player head (jukebox) that will take 8 planks + 1 custom paper.
 
When running your code, and looking in the recipe book, this is what I got:

Screen Shot 2019-08-27 at 12.09.55 AM.png


I think the issue is you put "plank" which Skript randomly picks a plank ... I think you need to specify the plank type
 
Weird that i can't find the custom head in the recipe book, even using this (while you can see in the recipe book):

Code:
on join:
  discover recipe "jukebox" for player

I'll try to change to a specific plank.
 
Well, something is off.
I used the command /minecraft:recipe give, and it says that the recipe does not exist.

So, this is not working (the recipe register part.)

I just copied your code and edited just the recipe part, and it works for you.

I'll paste it all here so you can see:

Code:
import:
  org.bukkit.Bukkit
  org.bukkit.inventory.ShapedRecipe
  org.bukkit.inventory.RecipeChoice$ExactChoice
  org.bukkit.NamespacedKey
 
#! Register shaped recipe with custom ingredients !#
effect register [new] shaped recipe for %item% using %items% with id %string%:
  trigger:
    set {_ing::*} to expressions-2
    loop 9 times:
      if {_ing::%loop-number%} is not set:
        set {_ing::%loop-number%} to air
    #! ID + NamespacedKey !#
    set {_id} to expression-3
    replace all " " with "_" in {_id}
    set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_id})
    #! Create Recipe !#
    set {_recipe} to new ShapedRecipe({_key}, expression-1)
    loop 9 times:
      set {_choices::%loop-number%} to new ExactChoice({_ing::%loop-number%})
    #! Ingredients !#
    {_recipe}.shape("123","456","789")
    loop {_ing::*}:
      {_recipe}.setIngredient(loop-index, {_choices::%loop-index%})
    Bukkit.addRecipe({_recipe})

#! Unlock a recipe for a player !#
effect [(1¦un)]discover recipe %string% for %players%:
  trigger:
    set {_string} to expression-1
    replace all " " with "_" in {_string}
    set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_string})
    loop expressions-2:
      if parse mark is 1:
        loop-expression.undiscoverRecipe({_key})
      else:
        loop-expression.discoverRecipe({_key})

on join:
  discover recipe "jukebox" for player

on skript load:
  set {_nbt} to "{SkullOwner:{Id:""04049c90-d3e9-4621-9caf-000000aaa218"",Properties:{textures:[{Value:""eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGQxZDhjNTA0ODY3OTMzNzAzZGEzNmVjMTFmNTM4ZjYyNjVmOTg0NDFkODgxZWFjNDhlZjJjNDkzNGMxYiJ9fX0=""}]}},display:{Lore:['{""text"":""§aToca-Discos""}'],Name:'{""text"":""§9Jukebox""}'},Damage:3}"
  set {_item} to player head
  set nbt of {_item} to {_nbt}
  set {_nbt} to "{HideFlags:47,display:{Lore:['{""text"":""§eTítulo - 64x §6AesCoins""}'],Name:'{""text"":""§6AesCheque""}'},Enchantments:[{lvl:1s,id:""minecraft:unbreaking""}]}"
  set {_ing} to paper
  set nbt of {_ing} to {_nbt}
  register new shaped recipe for {_item} using oak plank, oak plank, oak plank, oak plank, {_ing}, oak plank, oak plank, oak plank and oak plank with id "jukebox"
 
on skript load only works when Skript loads, not when a script loads.
You will need to restart your server (or if you are daring, run "/reload")
 
I got confused about on skript load and "on load", for me was both the same.

But I got this when restarting, is this a error?

Code:
27.08 03:26:17 [Server] Server thread/WARN method ShapedRecipe#shape called with (123 (String), 456 (String), 789 (String)) returned shaped recipe (ShapedRecipe), which could not be converted to Boolean

and after restarting, using the "/minecraft:recipe give aescraft skript:jukebox" command won't work (skript:jukebox doesn't exist).

skript 2.4-beta 5
skript-mirror 2.0
 
I got confused about on skript load and "on load", for me was both the same.

But I got this when restarting, is this a error?

Code:
27.08 03:26:17 [Server] Server thread/WARN method ShapedRecipe#shape called with (123 (String), 456 (String), 789 (String)) returned shaped recipe (ShapedRecipe), which could not be converted to Boolean

and after restarting, using the "/minecraft:recipe give aescraft skript:jukebox" command won't work (skript:jukebox doesn't exist).

skript 2.4-beta 5
skript-mirror 2.0
Hmm that is odd, I have never seen that error/warning before, im not really sure what is causing that.

just to double check, which spigot version are you using?
 
Craftbukkit ver git-spigot-ea7e48b-368f4e9 (mc 1.14.4) ver 1.14.4-R0.1 Snapshot.

12 versions behind.
 
Plugins (skript related only):

skript
reqn
skquery
skriptjson
tuske
sk-nbeet
tablisknu
skrayfall
skript-mirror
[doublepost=1566891947,1566891827][/doublepost]Same error:

Code:
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': Bukkit.getPluginManager().getPlugin("Skript"), {_id} (jukebox.sk, line 17: set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_id})')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': {_key}, expression-1 (jukebox.sk, line 19: set {_recipe} to new ShapedRecipe({_key}, expression-1)')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': "123","456","789" (jukebox.sk, line 23: {_recipe}.shape("123","456","789")')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': loop-index, {_choices::%loop-index%} (jukebox.sk, line 25: {_recipe}.setIngredient(loop-index, {_choices::%loop-index%})')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': Bukkit.getPluginManager().getPlugin("Skript"), {_string} (jukebox.sk, line 33: set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_string})')
27.08 03:44:54 [Server] Server thread/INFO All scripts loaded without errors.
27.08 03:44:54 [Server] Server thread/INFO Loaded 5 scripts with a total of 36 triggers and 36 commands in 4.22 seconds
27.08 03:44:54 [Server] Server thread/INFO Finished loading.
27.08 03:44:54 [Server] Server thread/WARN method ShapedRecipe#shape called with (123 (String), 456 (String), 789 (String)) returned shaped recipe (ShapedRecipe), which could not be converted to Boolean
[doublepost=1566891987][/doublepost]I'll remove the plugins one by one and restart.
[doublepost=1566894757][/doublepost]Tablisknu is the one causing issues.
https://github.com/TlatoaniHJ/Tablisknu/issues/4
 
Plugins (skript related only):

skript
reqn
skquery
skriptjson
tuske
sk-nbeet
tablisknu
skrayfall
skript-mirror
[doublepost=1566891947,1566891827][/doublepost]Same error:

Code:
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': Bukkit.getPluginManager().getPlugin("Skript"), {_id} (jukebox.sk, line 17: set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_id})')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': {_key}, expression-1 (jukebox.sk, line 19: set {_recipe} to new ShapedRecipe({_key}, expression-1)')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': "123","456","789" (jukebox.sk, line 23: {_recipe}.shape("123","456","789")')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': loop-index, {_choices::%loop-index%} (jukebox.sk, line 25: {_recipe}.setIngredient(loop-index, {_choices::%loop-index%})')
27.08 03:44:53 [Server] Server thread/WARN List is missing 'and' or 'or', defaulting to 'and': Bukkit.getPluginManager().getPlugin("Skript"), {_string} (jukebox.sk, line 33: set {_key} to new NamespacedKey(Bukkit.getPluginManager().getPlugin("Skript"), {_string})')
27.08 03:44:54 [Server] Server thread/INFO All scripts loaded without errors.
27.08 03:44:54 [Server] Server thread/INFO Loaded 5 scripts with a total of 36 triggers and 36 commands in 4.22 seconds
27.08 03:44:54 [Server] Server thread/INFO Finished loading.
27.08 03:44:54 [Server] Server thread/WARN method ShapedRecipe#shape called with (123 (String), 456 (String), 789 (String)) returned shaped recipe (ShapedRecipe), which could not be converted to Boolean
[doublepost=1566891987][/doublepost]I'll remove the plugins one by one and restart.
[doublepost=1566894757][/doublepost]Tablisknu is the one causing issues.
https://github.com/TlatoaniHJ/Tablisknu/issues/4
That is probably because the method returns a value, which is weird because the description of the method says that it changes the shape of this recipe, so it's weird that it also returns itself. You could probably work around the issue by using it as an expression instead.
 
That is probably because the method returns a value, which is weird because the description of the method says that it changes the shape of this recipe, so it's weird that it also returns itself. You could probably work around the issue by using it as an expression instead.
That part of the code I got from shanebee.
I never used those before, so I don't know what a method is or the difference from expressions.
 
That part of the code I got from shanebee.
I never used those before, so I don't know what a method is or the difference from expressions.
Yea it was a little more directed towards @ShaneBee, but your post had the error so I quoted that. It's just weird since the line seems to get recognized as a condition, and that's why Skript tried to convert it to a boolean. It's probably because skript-mirror has registered methods as an effect and expression, otherwise value returning wouldn't be possible, and Skript thought this should be parsed as an expression (which could then be converted to a boolean for the condition), not an effect for some reason. But this doesn't make sense, Skript should clearly parse this as an effect.
 
Yea it was a little more directed towards @ShaneBee, but your post had the error so I quoted that. It's just weird since the line seems to get recognized as a condition, and that's why Skript tried to convert it to a boolean. It's probably because skript-mirror has registered methods as an effect and expression, otherwise value returning wouldn't be possible, and Skript thought this should be parsed as an expression (which could then be converted to a boolean for the condition), not an effect for some reason. But this doesn't make sense, Skript should clearly parse this as an effect.
Ok.

But the thing is, if I remove tablisknu, it works.
With the addon tablisknu, this error happens.