I have a bit of a problem. I would like to make a behavior pack where you can use a custom crafting recipe to craft items with enchantments on them. But I have not found any documentation or any guides on how to do this. Any ways I can?
1 Answer
If you haven't yet, begin by familiarizing yourself with the Vanilla packs. Within a behavior pack you can define a crafting recipe in the recipies
folder of your behavior pack:
Unfortunately, crafting does not offer the ability to enchant items. This is instead defined on the item data itself; for example, look at the enchanted apple definition:
{
"format_version": "1.10",
"minecraft:item": {
"description": {
"identifier": "minecraft:appleEnchanted"
},
"components": {
"minecraft:hand_equipped": false,
"minecraft:stacked_by_data": true,
"minecraft:use_duration": 32,
"minecraft:foil": true,
"minecraft:food": {
"nutrition": 4,
"saturation_modifier": "supernatural",
"can_always_eat": true,
"effects": [
{
"name": "regeneration",
"chance": 1.0,
"duration": 30,
"amplifier": 4
},
{
"name": "absorption",
"chance": 1.0,
"duration": 120, // 2 * 60
"amplifier": 3
},
{
"name": "resistance", // damage resistance
"chance": 1.0,
"duration": 300,
"amplifier": 0
},
{
"name": "fire_resistance",
"chance": 1.0,
"duration": 300,
"amplifier": 0
}
]
}
}
}
}
You'll have to define the crafting recipe and enchantments for your item separately.
-
@Iamstupidpleasehelp no worries! If this answered your question don't forget to upvote and click the check mark to accept the answer. Aug 10, 2021 at 19:12
-
It sort of answered my question, but now I have another. How do I define the enchantments exactly? As my username says, i have no idea what I'm doing Aug 10, 2021 at 19:15
-
@Iamstupidpleasehelp in your item's data file
myitem.json
you'll need to add a section labeledeffects
which is an array of effects as seen in my answer above. The enchanted apple is a good resource to pull data from for adding enchantments to an item at a basic level. Aug 10, 2021 at 19:20 -
I was going to change the recipes for pickaxes and other tools to automatically apply efficiency, but I can't do that. Also, how do I add an effects array to a wooden pickaxe and how does that make it have enchantments? Extremely confused Aug 10, 2021 at 19:38
-
@Iamstupidpleasehelp unfortunately, you can't modify some of the base namespace items, and the pickaxes, swords, shovels, armor, etc are included in the list of items we can't modify with the behavior pack. However, you can always create a new item that behaves like these items. Aug 10, 2021 at 19:44