promotional bannermobile promotional banner

Fishing Loot Helper API

This API makes it easy for mods to add custom fishing loot.
item image

Description

Fishing Loot Helper API

This API makes it easy for mods to add custom fishing loot.

Right now it is just for NeoForge 26.3, but more versions will come!

Installation

1. Add the API .jar

Place the fishingloothelperapi.jar file into your Minecraft mods folder:

C:\Users\you\AppData\Roaming\.minecraft\mods

Also, place a copy inside your mod's libs folder:

your-mod/
├── libs/
│   └── fishingloothelperapi.jar
├── src/
├── build.gradle
└── ...

2. Add the API to build.gradle

Change version 1.0.0 to whatever version you are using.

repositories {
    flatDir {
        dir 'libs'
    }
}

dependencies {
    implementation 'com.exline:fishingloothelperapi:1.0.0'
}

3. Add the API as a mod dependency

In neoforge.mods.toml, add:

[[dependencies.${mod_id}]]
modId="fishingloothelperapi"
type="required"
versionRange="[1.0.0,)"
ordering="NONE"
side="BOTH"

Use the API version you are depending on.

The API .jar must also be present in the Minecraft mods folder when running the game.

Adding Fishing Loot

Register custom fishing loot with this method:

FishRegistry.registerFishingLoot(
        Items.BRAIN_CORAL,
        10,
        FishingEntry.FishingType.FISH
);

Parameters

Item (Required)

The item being added to the fishing loot can be a vanilla item or custom item.

Items.BRAIN_CORAL

Weight (Required)

The item's weight. Higher weight means a higher chance of being selected.

10

Fishing Loot Type (Optional)

This determines which vanilla fishing pool the item is added to.

FishingEntry.FishingType.FISH

Available types:

FishingEntry.FishingType.FISH
FishingEntry.FishingType.JUNK
FishingEntry.FishingType.TREASURE

Example with a modded item

FishRegistry.registerFishingLoot(
        ModItems.ANCHOVY,
        10,
        FishingEntry.FishingType.FISH
);

Biomes

You can optionally choose which biome(s) an item can be caught in.

One Biome

FishRegistry.registerFishingLoot(
        ModItems.ANCHOVY,
        10,
        FishingEntry.FishingType.FISH,
        Biomes.OCEAN
);

Multiple Biomes

FishRegistry.registerFishingLoot(
        ModItems.ANCHOVY,
        10,
        FishingEntry.FishingType.FISH,
        Biomes.OCEAN,
        Biomes.BEACH
);

Biome Tags

You can also use biome tags instead of individual biome keys.

Multiple biome tags can be specified as well.

FishRegistry.registerFishingLoot(
        ModItems.ANCHOVY,
        10,
        FishingEntry.FishingType.FISH,
        Tags.Biomes.IS_AQUATIC
);

Any Biome

When no biomes are specified, the item can be caught in any biome.

The same applies to junk and treasure:

FishRegistry.registerFishingLoot(
        ModItems.ANCHOVY,
        10,
        FishingEntry.FishingType.FISH
);

Weights

Fishing Loot Helper API uses a weight system based on the vanilla fishing pool.

Vanilla Base Weights

Fishing Type Base Weight
Fish 100
Junk 110
Treasure 6

Your custom loot is added to the corresponding vanilla pool.

From our earlier example, we have a weight of 10:

FishRegistry.registerFishingLoot(
        ModItems.ANCHOVY,
        10,
        FishingEntry.FishingType.FISH
);

The fish pool becomes:

Loot Weight
Vanilla fish 100
Anchovy 10
Total 110

The Anchovy therefore has a 10/110 chance of being selected, or about 9.09%.

If you add two fish with weight 10:

Loot Weight
Vanilla fish 100
Fish A 10
Fish B 10
Total 120

Each custom fish has a 10/120 chance of being selected, or about 8.33%.

Base Weight + Added Weights = New Total Weight

Higher weight = more common loot.

More weight added means less chance of getting vanilla loot.

However, you can also add the same vanilla loot to increase the chances again, like cod or salmon.

Vanilla Weights for Reference

Fish

Item Weight
Cod 60
Salmon 25
Pufferfish 13
Tropical Fish 2
Total 100

Junk

Item Weight
Lily Pad 17
Leather Boots 10
Leather 10
Water Potion 10
String 5
Fishing Rod 2
Bowl 5
Stick 5
Ink Sac 5
Tripwire Hook 5
Rotten Flesh 5
Bamboo 5
Total 110

Treasure

Item Weight
Cod 60
Salmon 25
Pufferfish 13
Tropical Fish 2
Total 100

You can calculate an item's chance by dividing its weight by the total weight.

For example, if we add a fish with weight 20, the chance of catching Cod goes from 60/100, or 60%, to 60/120, or 50%.

Fishing Loot Helper API Team

Grand Artisan tier frameprofile avatar
  • 159
    Followers
  • 43
    Projects
  • 17.5M
    Downloads

More from exlinegamesView all