Minecraft Data Packs / Technology

Custom Crafting template [use nbt edited items as ingredients]

  • check_circle Advancements
  • check_circle Functions
  • check_circle Predicates
  • check_circle Recipes
  • 4,515 views, 4 today
  • 213 downloads, 0 today
  • 17
  • 11
imalittlhigh's Avatar imalittlhigh
Level 62 : High Grandmaster Sweetheart
110
Want to craft with nbt edited / custom Items?
Dont like ground crafting or instant crafting?

Feel free to use this =)




Crafting the Custom Crafting Table:
- place a craftingtable with ironingot and paper above it in a normal crafting table.
Recipe
Custom Crafting template [use nbt edited items as ingredients] Minecraft Data Pack



Adding your own recipes:



Edit the function found here: crafting/data/crafting/functions/table/recipes/recipes.mcfunction


The lines you don´t need to change / copy are lines 9 & 17.
This template has 3 example recipes: test1, test2 and test3.
You need to copy each line with either of these names in it and change them to your own to add your recipe.


If you want to add more recipes just copy the lines and change the marked text to your new recipe.

Edit the marked (red) text to fit your recipe. Example:
(lines 11-13)

execute as @s[tag=crafting.crafted.test3] at @s positioned ~ ~1 ~ unless predicate crafting:recipes/test/test3 positioned ~ ~0.5 ~ run data modify entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item set value {id:"minecraft:air",Count:1b}

To:

execute as @s[tag=crafting.crafted.rocket1] at @s positioned ~ ~1 ~ unless predicate crafting:recipes/rockets/rocket1 positioned ~ ~0.5 ~ run data modify entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item set value {id:"minecraft:air",Count:1b}

The same goes for these:
(lines 10-21)

tag @s remove crafting.crafted.test3
(lines 23-46)
#recipe example 2
#which recipe
execute as @s at @s positioned ~ ~1 ~ if predicate crafting:recipes/test/test3 run tag @s add crafting.crafted.test3
#tagging that something is crafted
execute as @s at @s positioned ~ ~1 ~ if predicate crafting:recipes/test/test3 run tag @s add crafting.crafted
#setting the item in the frame to the crafting result
execute as @s[tag=crafting.crafted.test3] at @s positioned ~ ~1 ~ unless data entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item{id:"minecraft:diamond",Count:1b} run data modify entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item set value {id:"minecraft:diamond",Count:1b}


Example of the lines above changed:

tag @s remove crafting.crafted.rocket1

#recipe example 2
#which recipe
execute as @s at @s positioned ~ ~1 ~ if predicate crafting:recipes/rockets/rocket1 run tag @s add crafting.crafted.rocket1
#tagging that something is crafted
execute as @s at @s positioned ~ ~1 ~ if predicate crafting:recipes/rockets/rocket1 run tag @s add crafting.crafted
#setting the item in the frame to the crafting result
execute as @s[tag=crafting.crafted.rocket1] at @s positioned ~ ~1 ~ unless data entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item{id:"minecraft:firework_rocket",Count:1b} run data modify entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item set value {id:"minecraft:firework_rocket",Count:1b}


To explain the last line:

execute as @s[tag=crafting.crafted.test2] at @s positioned ~ ~1 ~ unless data entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item{id:"minecraft:diamond",Count:1b} run data modify entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item set value {id:"minecraft:diamond",Count:1b}

The Red text is the item the recipe is crafting. This just needs to be the same item type as the actual crafting result (no added nbt is needed).

The Purple text (at the end) is the actual item that is being crafted. This needs to have all the nbt you want it to have since its the item you take from the Item frame.

Example of a more complex item in the frame:
execute as @s[tag=crafting.crafted.test3] at @s positioned ~ ~1 ~ unless data entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item{id:"minecraft:wooden_sword",Count:1b} run data modify entity @e[type=item_frame,limit=1,sort=nearest,tag=crafting.itemframe] Item set value {id:"minecraft:wooden_sword",Count:1b,tag:{display:{Name:'{"text":"I am so custom"}',Lore:['{"text":"the customest sword ever"}']},Damage:0.9,Enchantments:[{id:"minecraft:sharpness",lvl:10s},{id:"minecraft:looting",lvl:5s}],AttributeModifiers:[{AttributeName:"generic.attack_speed",Name:"generic.attack_speed",Amount:3,Operation:0,UUID:[I;-1966788,2039563859,-2123628066,-1862249592]}]}}

If you´re having trouble getting the syntax, give yourself the item, place it in a container and do /data get block on it.

This gives you the correct syntax:

Custom Crafting template [use nbt edited items as ingredients] Minecraft Data Pack


If you have recipes that have overlapping ingredients in the same position like this:

recipe test1
&
recipe test2

You need to have additional code:

The first 2 lines of the affected recipes need to be changed to this:
(lines 26-28)

#recipe example 1#which recipe
execute as @s at @s positioned ~ ~1 ~ if predicate crafting:recipes/test/test unless predicate crafting:recipes/test/test2 run tag @s add crafting.crafted.test
#tagging that something is crafted
execute as @s at @s positioned ~ ~1 ~ if predicate crafting:recipes/test/test unless predicate crafting:recipes/test/test2 run tag @s add crafting.crafted


test1 is the upper recipe while test2 is the lower.

This ensures that the more complex recipe is chosen (stone and dirt) instead of the simpler (just stone) if both stone and dirt are placed in the dropper.

You need to add an unless predicate crafting:recipes/test/test2 for every recipe that uses items placed in the same slot unless other slots differ (other than not having anyting in it).

For example you would not have to do this with these recipes if recipe test1 (the upper one) had some other block in the top middle slot of the dropper, since recipes test1 and test2 can never be the "same" then.

Important note:
This datapack does not check for blank spaces in the dropper. Meaning you could put the stone as shown above in the middle and surround it with diamonds and the recipe would still give the deeplate. If you remove the deepslate ALL the items in the dropper will be deleted.

You also can not craft multiple of the same item at once, so I would recommend to only use this to craft relatively complex items that are not needed too often since that could get very annoying to craft (like dispensers).




Adding Recipe Predicates



To actually add recipes you need to add predicates that dictate how the items in the dropper need to be placed.

These predicates are found here:
predicate dir

Example for the crafting stone to deepslate recipe:
{ "condition": "minecraft:location_check",
"predicate": {
"block": {
"nbt": "{Items:[{Slot:4b,id:\"minecraft:stone\",Count:1b}]}"
} } }


test3 is a blank recipe with all the slots having one dirt in them:

{ "condition": "minecraft:location_check",
"predicate": {
"block": {
"nbt": "{Items:[
{
Slot:0b,id:\"minecraft:dirt\",Count:1b},
{
Slot:1b,id:\"minecraft:dirt\",Count:1b},
{
Slot:2b,id:\"minecraft:dirt\",Count:1b},
{
Slot:3b,id:\"minecraft:dirt\",Count:1b},
{
Slot:4b,id:\"minecraft:dirt\",Count:1b},
{
Slot:5b,id:\"minecraft:dirt\",Count:1b},
{
Slot:6b,id:\"minecraft:dirt\",Count:1b},
{
Slot:7b,id:\"minecraft:dirt\",Count:1b},
{
Slot:8b,id:\"minecraft:dirt\",Count:1b}]}"
} }}


You can change the item, the Count, and any other nbt value (like tags, etc) of the ingredients.

Here an example of items with custom tags:
{Slot:3b,id:\"minecraft:disc_fragment_5\",Count:1b,tag:{custom_tag:1b}}

Example of item with custom name:

{Slot:1b,id:\"minecraft:dirt\",Count:1b,tag:{display:{Name:'{\"text\":\"Name\"}'}}}

If you have trouble finding the right syntax, just give youself the item, place it in a container and do a /data get block on it.

This shows you the correct syntax:



Be sure to escape double quotes with a \ !

Here is a picture of all the dropper slots labled with the corresponding slot number:




And here is an example of a recipe using unmodified items that you could not do with normal crafting:

Recipe and Result:



Recipe Predicate:
{ "condition": "minecraft:location_check",
"predicate": {
"block": {
"nbt": "{Items:[
{
Slot:0b,id:\"minecraft:repeater\",Count:1b},
{
Slot:1b,id:\"minecraft:obsidian\",Count:2b},
{
Slot:2b,id:\"minecraft:repeater\",Count:1b},
{
Slot:3b,id:\"minecraft:piston\",Count:2b},
{
Slot:4b,id:\"minecraft:tnt\",Count:1b},
{
Slot:5b,id:\"minecraft:observer\",Count:2b},
{
Slot:6b,id:\"minecraft:redstone_torch\",Count:1b},
{
Slot:7b,id:\"minecraft:scaffolding\",Count:32b},
{
Slot:8b,id:\"minecraft:redstone\",Count:8b}]}" } } }




Do not copy the code from this post. I changed the layout a bit to make it easier to read.
Use the code in the datapack, it is the same I have used here with the last example recipe being the exception.
CompatibilityMinecraft 1.18
toMinecraft 1.19
Tags

1 Update Logs

Update #1 : by imalittlhigh 01/19/2023 1:47:57 pmJan 19th, 2023

Fixed a bug where the dropper would replace not-full-blocks and place the armorstand and item frame wrong.
Works with every possible block-elevation now.

Create an account or sign in to comment.

Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome