Skip to content

How to make a mob that drops an item in a Minecraft mod

A mob’s drops come from its loot table, but a mod can add one more item without touching the table: listen for the mob’s death. Fabric API has ServerLivingEntityEvents.AFTER_DEATH and calls entity.spawnAtLocation. Forge and NeoForge have LivingDropsEvent and you add an item entity to its drops list. Both run on the server only. For your own mob, write a loot table in data/<modid>/loot_table/entities/<mob>.json instead (loot_tables before 1.21, assets/<modid>/loot_tables on 1.12.2).

Works on Minecraft 1.20.1 to 26.3 on NeoForge; Minecraft 1.19.2 to 26.3 on Fabric; Minecraft 1.16.5 to 1.20.1 on Forge; Minecraft 1.12.2 on Forge. Each example was compiled against its loader and version before it shipped in Linen.

  1. Pick the mob and the item by their ids, like minecraft:zombie and minecraft:diamond.
  2. Listen for the death event on your loader.
  3. Roll the chance and add the item to the drops.
  4. Kill the mob in survival a few times to see the drop.

The example uses these values. Change them in the code.

Setting In the example What it does
mob minecraft:zombie The id of the mob that drops it.
item minecraft:diamond The id of the item it drops.
chance 0.5 The chance, from 0 to 1.

The example mod is examplemod in the package com.example.examplemod. Use your own mod id and package.

Uses:

  • ServerLivingEntityEvents.AFTER_DEATH
  • Entity.spawnAtLocation
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Fabric API: ServerLivingEntityEvents.AFTER_DEATH).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's onInitialize.
public static void register() {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
if (entity.getType() == mob && entity.getRandom().nextFloat() < 0.5F) {
entity.spawnAtLocation(new ItemStack(BuiltInRegistries.ITEM.get(new ResourceLocation("minecraft:diamond"))));
}
});
}
}

In your main mod class, inside onInitialize:

ZombieLootDrops.register();

Uses:

  • ServerLivingEntityEvents.AFTER_DEATH
  • Entity.spawnAtLocation
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Fabric API: ServerLivingEntityEvents.AFTER_DEATH).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's onInitialize.
public static void register() {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(ResourceLocation.parse("minecraft:zombie"));
ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
if (entity.getType() == mob && entity.getRandom().nextFloat() < 0.5F) {
entity.spawnAtLocation(new ItemStack(BuiltInRegistries.ITEM.get(ResourceLocation.parse("minecraft:diamond"))));
}
});
}
}

In your main mod class, inside onInitialize:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (NeoForge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
NeoForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(ResourceLocation.parse("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.get(ResourceLocation.parse("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (NeoForge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
NeoForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.get(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • ServerLivingEntityEvents.AFTER_DEATH
  • Entity.spawnAtLocation
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Fabric API: ServerLivingEntityEvents.AFTER_DEATH).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's onInitialize.
public static void register() {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.getValue(ResourceLocation.parse("minecraft:zombie"));
ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
if (entity.level() instanceof ServerLevel level && entity.getType() == mob && entity.getRandom().nextFloat() < 0.5F) {
entity.spawnAtLocation(level, new ItemStack(BuiltInRegistries.ITEM.getValue(ResourceLocation.parse("minecraft:diamond"))));
}
});
}
}

In your main mod class, inside onInitialize:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (NeoForge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
NeoForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.getValue(ResourceLocation.parse("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.getValue(ResourceLocation.parse("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (NeoForge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
NeoForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.getValue(Identifier.parse("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.getValue(Identifier.parse("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • ServerLivingEntityEvents.AFTER_DEATH
  • Entity.spawnAtLocation
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Fabric API: ServerLivingEntityEvents.AFTER_DEATH).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's onInitialize.
public static void register() {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.getValue(Identifier.parse("minecraft:zombie"));
ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
if (entity.level() instanceof ServerLevel level && entity.getType() == mob && entity.getRandom().nextFloat() < 0.5F) {
entity.spawnAtLocation(level, new ItemStack(BuiltInRegistries.ITEM.getValue(Identifier.parse("minecraft:diamond"))));
}
});
}
}

In your main mod class, inside onInitialize:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Forge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
MinecraftForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = Registry.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
if (event.getEntityLiving().getType() == mob && event.getEntityLiving().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(Registry.ITEM.get(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntityLiving().level, event.getEntityLiving().getX(), event.getEntityLiving().getY(), event.getEntityLiving().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Forge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
MinecraftForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = Registry.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(Registry.ITEM.get(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level, event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Forge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
MinecraftForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.get(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level, event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Forge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
MinecraftForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.get(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • BuiltInRegistries.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (NeoForge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
MinecraftForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
if (event.getEntity().getType() == mob && event.getEntity().getRandom().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.get(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level(), event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • ServerLivingEntityEvents.AFTER_DEATH
  • Entity.spawnAtLocation
  • Registry.ITEM

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Fabric API: ServerLivingEntityEvents.AFTER_DEATH).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's onInitialize.
public static void register() {
EntityType<?> mob = Registry.ENTITY_TYPE.get(new ResourceLocation("minecraft:zombie"));
ServerLivingEntityEvents.AFTER_DEATH.register((entity, source) -> {
if (entity.getType() == mob && entity.getRandom().nextFloat() < 0.5F) {
entity.spawnAtLocation(new ItemStack(Registry.ITEM.get(new ResourceLocation("minecraft:diamond"))));
}
});
}
}

In your main mod class, inside onInitialize:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • ItemEntity
  • ForgeRegistries.ITEMS

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import java.util.Random;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraft.util.ResourceLocation;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Forge: LivingDropsEvent adds to the drops list).
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
// Called from the mod's constructor.
public static void register() {
MinecraftForge.EVENT_BUS.addListener(ZombieLootDrops::onDrops);
}
private static void onDrops(LivingDropsEvent event) {
EntityType<?> mob = ForgeRegistries.ENTITIES.getValue(new ResourceLocation("minecraft:zombie"));
if (event.getEntity().getType() == mob && new Random().nextFloat() < 0.5F) {
ItemStack stack = new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft:diamond")));
event.getDrops().add(new ItemEntity(event.getEntity().level, event.getEntity().getX(), event.getEntity().getY(), event.getEntity().getZ(), stack));
}
}
}

In your main mod class, inside <init>:

ZombieLootDrops.register();

Uses:

  • LivingDropsEvent.getDrops
  • EntityItem
  • ForgeRegistries.ITEMS

src/main/java/com/example/examplemod/event/ZombieLootDrops.java

package com.example.examplemod.event;
import com.example.examplemod.ExampleMod;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
// A minecraft:zombie drops minecraft:diamond on death with chance 0.5F (Forge: LivingDropsEvent adds to the drops list).
@Mod.EventBusSubscriber(modid = ExampleMod.MOD_ID)
public final class ZombieLootDrops {
private ZombieLootDrops() {
}
@SubscribeEvent
public static void onDrops(LivingDropsEvent event) {
EntityLivingBase mob = event.getEntityLiving();
if (new ResourceLocation("minecraft:zombie").equals(EntityList.getKey(mob)) && mob.getRNG().nextFloat() < 0.5F) {
Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation("minecraft:diamond"));
event.getDrops().add(new EntityItem(mob.world, mob.posX, mob.posY, mob.posZ, new ItemStack(item)));
}
}
}

Linen’s How-tos library has this page too, with the example for your own mod’s loader and Minecraft version. Hover a name in your code and Linen points to the how-tos that explain it. Both are free. Download Linen.