Minecraft – How to summon a mob that drops an item with custom durability

minecraft-commandsminecraft-java-edition

I have tried and failed to summon a mob with a fixed durability item. Every time the entity is killed, it drops the item with a randomized durability, because such is the way. But is there a way to over-ride this and give the item a fixed durability on drop? I have tried:

/summon zombie ~ ~1 ~ {HandItems:[{Count:1,id:stone_sword,tag:{Damage:1,display:{Name:"\"Blade\""}}},{}],HandDropChances:[1.0f,0.0f]}

The test being the "Damage:1" bit.

Best Answer

You need to override its loot table with your own. To add your own loot table, you will need a data pack (which is a folder from which the game will load your loot table) and you need the loot table itself which you can either write manually or generate using an online loot table generator.

I already made this data pack, you can download it here: https://www.dropbox.com/sh/bc0obb1ffcevdla/AAAmA49J_C-olU25uxGWwwKva?dl=0
to apply it to your save, paste the folder "zombie_loot_table" inside .minecraft/saves/your_save/datapacks and make sure to /reload if you are already in the game.

but in case you want to do it yourself, here is all the information you need:
Data pack structure - https://minecraft.gamepedia.com/Data_pack
loot table generator - https://misode.github.io/loot-table/
my tutorial on loot tables - https://datapackcenter.com/projects/loot-tables.72/