DropAPI
掉落物 API 分为两个子入口:
DropAPI.DropItem.API— 按物品库 ID 掉落物品DropAPI.ExpballDrop.API— 经验球掉落
DropItem
通过 DropAPI.DropItem.API 访问。根据物品库 ID 在指定位置生成掉落物。
方法列表
| 方法签名 | 说明 |
|---|---|
drop(id: String, location: Location, amount: Int, velocity: String, player: Player?, owner: String?) | 按物品库 ID 掉落物品 |
drop(id: String, location: Location, amount: Int, chance: Float, velocity: String, player: Player?, owner: String?) | 带概率掉落 |
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
id | String | 物品库 ID |
location | Location | 掉落位置 |
amount | Int | 掉落数量 |
chance | Float | 掉落概率(0.0 ~ 100.0) |
velocity | String | 掉落物初速度,"false" 使用默认 |
player | Player? | 关联玩家(用于变量解析),可为 null |
owner | String? | 掉落物归属者名称(拾取保护),可为 null |
import kim.hhhhhy.kethermodule.api.DropAPI
// 基础掉落
DropAPI.DropItem.API.drop("diamond_sword", location, 1)
// 带概率掉落,50% 概率,指定归属者
DropAPI.DropItem.API.drop(
"rare_gem", location, 1, 50.0f,
"0.0,0.3,0.0", player, player.name
)
ExpballDrop
通过 DropAPI.ExpballDrop.API 访问。在指定位置生成经验球。
方法列表
| 方法签名 | 说明 |
|---|---|
drop(location: Location, amount: Int, chance: Int) | 带概率掉落经验球 |
drop(location: Location, amount: Int) | 掉落经验球(100% 概率) |
参数说明:
| 参数 | 类型 | 说明 |
|---|---|---|
location | Location | 掉落位置 |
amount | Int | 经验值数量 |
chance | Int | 掉落概率(0 ~ 100) |
import kim.hhhhhy.kethermodule.api.DropAPI
// 固定掉落 50 经验
DropAPI.ExpballDrop.API.drop(location, 50)
// 30% 概率掉落 100 经验
DropAPI.ExpballDrop.API.drop(location, 100, 30)