Skip to content
On this page
通用

KattonWorldApi

top.katton.api.dpcallercommon/src/main/kotlin/top/katton/api/dpcaller/KattonWorldApi.kt
以类似 Map 的方式按 ResourceKey 访问所有服务端关卡。

KattonLevelMap

KattonLevelMap通用
kotlin
class KattonLevelMap( private val server: MinecraftServer ) : Map<ResourceKey<Level>, ServerLevel>

以类似 Map 的方式按 ResourceKey 访问所有服务端关卡。

KattonLevelMap.overworld

KattonLevelMap.overworld通用属性
kotlin
val overworld: ServerLevel

快速访问主世界关卡。

KattonLevelMap.nether

KattonLevelMap.nether通用属性
kotlin
val nether: ServerLevel

快速访问下界关卡。

KattonLevelMap.end

KattonLevelMap.end通用属性
kotlin
val end: ServerLevel

快速访问末地关卡。

levels

levels通用属性
kotlin
val levels: KattonLevelMap

以类似 Map 的方式访问所有服务端关卡。

players

players通用属性
kotlin
val ServerLevel.players: KattonLevelPlayerCollection

访问关卡中的玩家。

blockEntities

blockEntities通用属性
kotlin
val ServerLevel.blockEntities: KattonLevelBlockEntityCollection

访问关卡中的方块实体。

entities

entities通用属性
kotlin
val ServerLevel.entities: KattonLevelEntityCollection

访问关卡中的实体。

blocks

blocks通用属性
kotlin
val Level.blocks: KattonLevelBlockCollection

访问关卡中的方块。

blockStates

blockStates通用属性
kotlin
val Level.blockStates: KattonLevelBlockStateCollection

访问关卡中的方块状态。

setBlock

setBlock通用函数
kotlin
fun setBlock(level: Level, pos: BlockPos, state: BlockState)

在指定位置设置特定方块状态。

参数

参数说明
level要修改的关卡。
pos方块位置。
state要设置的方块状态。

setBlock

setBlock通用函数
kotlin
fun setBlock(level: Level, pos: BlockPos, block: Block)

使用方块类型的默认状态在指定位置设置方块。

参数

参数说明
level要修改的关卡。
pos方块位置。
block要设置的方块类型。

fill

fill通用函数
kotlin
fun fill(level: Level, start: BlockPos, end: BlockPos, state: BlockState)

使用给定方块状态填充一个区域。

参数

参数说明
level要修改的关卡。
start起始位置(包含)。
end结束位置(包含)。
state要放置的方块状态。

fill

fill通用函数
kotlin
fun fill(level: Level, start: BlockPos, end: BlockPos, block: Block)

使用给定方块类型的默认状态填充一个区域。

参数

参数说明
level要修改的关卡。
start起始位置(包含)。
end结束位置(包含)。
block要放置的方块类型。

fillBiome

fillBiome通用函数
kotlin
fun fillBiome(level: Level, start: BlockPos, end: BlockPos, biome: Identifier, biomePredicate: (Holder<Biome>) -> Boolean)

使用给定谓词筛选生物群系 Holder,并填充区域内的生物群系。

参数

参数说明
level要修改的服务端关卡。
start起始位置。
end结束位置。
biome要应用的生物群系标识符。
biomePredicate用于进一步筛选生物群系应用范围的谓词。

locateStructure

locateStructure通用函数
kotlin
fun locateStructure(structureKey: ResourceKey<Structure>, level: ServerLevel, startPos: BlockPos = BlockPos.ZERO): BlockPos?

按 ResourceKey 定位结构。

参数

参数说明
structureKey结构资源键。
level要搜索的服务端关卡。
startPos搜索起始位置。

返回值

返回结构所在的 BlockPos;找不到时返回 null。

locateStructure

locateStructure通用函数
kotlin
fun locateStructure(structureKey: TagKey<Structure>, level: ServerLevel, startPos: BlockPos = BlockPos.ZERO): BlockPos?

按 TagKey 定位结构。

参数

参数说明
structureKey结构标签键。
level要搜索的服务端关卡。
startPos起始位置。

返回值

返回 BlockPos;找不到时返回 null。

locateBiome

locateBiome通用函数
kotlin
fun locateBiome(biomeKey: ResourceKey<Biome>, level: ServerLevel, startPos: BlockPos = BlockPos.ZERO): Pair<BlockPos, Holder<Biome>>?

按 ResourceKey 查找最近的生物群系。

参数

参数说明
biomeKey生物群系资源键。
level要搜索的服务端关卡。
startPos起始位置。

返回值

返回方块位置和生物群系 Holder 的 Pair;找不到则返回 null。

locateBiome

locateBiome通用函数
kotlin
fun locateBiome(biomeKey: TagKey<Biome>, level: ServerLevel, startPos: BlockPos = BlockPos.ZERO): Pair<BlockPos, Holder<Biome>>?

按 TagKey 查找最近的生物群系。

参数

参数说明
biomeKey生物群系标签键。
level要搜索的服务端关卡。
startPos起始位置。

返回值

返回方块位置和生物群系 Holder 的 Pair;找不到则返回 null。

placeFeature

placeFeature通用函数
kotlin
fun placeFeature(feature: Identifier, pos: BlockPos)

在指定位置放置已配置特性。

参数

参数说明
feature特性标识符。
pos放置位置。

placeJigsaw

placeJigsaw通用函数
kotlin
fun placeJigsaw(templatePool: Identifier, start: Identifier, depth: Int, pos: BlockPos)

从模板池放置拼图结构。

参数

参数说明
templatePool池标识符。
start起始模板标识符。
depth放置深度。
pos起始位置。

placeStructure

placeStructure通用函数
kotlin
fun placeStructure(structure: Identifier, pos: BlockPos)

按标识符在指定位置放置结构。

参数

参数说明
structure结构标识符。
pos放置位置。

playSound

playSound通用函数
kotlin
fun playSound(level: ServerLevel, players: Collection<ServerPlayer>, sound: Identifier, soundSource: SoundSource, pos: Vec3, volume: Float = 1.0f, pitch: Float = 1.0f, minVolume: Float = 0.0f)

向一组玩家播放声音,并处理距离衰减和最小音量。

参数

参数说明
level服务端关卡。
players要接收声音的玩家。
sound声音标识符。
soundSource声音类别或来源。
pos声音来源位置。
volume基础音量。
pitch播放音高。
minVolume超出范围时的最小可听音量。

randomSample

randomSample通用函数
kotlin
fun randomSample(randomSequence: Identifier? = null, broadcast: Boolean = false, min: Int = Int.MIN_VALUE, max: Int = Int.MAX_VALUE): Int?

使用可选随机序列在 [min, max] 范围内抽取随机整数。

参数

参数说明
randomSequence随机序列的可选标识符。
broadcast是否向玩家广播结果。
min包含的最小值。
max包含的最大值。

返回值

返回随机整数;范围无效时返回 null。

resetSequence

resetSequence通用函数
kotlin
fun resetSequence(level: ServerLevel, randomSequence: Identifier)

将关卡中的命名随机序列重置为默认种子。

参数

参数说明
level服务端关卡。
randomSequence序列标识符。

resetSequence

resetSequence通用函数
kotlin
fun resetSequence(level: ServerLevel, randomSequence: Identifier, seed: Int, includeWorldSeed: Boolean = true, includeSequenceID: Boolean = true)

使用指定种子和行为标志重置命名随机序列。

参数

参数说明
level服务端关卡。
randomSequence序列标识符。
seed整数种子。
includeWorldSeed是否包含世界种子。
includeSequenceID是否包含序列 ID。

resetAllSequences

resetAllSequences通用函数
kotlin
fun resetAllSequences(level: ServerLevel)

清除关卡中的所有随机序列。

参数

参数说明
level服务端关卡。

resetAllSequencesAndSetNewDefaults

resetAllSequencesAndSetNewDefaults通用函数
kotlin
fun resetAllSequencesAndSetNewDefaults(level: ServerLevel, seed: Int, includeWorldSeed: Boolean = true, includeSequenceID: Boolean = true)

重置所有随机序列并设置新的默认值。

参数

参数说明
level服务端关卡。
seed要设为默认值的种子。
includeWorldSeed是否包含世界种子。
includeSequenceID是否包含序列 ID。

setTickingRate

setTickingRate通用函数
kotlin
fun setTickingRate(f: Float)

设置服务器 tick 速率。

参数

参数说明
f新的 tick 速率(每秒刻数)。

tickQuery

tickQuery通用函数
kotlin
fun tickQuery(): Float

查询当前 tick 速率。

返回值

返回 tick 速率值。

tickSprint

tickSprint通用函数
kotlin
fun tickSprint(i: Int)

请求服务器按给定 tick 数快速推进。

参数

参数说明
i要快速推进的 tick 数。

setTickFreeze

setTickFreeze通用函数
kotlin
fun setTickFreeze(freeze: Boolean)

冻结或解除冻结服务器 tick 处理。

参数

参数说明
freezetrue 表示冻结,false 表示解除冻结。

tickStep

tickStep通用函数
kotlin
fun tickStep(i: Int)

服务器暂停时按指定 tick 数步进。

参数

参数说明
i要步进的 tick 数。

tickStopStepping

tickStopStepping通用函数
kotlin
fun tickStopStepping(): Boolean

停止 tick 管理器的步进模式。

返回值

如果已停止步进则返回 true。

tickStopSprinting

tickStopSprinting通用函数
kotlin
fun tickStopSprinting(): Boolean

停止 tick 管理器的快速推进模式。

返回值

如果已停止快速推进则返回 true。

getDuration

getDuration通用函数
kotlin
fun getDuration(level: ServerLevel, i: Int, intProvider: IntProvider): Int

解析持续时间:如果 [i] 为 -1,则从 [intProvider] 抽样;否则返回 [i]。

参数

参数说明
i提供的持续时间,-1 表示抽样。
intProvider用于抽样的 IntProvider。

返回值

返回持续时间。

setClear

setClear通用函数
kotlin
fun setClear(level: ServerLevel, i: Int)

设置晴朗天气的持续时间;传入 -1 时从 IntProvider 抽样。

参数

参数说明
i持续 tick 数,或 -1 表示抽样。

setRain

setRain通用函数
kotlin
fun setRain(level: ServerLevel, i: Int)

设置降雨天气的持续时间;传入 -1 时从 IntProvider 抽样。

参数

参数说明
i持续 tick 数,或 -1 表示抽样。

setThunder

setThunder通用函数
kotlin
fun setThunder(level: ServerLevel, i: Int)

设置雷暴天气的持续时间;传入 -1 时从 IntProvider 抽样。

参数

参数说明
i持续 tick 数,或 -1 表示抽样。

setWorldBorderDamageBuffer

setWorldBorderDamageBuffer通用函数
kotlin
fun setWorldBorderDamageBuffer(level: ServerLevel, distance: Double)

设置世界边界安全缓冲区。

参数

参数说明
level要修改世界边界的服务端关卡。
distance安全距离缓冲区。

setWorldBorderDamageAmount

setWorldBorderDamageAmount通用函数
kotlin
fun setWorldBorderDamageAmount(level: ServerLevel, damage: Double)

设置世界边界每格伤害值。

参数

参数说明
level服务端关卡。
damage每格伤害值。

setWorldBorderWarningTime

setWorldBorderWarningTime通用函数
kotlin
fun setWorldBorderWarningTime(level: ServerLevel, time: Int)

设置世界边界警告时间。

参数

参数说明
level服务端关卡。
time警告时间,单位为秒。

setWorldBorderWarningDistance

setWorldBorderWarningDistance通用函数
kotlin
fun setWorldBorderWarningDistance(level: ServerLevel, distance: Int)

设置世界边界警告距离,单位为方块。

参数

参数说明
level服务端关卡。
distance警告距离。

getWorldBorderSize

getWorldBorderSize通用函数
kotlin
fun getWorldBorderSize(level: ServerLevel): Double

获取当前世界边界大小。

参数

参数说明
level服务端关卡。

返回值

返回世界边界大小。

setWorldBorderSize

setWorldBorderSize通用函数
kotlin
fun setWorldBorderSize(level: ServerLevel, size: Double, time: Long = 0L)

设置世界边界大小,可选在一段时间内渐变。

参数

参数说明
level服务端关卡。
size目标边界大小。
time插值到新大小的 tick 数,0 表示立即生效。