Vanilla json recipes, Crafttweaker and KubeJS have different ways to handle items nbt so I will put an example of each below.
{
"type": "minecraft:crafting_shaped",
"pattern":
[
"xxx",
"x x",
"xxx"
],
"key":
{
"x":
{
"item": "minecraft:diamond"
}
},
"result":
{
"item": "custommachinery:custom_machine_item",
"count": 1,
"nbt": {"machine":"custommachinery:power_crusher"}
}
}
You need NBT crafting mod for this json recipe to work since fabric doesn't has a native way to make a crafting recipe output an item with nbt.
{
"type": "minecraft:crafting_shaped",
"pattern":
[
"xxx",
"x x",
"xxx"
],
"key":
{
"x":
{
"item": "minecraft:diamond"
}
},
"result":
{
"item": "custommachinery:custom_machine_item",
"count": 1,
"data": {"machine":"custommachinery:power_crusher"}
}
}
craftingTable.addShaped("power_crusher", <item:custommachinery:custom_machine_item>.withTag({machine: "custommachinery:power_crusher" as string}), [
[<item:minecraft:diamond>, <item:minecraft:diamond>, <item:minecraft:diamond>],
[<item:minecraft:diamond>, <item:minecraft:air>, <item:minecraft:diamond>],
[<item:minecraft:diamond>, <item:minecraft:diamond>, <item:minecraft:diamond>]
]);
onEvent('recipes', e => {
event.shaped(Item.of('custommachinery:custom_machine_item', {machine:"custommachinery:power_crusher"}), [
'DDD',
'D D',
'DDD'
], {
'D': 'minecraft:diamond'
})
})