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 ​

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

Map-like access to all server levels by ResourceKey.

KattonLevelMap.overworld ​

KattonLevelMap.overworldCommonProperty
kotlin
val overworld: ServerLevel

Quick access to the Overworld level.

KattonLevelMap.nether ​

KattonLevelMap.netherCommonProperty
kotlin
val nether: ServerLevel

Quick access to the Nether level.

KattonLevelMap.end ​

KattonLevelMap.endCommonProperty
kotlin
val end: ServerLevel

Quick access to the End level.

levels ​

levelsCommonProperty
kotlin
val levels: KattonLevelMap

Map-like access to all server levels.

players ​

playersCommonProperty
kotlin
val ServerLevel.players: KattonLevelPlayerCollection

Access to players in a level.

blockEntities ​

blockEntitiesCommonProperty
kotlin
val ServerLevel.blockEntities: KattonLevelBlockEntityCollection

Access to block entities in a level.

entities ​

entitiesCommonProperty
kotlin
val ServerLevel.entities: KattonLevelEntityCollection

Access to entities in a level.

blocks ​

blocksCommonProperty
kotlin
val Level.blocks: KattonLevelBlockCollection

Access to blocks in a level.

blockStates ​

blockStatesCommonProperty
kotlin
val Level.blockStates: KattonLevelBlockStateCollection

Access to block states in a level.

setBlock ​

setBlockCommonFunction
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 ​

setBlockCommonFunction
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 ​

fillCommonFunction
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 ​

fillCommonFunction
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 ​

fillBiomeCommonFunction
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 ​

locateStructureCommonFunction
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 ​

BlockPos of the structure, or null if not found

locateStructure ​

locateStructureCommonFunction
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 ​

BlockPos, or null if not found

locateBiome ​

locateBiomeCommonFunction
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 ​

locateBiomeCommonFunction
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 ​

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

Place a configured feature at a position.

Parameters ​

ParameterDescription
featurefeature identifier
posposition to place

placeJigsaw ​

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

Place a jigsaw structure from a template pool.

Parameters ​

ParameterDescription
templatePooltemplate pool identifier
startstarting template identifier
depthplacement depth
posstarting position

placeStructure ​

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

Place a structure by identifier at a position.

Parameters ​

ParameterDescription
structurestructure identifier
posposition to place

playSound ​

playSoundCommonFunction
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 the sound to
soundsound identifier
soundSourcesound source category
possound origin position
volumebase volume
pitchplayback pitch
minVolumeminimum audible volume when out of range

randomSample ​

randomSampleCommonFunction
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 random sequence identifier
broadcastwhether to broadcast the result to players
mininclusive minimum value
maxinclusive maximum value

Returns ​

integer or null on invalid range

resetSequence ​

resetSequenceCommonFunction
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 ​

resetSequenceCommonFunction
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 the world seed
includeSequenceIDwhether to include the sequence ID

resetAllSequences ​

resetAllSequencesCommonFunction
kotlin
fun resetAllSequences(level: ServerLevel)

Clear all random sequences for a level.

Parameters ​

ParameterDescription
levelserver level

resetAllSequencesAndSetNewDefaults ​

resetAllSequencesAndSetNewDefaultsCommonFunction
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 use as the new default
includeWorldSeedwhether to include the world seed
includeSequenceIDwhether to include the sequence ID

setTickingRate ​

setTickingRateCommonFunction
kotlin
fun setTickingRate(f: Float)

Set the server ticking rate.

Parameters ​

ParameterDescription
fnew tick rate (ticks per second)

tickQuery ​

tickQueryCommonFunction
kotlin
fun tickQuery(): Float

Query current tickrate.

Returns ​

tick rate value

tickSprint ​

tickSprintCommonFunction
kotlin
fun tickSprint(i: Int)

Request the server to sprint tick advancement by given ticks.

Parameters ​

ParameterDescription
inumber of ticks to sprint

setTickFreeze ​

setTickFreezeCommonFunction
kotlin
fun setTickFreeze(freeze: Boolean)

Freeze or unfreeze server tick processing.

Parameters ​

ParameterDescription
freezetrue to freeze, false to unfreeze

tickStep ​

tickStepCommonFunction
kotlin
fun tickStep(i: Int)

Step the server forward a number of ticks while paused.

Parameters ​

ParameterDescription
inumber of ticks to step

tickStopStepping ​

tickStopSteppingCommonFunction
kotlin
fun tickStopStepping(): Boolean

Stop stepping mode on the tick manager.

Returns ​

if stepping was stopped

tickStopSprinting ​

tickStopSprintingCommonFunction
kotlin
fun tickStopSprinting(): Boolean

Stop sprinting mode on the tick manager.

Returns ​

if sprinting was stopped

getDuration ​

getDurationCommonFunction
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 ​

duration

setClear ​

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

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

Parameters ​

ParameterDescription
iduration in ticks, or -1 to sample

setRain ​

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

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

Parameters ​

ParameterDescription
iduration in ticks, or -1 to sample

setThunder ​

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

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

Parameters ​

ParameterDescription
iduration in ticks, or -1 to sample

setWorldBorderDamageBuffer ​

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

Set the world border safe-zone buffer.

Parameters ​

ParameterDescription
levelserver level whose border to modify
distancesafe distance buffer

setWorldBorderDamageAmount ​

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

Set the world border damage amount per block.

Parameters ​

ParameterDescription
levelserver level
damagedamage per block

setWorldBorderWarningTime ​

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

Set the world border warning time.

Parameters ​

ParameterDescription
levelserver level
timewarning time in seconds

setWorldBorderWarningDistance ​

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

Set world border warning distance in blocks.

Parameters ​

ParameterDescription
levelserver level
distancewarning distance

getWorldBorderSize ​

getWorldBorderSizeCommonFunction
kotlin
fun getWorldBorderSize(level: ServerLevel): Double

Get the current world border size.

Parameters ​

ParameterDescription
levelserver level

Returns ​

border size (double)

setWorldBorderSize ​

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

Set world border size, optionally over time.

Parameters ​

ParameterDescription
levelserver level
sizetarget border size
timeinterpolation time in ticks (0 applies immediately)