2

The code is right there but basically I want to make it where it makes the diamond sword unbreakable and also with a name.

{
    "type": "minecraft:crafting_shaped",
    "pattern": [
        " # ",
        " # ",
        " / "
    ],
    "key": {
        "#": {
            "item": "minecraft:obsidian"
        },
        "/": {
            "item": "minecraft:blaze_rod"
        }
    },
    "result": {
        "item": "minecraft:diamond_sword",
        "count": 1
    }
}

2 Answers 2

0

As of the current Minecraft update (1.14.4) it is not possible to add custom NBT to crafting recipes, so you will be unable to give it a custom name and enchantments.

2
  • …which means you need to swap it out in the inventory later. How to do that is a bit complicated, I have a broad idea, but haven't programmed it in the game yet. But the basic way is /clear and /give, that just moves the item into a different slot. Commented Jul 20, 2019 at 9:47
  • Can I add damage modifiers at least?
    – Shiba
    Commented Jul 24, 2019 at 1:25
0

There is a way!

I was searching for a way to do this and I found a creative solution.

You will need an advancement, recipe, and a function.

  • The recipe should not be shapeless, and the recipe should give a knowledge book.
  • The advancement should look like:
{
    "criteria": {
        "Unlocked": {
            "trigger": "minecraft:recipe_unlocked",
            "conditions": {
                "recipe": "RECIPE NAME"
            }
        }
    },
    "rewards": {
        "function": "FUNCTION NAME"
    }
}
  • And the function should look like:
recipe take @s (RECIPE NAME)

advancement revoke @s only (ADVANCEMENT NAME)

(GIVE COMMAND FOR ITEM)

clear @s minecraft:knowledge_book

This has been super useful to me in the past, and it's the only way I know where you can use the vanilla crafting table for custom nbt recipes.
Note: There is no way to require custom nbt crafting materials unless you use a custom crafting table

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .