跳到主要内容

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)带概率掉落

参数说明:

参数类型说明
idString物品库 ID
locationLocation掉落位置
amountInt掉落数量
chanceDouble掉落概率(0.0 ~ 1.0)
velocityVector?掉落物初速度,null 使用默认
playerPlayer?关联玩家(用于变量解析),可为 null
ownerPlayer?掉落物归属者(拾取保护),可为 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% 概率)

参数说明:

参数类型说明
locationLocation掉落位置
amountInt经验值数量
chanceDouble掉落概率(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)