Drop Rate API

Forge 1.16.5 - 1.20.x GNU GPLv3

A Minecraft Forge mod that provides JSON-based mob drop configuration, a programmatic API for developers, and a cross-mod compatibility layer for Loot Tables.

Key Features

  • JSON Config: Customize mob drop rates and items easily without coding.
  • API Integration: Developers can add or modify drops programmatically.
  • Complex Amounts: Support for fixed amounts or min/max ranges.
  • Non-Destructive: Designed to work alongside other loot modifiers.

Installation

For Players

  1. Download the droprate-api.jar file from CurseForge.
  2. Place the file into your /mods folder.
  3. Launch the game to generate the default configuration file.

For Developers (Gradle/Maven)

To use the API in your own mod, add the following to your build.gradle:

1. Repository Setup

repositories {
    maven {
        url "https://cursemaven.com"
        content { includeGroup "curse.maven" }
    }
}

2. Dependencies

Replace the IDs with the version you want to target (ProjectID: 1208468):

dependencies {
    // Drop Rate API (Example for 1.16.5)
    // Format: curse.maven:slug-projectid:fileid
    implementation fg.deobf("curse.maven:drop-rate-api-1208468:6249868")
}
Pro Tip: Remember to run gradlew --refresh-dependencies after adding the dependency.

Configuration

The configuration file is located at config/droprate.config.json.

Basic Structure

{
  "config": [
    {
      "mob": "minecraft:zombie",
      "rate": 80,
      "item": ["minecraft:apple"],
      "item_amount": {
        "min_amount": 1,
        "max_amount": 3
      }
    }
  ]
}

Field Reference

Field Type Description
mob String The Entity ID (e.g., minecraft:skeleton).
rate Integer Drop chance percentage (0-100).
item Array List of item IDs to drop (e.g., ["minecraft:diamond"]).
item_amount Int / Obj Either a fixed number or an object with min_amount and max_amount.

* Note: Amounts are automatically clamped between 1 and 64.

Commands

Commands to manage the mod in-game.

Command Description
/droprate_reload Reloads the config/droprate.config.json file immediately without restarting the server/game.

Developer API

Usage examples for mod developers integrating DropRate.

Importing the API

import th.tamkungz.droprateapi.api.DropRateAPI;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Items;
import java.util.Arrays;

Registering Custom Drops

// Register drops: Mob, Rate(%), Items List, Min Amount, Max Amount
DropRateAPI.registerDrop(
    EntityType.ZOMBIE, 
    75, 
    Arrays.asList(Items.DIAMOND, Items.EMERALD), 
    1, 
    5
);

Removing Drops

// Remove specific items from a mob's drop list
DropRateAPI.removeDrop(EntityType.CREEPER, Items.GUNPOWDER);

Event Handling

Drops are processed during the LivingDeathEvent via the MobDeathHandler. You can subscribe to this event to add custom logic alongside DropRate.

Compatibility

Load Order: DropRate should ideally load after core content mods but before other heavy loot modifiers to ensure overrides work correctly.
Mod Status Notes
Apotheosis Full Use Apotheosis for drop scaling mechanics.
Lootr Partial Chest interactions should be tested manually.
TConstruct Limited Tool modification support is not currently active.

License

DropRate - Custom Mob Drops & API is licensed under the GNU General Public License v3.0.

Copyright (C) 2023 TamKungZ_

This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.