I'm trying to make a custom npc map for myself.
I need a command that will summon a weapon that has low durability so it can by dropped by the npc.
Can anyone give me an example on how to do it?
I'm trying to make a custom npc map for myself.
I need a command that will summon a weapon that has low durability so it can by dropped by the npc.
Can anyone give me an example on how to do it?
Another thing that should be taken into account is that you cannot change the maximum durability of an item unless you use some sort of datapack or mod, but other than that you can change the number of uses it has left.
In 1.12 and before:
/give @p minecraft:diamond_sword 1 100
In 1.13 and after:
/give @p minecraft:diamond_sword{Damage:100} 1
Add the Damage tag to the command:
/give @s diamond_sword{Damage:780}
This will give you a half durability sword, or at least as close to half as you can get because a diamond swords durability is 1561
The /give command can do this.
The syntax is:
/give <player> <item> [amount] [data] [dataTag]
To give tools with less durability, just increase the [data].
This will give a diamond sword with full durability:
/give @p diamond_sword 1 0
This will give a diamond sword with 50 durability missing:
/give @p diamond_sword 1 50
This will give a diamond sword with 100 durability missing:
/give @p diamond_sword 1 100