mojira.dev
MC-103995

Can't combine swords/tools/armor with Unbreakable tag in an anvil

If you give yourself 2 unbreakable swords with this command

/give @s minecraft:diamond_sword[minecraft:unbreakable={}] 2

you cannot combine them in an anvil.

This makes it hard in some custom maps to obtain higher levels of enchantments.

Suggested fix:
Make it only possible to combine unbreakable tools with the same damage value, and have the returned item have that damage too (so custom models don’t change and still make sense). Possibly making it a gamerule.

Linked issues

Attachments

Comments 18

It would seem that because the anvil is used for repair, that it won't accept the Unbreakble tag. For the anvil to work the item in slot one must be damaged. If sword is damaged in slot 1 then in slot 2 there could be another damaged sword of the same material or an undamaged sword of the same material or an enchantment book with an acceptable enchantment. However, you can use enchantment books for your adventure map. Since if the unbreakable sword is in slot one then the only acceptable item in slot 2 can be an acceptable enchantment book. Some enchantments cannot be combined. And i think there is a limit on how many enchantments can be placed on a sword using the anvil. So using this theory, you cannot place two Unbreakable tagged swords because the one in slot 1 must be damaged.

Can confirm for MC 1.12.1.

Can confirm in 20w48a.

Can confirm in 21w03a.

Can confirm in 21w05b.

8 more comments

Can confirm for 1.20.4.

I think the problem with trying to fix this is that damage values pull double duty. Not only do they measure the damage of the item, they also serve as the means of letting map makers create new items. This means that "Unbreakable: 1b" is pulling double duty as well, which is a problem when one may not want both fulfilled.

So an unbreakable item's damage value must be assumed to be perfectly stable, regardless of what a player attempts to do with it.

But on the other hand, if someone wants to make certain items (say all swords) unbreakable through a datapack, and wants the players to be able to do everything else normally, such as combining enchantments with other items regardless of the other item's damage, they should be able to do so and have the resulting item remain unbreakable.

So somehow, custom items remaining stable, and combining items with enchantments in anvils, need to be segregated.

Perhaps this could be a solution:

  • allow "Unbreakable: 1" items to be combined if they have the same damage value, but don't change the damage value of the resulting item, and...

  • give the "Unbreakable" nbt tag a possible value of 2 (an int instead of a bool), which still be unbreakable, but would allow the item to be combined with any item of its type regardless of damage values, and the resulting item still have "Unbreakable: 2".

This would allow map makers to continue to use their items as is without needing to worry about changing too much (1b would just be taken as an int of 1), and would allow future map makers and especially datapack makers to allow the combining of enchanted items in anvils without worrying about damage values.

Confirmed 24w09a

However, with "minecraft:unbreakable" being changed to a component, and no longer being a boolean, we could potentially add properties to it that would allow it to combine with other items.

Things like "minecraft:unbreakable={anvil_requires_matching_damage:false}" would allow us to specify under what circumstances unbreakable items can be combined in anvils and more.

If "anvil_requires_matching_damage" is unspecified, it can disable combining completely. Setting it to true would require the damage values to be the same. Setting it to false would allow you combine items of the same type regardless of damage values.

There could even be a field to specify how it combines in anvils, either keeping the damage value of the first item, or adding the damage values together to get a new value, or something else.

I believe something like this could solve most if not all of the issues with this bug.

Side note: It is possible with components to now remove the "minecraft:damage" component from an item completely (though only in loot tables, through item modifiers, etc. It's not possible to do with /give or other such commands yet due to the limitations with the new syntax), and this makes the item equally unbreakable.

However, items with the damage component removed cannot be combined in anvils either (understandably), leading to the same problem as before.

But this isn't an issue if "minecraft:unbreakable" is able to be modified to allow the combining of items under specified circumstances.

Can confirm in 24w38a

Can confirm in 1.21.2

user-f2760

(Unassigned)

Confirmed

Crafting, Items

anvil, armor, combine, combining, sword, tools, unbreakable

Minecraft 1.10, Minecraft 1.10.1, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 1.11 Pre-Release 1, ..., 24w10a, 24w38a, 1.21.2, 1.21.3, 1.21.5

Retrieved