Cooldown

A key used by all cooldown functions in net.silkmc.silk.game.cooldown for storing cooldowns.#

Parameters

defaultLength

The cooldown length in milliseconds which is used if no other length has been given to the cooldown functions. This defaults to 50ms = 1 tick.

Constructors

Link copied to clipboard
constructor(defaultLength: Long = 50)
constructor(id: ResourceLocation, defaultLength: Long = 50)

Properties

Link copied to clipboard
Link copied to clipboard
val key: String

Functions

Link copied to clipboard
fun applyCooldown(entity: Entity, delay: Long = defaultLength)

Applies this cooldown to the given entity. After the given delay, the cooldown will be removed automatically.

Link copied to clipboard
fun hasCooldown(entity: Entity): Boolean

Checks if this entity currently has the given cooldown (specified by key).

Link copied to clipboard
inline fun <R> withCooldown(entity: Entity, delay: Long = defaultLength, block: () -> R): R?

Executes the given block if the entity currently does not have this cooldown. If the block is executed, this function will call applyCooldown. After the given delay, the cooldown will be removed automatically.