D
Deleted member 5254
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:
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.
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)
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.
[doublepost=1552851982,1548060972][/doublepost]Updated furnace recipe thing.
I wrote something wrong with totally screwed it up.... if you are using it, please update
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
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!
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
I wrote something wrong with totally screwed it up.... if you are using it, please update
Last edited by a moderator: