截图
介绍
Fishing Loot Helper API
This API makes it easy for mods to add custom fishing loot.
Right now there are just versions for 26.3, for Fabric and NeoForge.
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"
For Fabric:
Open src/main/resources/fabric.mod.json and add fishingloothelperapi to the existing depends section:
"depends": {
"fabricloader": ">=0.19.0",
"minecraft": "26.3",
"fishingloothelperapi": ">=1.0.0"
}
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 |
|---|---|
| Bow | 1 |
| Enchanted Book | 1 |
| Fishing Rod | 1 |
| Name Tag | 1 |
| Nautilus Shell | 1 |
| Saddle | 1 |
| Total | 6 |
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%.
Example Mod
I made an example mod you can use to learn from or just try out. https://github.com/jexline/ogfishmod
常见问题
Fishing Loot Helper API 支持哪些 Minecraft 版本?
Fishing Loot Helper API 支持 Minecraft Java 版 26.3,可用的加载器:Fabric / NeoForge。下载时注意选择和你游戏版本一致的文件。
Fishing Loot Helper API 怎么安装?
先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / NeoForge,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。
评论
登录后评论和评分