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