Skip to content
On this page

Common

KattonWorldApi

top.katton.api.dpcallercommon/src/main/kotlin/top/katton/api/dpcaller/KattonWorldApi.kt
Map-like access to all server levels by ResourceKey.

KattonLevelMap

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

Map-like access to all server levels by ResourceKey.

KattonLevelMap.overworld

CommonProperty
kotlin
val overworld: ServerLevel

Quick access to the Overworld level.

KattonLevelMap.nether

CommonProperty
kotlin
val nether: ServerLevel

Quick access to the Nether level.

KattonLevelMap.end

CommonProperty
kotlin
val end: ServerLevel

Quick access to the End level.

levels

CommonProperty
kotlin
val levels: KattonLevelMap

Map-like access to all server levels.

players

CommonProperty
kotlin
val ServerLevel.players: KattonLevelPlayerCollection

Access to players in a level.

blockEntities

CommonProperty
kotlin
val ServerLevel.blockEntities: KattonLevelBlockEntityCollection

Access to block entities in a level.

entities

CommonProperty
kotlin
val ServerLevel.entities: KattonLevelEntityCollection

Access to entities in a level.

blocks

CommonProperty
kotlin
val Level.blocks: KattonLevelBlockCollection

Access to blocks in a level.

blockStates

CommonProperty
kotlin
val Level.blockStates: KattonLevelBlockStateCollection

Access to block states in a level.

setBlock

CommonFunction
kotlin
fun setBlock(level: Level, pos: BlockPos, state: BlockState)

Set a block at position to a specific BlockState.

Parameters

ParameterDescription
levellevel to modify
posblock position
stateBlockState to set

setBlock

CommonFunction
kotlin
fun setBlock(level: Level, pos: BlockPos, block: Block)

Set a block at position using a Block type's default state.

Parameters

ParameterDescription
levellevel to modify
posblock position
blockblock type to set

fill

CommonFunction
kotlin
fun fill(level: Level, start: BlockPos, end: BlockPos, state: BlockState)

Fill a region with a given BlockState.

Parameters

ParameterDescription
levellevel to modify
startstart position (inclusive)
endend position (inclusive)
stateBlockState to place

fill

CommonFunction
kotlin
fun fill(level: Level, start: BlockPos, end: BlockPos, block: Block)

Fill a region with a given Block type using its default state.

Parameters

ParameterDescription
levellevel to modify
startstart position (inclusive)
endend position (inclusive)
blockblock type to place

fillBiome

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

Fill a region's biome using a predicate on biome holder.

Parameters

ParameterDescription
levelserver-level to modify
startstart position
endend position
biomebiome identifier to apply
biomePredicatepredicate to further filter biome application

locateStructure

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

Locate a structure by ResourceKey.

Parameters

ParameterDescription
structureKeystructure resource key
levelserver level to search in
startPosstarting position for search

Returns

nearest BlockPos of the structure or null if not found

locateStructure

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

Locate a structure by TagKey.

Parameters

ParameterDescription
structureKeystructure tag key
levelserver level to search in
startPosstarting position

Returns

nearest BlockPos or null if not found

locateBiome

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

Find closest biome by resource key.

Parameters

ParameterDescription
biomeKeybiome resource key
levelserver level to search
startPosstarting position

Returns

Pair of BlockPos and biome Holder, or null if not found

locateBiome

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

Find closest biome by tag key.

Parameters

ParameterDescription
biomeKeybiome tag key
levelserver level to search
startPosstarting position

Returns

Pair of BlockPos and biome Holder, or null if not found

placeFeature

CommonFunction
kotlin
fun placeFeature(feature: Identifier, pos: BlockPos)

Place a configured feature at a position.

Parameters

ParameterDescription
featurefeature identifier
posposition to place

placeJigsaw

CommonFunction
kotlin
fun placeJigsaw(templatePool: Identifier, start: Identifier, depth: Int, pos: BlockPos)

Place a jigsaw structure from a template pool.

Parameters

ParameterDescription
templatePoolpool identifier
startstarting template identifier
depthplacement depth
posstarting position

placeStructure

CommonFunction
kotlin
fun placeStructure(structure: Identifier, pos: BlockPos)

Place a structure by identifier at a position.

Parameters

ParameterDescription
structurestructure identifier
posposition to place

playSound

CommonFunction
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)

Play a sound to a set of players, performing distance attenuation and minimum volume handling.

Parameters

ParameterDescription
levelserver level
playersplayers to send sound to
soundsound identifier
soundSourcesound category/source
possound origin position
volumebase volume
pitchplayback pitch
minVolumeminimum audible volume when out of range

randomSample

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

Sample a random integer in [min, max] using optional random sequence.

Parameters

ParameterDescription
randomSequenceoptional identifier for random sequence
broadcastwhether to broadcast the result to players
mininclusive minimum
maxinclusive maximum

Returns

sampled integer or null on invalid range

resetSequence

CommonFunction
kotlin
fun resetSequence(level: ServerLevel, randomSequence: Identifier)

Reset a named random sequence for a level to its default seed.

Parameters

ParameterDescription
levelserver level
randomSequencesequence identifier

resetSequence

CommonFunction
kotlin
fun resetSequence(level: ServerLevel, randomSequence: Identifier, seed: Int, includeWorldSeed: Boolean = true, includeSequenceID: Boolean = true)

Reset a named random sequence with a specific seed and behavior flags.

Parameters

ParameterDescription
levelserver level
randomSequencesequence identifier
seedinteger seed
includeWorldSeedwhether to include world seed
includeSequenceIDwhether to include sequence id

resetAllSequences

CommonFunction
kotlin
fun resetAllSequences(level: ServerLevel)

Clear all random sequences for a level.

Parameters

ParameterDescription
levelserver level

resetAllSequencesAndSetNewDefaults

CommonFunction
kotlin
fun resetAllSequencesAndSetNewDefaults(level: ServerLevel, seed: Int, includeWorldSeed: Boolean = true, includeSequenceID: Boolean = true)

Reset all sequences and set new defaults.

Parameters

ParameterDescription
levelserver level
seedseed to set as default
includeWorldSeedwhether to include world seed
includeSequenceIDwhether to include sequence id

setTickingRate

CommonFunction
kotlin
fun setTickingRate(f: Float)

Set the server ticking rate.

Parameters

ParameterDescription
fnew tick rate (ticks per second)

tickQuery

CommonFunction
kotlin
fun tickQuery(): Float

Query current tickrate.

Returns

current tickrate value

tickSprint

CommonFunction
kotlin
fun tickSprint(i: Int)

Request the server to sprint tick advancement by given ticks.

Parameters

ParameterDescription
inumber of ticks to sprint

setTickFreeze

CommonFunction
kotlin
fun setTickFreeze(freeze: Boolean)

Freeze or unfreeze server tick processing.

Parameters

ParameterDescription
freezetrue to freeze, false to unfreeze

tickStep

CommonFunction
kotlin
fun tickStep(i: Int)

Step the server forward a number of ticks while paused.

Parameters

ParameterDescription
inumber of ticks to step

tickStopStepping

CommonFunction
kotlin
fun tickStopStepping(): Boolean

Stop stepping mode on the tick manager.

Returns

true if stepping was stopped

tickStopSprinting

CommonFunction
kotlin
fun tickStopSprinting(): Boolean

Stop sprinting mode on the tick manager.

Returns

true if sprinting was stopped

getDuration

CommonFunction
kotlin
fun getDuration(level: ServerLevel, i: Int, intProvider: IntProvider): Int

Resolve duration: if i == -1 use IntProvider sampled value; otherwise return i.

Parameters

ParameterDescription
iprovided duration (-1 means sample)
intProviderprovider to sample from

Returns

resolved duration

setClear

CommonFunction
kotlin
fun setClear(level: ServerLevel, i: Int)

Set clear weather for specified duration (or sample when -1).

Parameters

ParameterDescription
iduration ticks or -1 to sample

setRain

CommonFunction
kotlin
fun setRain(level: ServerLevel, i: Int)

Set rain weather for specified duration (or sample when -1).

Parameters

ParameterDescription
iduration ticks or -1 to sample

setThunder

CommonFunction
kotlin
fun setThunder(level: ServerLevel, i: Int)

Set thunder weather for specified duration (or sample when -1).

Parameters

ParameterDescription
iduration ticks or -1 to sample

setWorldBorderDamageBuffer

CommonFunction
kotlin
fun setWorldBorderDamageBuffer(level: ServerLevel, distance: Double)

Set world border safe-zone buffer.

Parameters

ParameterDescription
levelserver level whose border to modify
distancesafe distance buffer

setWorldBorderDamageAmount

CommonFunction
kotlin
fun setWorldBorderDamageAmount(level: ServerLevel, damage: Double)

Set world border damage per block amount.

Parameters

ParameterDescription
levelserver level
damagedamage per block

setWorldBorderWarningTime

CommonFunction
kotlin
fun setWorldBorderWarningTime(level: ServerLevel, time: Int)

Set world border warning time.

Parameters

ParameterDescription
levelserver level
timewarning time in seconds

setWorldBorderWarningDistance

CommonFunction
kotlin
fun setWorldBorderWarningDistance(level: ServerLevel, distance: Int)

Set world border warning distance in blocks.

Parameters

ParameterDescription
levelserver level
distancewarning distance

getWorldBorderSize

CommonFunction
kotlin
fun getWorldBorderSize(level: ServerLevel): Double

Get the current world border size.

Parameters

ParameterDescription
levelserver level

Returns

world border size (double)

setWorldBorderSize

CommonFunction
kotlin
fun setWorldBorderSize(level: ServerLevel, size: Double, time: Long = 0L)

Set world border size, optionally over time.

Parameters

ParameterDescription
levelserver level
sizetarget border size
timetime in ticks to lerp to new size (0 for instant)