How to Add Custom Loot to Forge Mobs: Global Loot Modifiers Guide

Master adding custom loot to Forge mobs using Global Loot Modifiers. Learn JSON conditions, code setup, and mod compatibility best practices.

Adding custom drops to hostile or passive creatures is essential when designing custom RPG progression or balanced modpacks. When you want to attach fresh loot to Forge mobs, overriding base datapack files often causes harsh compatibility conflicts with other creators' mods. Learning the clean, modern approach to inject custom loot to Forge mobs ensures your content works seamlessly alongside hundreds of other mods without breaking vanilla drop tables.

Minecraft modding has evolved past the era of destructively replacing base game registries. Using modern Forge architecture, creators can selectively modify drop behavior using non-invasive hooks. Whether you are rewarding players with rare crafting reagents from Strays or designing unique boss rewards, this comprehensive guide explores the architecture, implementation steps, and troubleshooting techniques you need.

Why Global Loot Modifiers Are Essential for Forge Mobs

In earlier versions of Minecraft, modders commonly altered drop behaviors by directly overriding the game's default loot tables (data/minecraft/loot_tables/entities/...json). While simple on paper, this practice is destructive. If two distinct mods attempt to replace the drops for a Zombie or a Stray, the mod loading last completely overwrites the other, causing items to vanish entirely from the game world.

To eliminate this conflict, the Minecraft Forge development team introduced the Global Loot Modifier (GLM) system. GLMs sit between the game's internal drop calculations and the final item spawn event. Instead of replacing tables, GLMs listen to drop events, evaluate custom conditions, and dynamically append, remove, or modify items in real time.

MethodCompatibility RatingMaintenance EffortRisk of Mod ConflictsMulti-Mod Safety
Direct JSON OverwriteVery LowHigh (breaks on game updates)Severe (last mod wins)Unsafe
Custom LivingDropsEvent (Code only)MediumMedium (manual math required)LowModerately Safe
Global Loot Modifiers (GLM)ExceptionalLow (data-driven JSON rules)MinimalRecommended Standard
Mixin InjectionLow to MediumVery High (fragile across versions)Moderate to HighAdvanced Only

By leveraging GLMs to supply loot to Forge mobs, you maintain standard Forge ecosystem hygiene. Your mod can inject custom gemstones, artifacts, or crafting materials into any vanilla or modded entity without interfering with any other developer's additions.

Core Architecture: The Two Halves of a Global Loot Modifier

Implementing a Global Loot Modifier requires two components working in sync: Java code registration and JSON data definitions. The Java class defines what action occurs to the item list, while the JSON files determine when and where that action applies.

Your Mod Root
├── src/main/java/com/yourname/mod/
│   └── loot/
│       └── AddItemModifier.java (The Java Logic & Serializer)
└── src/main/resources/
    └── data/
        ├── forge/
        │   └── loot_modifiers/
        │       └── global_loot_modifiers.json (Master list)
        └── your_mod_id/
            └── loot_modifiers/
                └── stray_frost_berry.json (Specific rule)

Understanding this separation prevents the most common developer mistakes. The Java class is intentionally reusable; a single AddItemModifier class can handle hundreds of distinct drops across dozens of different creatures merely through different JSON declarations.

Step 1: Writing the Java Modifier and Serializer

In your Java mod source, you must extend Forge's base loot modifier class. This class reads the incoming list of items (List<ItemStack>), adds your specified item, and returns the modified list back to the engine.

public class LootAdditionModifier extends LootModifier {
    private final Item addition;

    public LootAdditionModifier(LootItemCondition[] conditionsIn, Item addition) {
        super(conditionsIn);
        this.addition = addition;
    }

    @Nonnull
    @Override
    protected ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) {
        generatedLoot.add(new ItemStack(this.addition));
        return generatedLoot;
    }

    // Codec or Serializer registration depends on your exact Forge version
}

The modifier extracts the item dynamically. Rather than hardcoding a specific mob into the Java code, you keep the class generic so that data packs can configure targeting conditions without recompiling your JAR.

Step 2: Registering the Modifier Serializer

Forge requires your modifier's serializer to be registered in your mod's deferred registry. In modern versions, this is handled via DeferredRegister<Codec<? extends IGlobalLootModifier>> or GlobalLootModifierSerializer.

public static final DeferredRegister<Codec<? extends IGlobalLootModifier>> LOOT_MODIFIERS =
    DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, "your_mod_id");

public static final RegistryObject<Codec<LootAdditionModifier>> ADD_ITEM =
    LOOT_MODIFIERS.register("add_item", () -> LootAdditionModifier.CODEC);

For official developer references, review the Minecraft Forge Documentation regarding registry lifecycles and modern DataFixerUpper Codec patterns.

Target Configuration: Mapping Custom Loot to Forge Mobs

Once the Java code compiles and the serializer registers under your namespace, all remaining logic happens inside JSON files. This architecture allows modpack creators and server owners to alter drop tables via server datapacks without touching source code.

The Master Registration File

Forge scans a specific path for the list of active modifiers. You must place this file at data/forge/loot_modifiers/global_loot_modifiers.json.

{
  "replace": false,
  "entries": [
    "your_mod_id:stray_drops_berries",
    "your_mod_id:zombie_rare_iron"
  ]
}

Setting "replace": false is critical. If you set it to true, you will disable all modifiers registered by earlier-loading mods, recreating the very compatibility problems GLMs were designed to fix.

Crafting Entity Conditions for Mobs

To grant loot to Forge mobs accurately, you must target the entity using vanilla loot table conditions. Community reports from the official Forge support forums show that developers often struggle here: using block-breaking conditions instead of entity predicates causes drops to fail silently.

Here is an example rule file placed at data/your_mod_id/loot_modifiers/stray_drops_berries.json:

{
  "type": "your_mod_id:add_item",
  "conditions": [
    {
      "condition": "minecraft:entity_properties",
      "predicate": {
        "type": "minecraft:stray"
      },
      "entity": "this"
    },
    {
      "condition": "minecraft:killed_by_player"
    }
  ],
  "addition": "your_mod_id:frost_berries"
}
JSON ParameterRoleDescription
typeSerializer IdentifierPoints to your mod's registered modifier serializer ID.
conditionsLogic FiltersAn array of vanilla predicates that must all return true.
entityContext SelectorMust be set to "this" to inspect the mob that just died.
predicate.typeEntity IDThe ResourceLocation of the mob (e.g., minecraft:blaze).
additionPayload ItemThe item registered in Forge to insert into drops.

In this configuration, whenever a player kills a Stray, the game matches the conditions, fires your modifier, and adds your custom berries to the default bones and arrows.

Advanced Drop Logic: Probabilities, Looting, and Biomes

Basic 100% drop rates can quickly ruin gameplay balance. Fortunately, vanilla Minecraft's condition system supports extensive filtering logic without requiring extra Java development.

Adding Probabilistic Drop Rates

If an item should only drop 15% of the time, add a minecraft:random_chance condition into the JSON array:

{
  "condition": "minecraft:random_chance",
  "chance": 0.15
}

Factoring in the Looting Enchantment

Rewarding players who use the Looting enchantment is standard design practice. To make drop rates scale according to weapon enchantments, employ minecraft:random_chance_with_looting:

{
  "condition": "minecraft:random_chance_with_looting",
  "chance": 0.05,
  "looting_multiplier": 0.02
}

In this setup, killing the mob without Looting yields a 5% drop rate. Looting I raises it to 7%, Looting II to 9%, and Looting III provides an 11% total probability.

Condition Types Comparison

Condition NameUse CaseMob Drop Utility
minecraft:entity_propertiesTarget exact mob types or NBT tagsEssential for targeting specific mobs
minecraft:killed_by_playerPrevent automated mob farm exploitsHigh (preserves server economy)
minecraft:damage_source_propertiesRequire specific death causes (e.g., fire)Great for specialized mob drop logic
minecraft:location_checkLimit drops to specific biomes/dimensionsIdeal for regional mob variants
minecraft:random_chanceSet static percentage drop chancesEssential for rare mob drops

Combining these conditions ensures that your items are only distributed when appropriate player actions occur.

Troubleshooting Common Drop Registration Errors

When setting up custom loot to Forge mobs, subtle configuration mismatches can cause items to fail to drop. Based on player experience and mod development forum discussions, the following checklist resolves the vast majority of silent failures.

IssueSymptomImmediate Fix
Wrong Entity ContextItems drop from blocks, never mobsEnsure "entity": "this" is inside minecraft:entity_properties.
Serializer Name MismatchGame crashes during startup with JSON errorVerify the "type" string in your JSON matches your registry name.
Missing from Master ListNo crash, but zero custom items appearConfirm your file name is listed in global_loot_modifiers.json.
Datapack Path TyposFile loads fine, but logic never runsDouble-check folder structure: data/<namespace>/loot_modifiers/.
Non-player DeathsItems fail to drop in testingRemove minecraft:killed_by_player if testing using /kill.

If drops still do not appear in-game, verify the game's debug logs. When Forge encounters an unparseable loot modifier file, it logs a warning during registry startup noting the exact line number where the JSON syntax or item registry name failed.

Frequently Asked Questions (FAQ)

Can I attach custom loot to Forge mobs added by other third-party mods?

Yes. In the minecraft:entity_properties condition, replace the vanilla namespace with the target mod's namespace and entity ID (such as twilightforest:naga or alexsmobs:crocodile). As long as that mod registers its entities through standard Forge registries, Global Loot Modifiers will hook into them cleanly.

Do I need to create a new Java class for every single item drop?

No. A single generic LootAdditionModifier class can be referenced by dozens of different JSON files. Each JSON file supplies its own unique item identifier and targeting conditions, allowing you to attach diverse loot to Forge mobs without writing repetitive code.

Can Global Loot Modifiers remove vanilla items from mob tables?

Yes. Instead of using a simple generatedLoot.add(...) call in your Java logic, your modifier can inspect the generatedLoot collection and use removeIf(...) to strip away vanilla items like rotten flesh or bones under specific custom conditions.

Why won't my mob modifier work when using the /kill command?

If your modifier includes the minecraft:killed_by_player condition, using /kill or letting mobs die from fall damage bypasses the rule. Always test drops by striking the mob directly with a survival or creative player character to fulfill player-kill predicates.