2. Recipes - LeonidMem/CoreM GitHub Wiki
Before creating recipes, you need to subscribe to workbench by using this code in function, which calls on load:
function corem:subscribe/workbench
You can create your own recipe easily. There are two options:
1. Use the special utility, which will create a template in one minute.
Firstly. download recipe_utility.py
, after that run this file with Python (if you don't have it, launch it here: OnlineGDB). Follow the instructions инструкциям and you will succeed!
It is worth noting, that if you will choose the option "Create file", it will be created in the same folder, where recipe_utility.py
exists!
2. Write code by hand.
First of all, create a function with any name and paste this code:
# You need to replace tag "corem.gapple", and all other to unique. It may prevent many issues.
# For example, if you have two recipes of dirt in datapack named "Example", change the tag in the first function
# to "example.recipe.dirt.1", in the second - "example.recipe.dirt.2"
# Display the item that player will get:
execute if block ~ ~ ~ barrel{Items:[{Slot:2b,id:"minecraft:gold_block"},{Slot:3b,id:"minecraft:gold_block"},{Slot:4b,id:"minecraft:gold_block"},{Slot:11b,id:"minecraft:gold_block"},{Slot:12b,id:"minecraft:apple"},{Slot:13b,id:"minecraft:gold_block"},{Slot:20b,id:"minecraft:gold_block"},{Slot:21b,id:"minecraft:gold_block"},{Slot:22b,id:"minecraft:gold_block"}]} run tag @s add corem.gapple.check
execute if entity @s[tag=corem.gapple.check,scores={corem.workbench=0}] run data modify block ~ ~ ~ Items[{Slot:15b}] set value {Slot:15b,id:"minecraft:enchanted_golden_apple",tag:{Tags:[corem.clear]},Count:1}
execute if entity @s[tag=corem.gapple.check] run scoreboard players set @s corem.workbench 2
# If player used this recipe and crafted something, this crafted thing removes and replaces to normal:
execute if entity @s[tag=corem.gapple.check] if data block ~ ~ ~ Items[{Slot:15b,id:"minecraft:barrier"}] run tag @s add corem.gapple.crafted
execute if entity @s[tag=corem.gapple.crafted] run clear @a[distance=..6] enchanted_golden_apple{Tags:[corem.clear]}
execute if entity @s[tag=corem.gapple.crafted] run give @p enchanted_golden_apple 1
execute if entity @s[tag=corem.gapple.crafted] run function corem:custom_wb/count
execute if entity @s[tag=corem.gapple.crafted] run scoreboard players set @s corem.workbench 0
execute if entity @s[tag=!corem.gapple.check] if data block ~ ~ ~ Items[{Slot:15b,id:"minecraft:enchanted_golden_apple",tag:{Tags:[corem.clear]}}] run scoreboard players set @s corem.workbench 0
tag @s remove corem.gapple.crafted
tag @s remove corem.gapple.check
Function will be triggered from area effect cloud, on which all work of the custom workbench is based.
If there is an air in the recipe, for example, in the middle, you need to add unless block ~ ~ ~ barrel{Items:[{Slot:12b}]}
and remove (in my case) {Slot:12b,id:"minecraft:apple"}
in if block ~ ~ ~ barrel{...}
.
After that create file custom_recipes.json
in folder data/corem/tags/functions/
and change it using this template:
{
"values": [
"datapack_name:path_to_recipe1",
"datapack_name:path_to_recipe2"
]
}
Of course, you can add something else in this code, such as play sound or spawn a cow, but I don't recommend removing anything.