i want to change the drops of mobs to something else in 1.21 java using command blocks
1
Instead of using a commandblock you should consider using a datapack instead. Of course this does depend on what exactly it is you're trying to do.
But anyway... (random) drops are set up using so called loot tables. Which can be customized and created... using a datapack. However, applying such a loot table is indeed something you can do using a command block or a function. When working on chests and what not you're looking for the LootTable, but when messing around with entities then this is the DeathLootTable.
Changing these is easily done using the /data command. Let's say we want to prevent a cow from dropping items:
If you check the Minecraft client archive you'll find: "data\minecraft\loot_tables\entities\witch.json" which is the loot table for... the witch (duh!). So why not apply that to the above cow? =>
Nothing too hard, right?
But anyway... (random) drops are set up using so called loot tables. Which can be customized and created... using a datapack. However, applying such a loot table is indeed something you can do using a command block or a function. When working on chests and what not you're looking for the LootTable, but when messing around with entities then this is the DeathLootTable.
Changing these is easily done using the /data command. Let's say we want to prevent a cow from dropping items:
- /summon minecraft:cow ~ ~ ~ {NoAI:true, Tags:["m00"]}
- /data merge entity @e[tag=m00,limit=1] {DeathLootTable:""}
If you check the Minecraft client archive you'll find: "data\minecraft\loot_tables\entities\witch.json" which is the loot table for... the witch (duh!). So why not apply that to the above cow? =>
- /data merge entity @e[tag=m00,limit=1] {DeathLootTable:"minecraft:entities/witch"}
Nothing too hard, right?
