Skip to content

API reference / @jsprismarine/prismarine / world/BlockMining

world/BlockMining ​

Interfaces ​

BlockMining ​

Defined in: packages/prismarine/src/world/BlockMining.ts:13

A block a player is mining, and what its crack animation needs each tick.

Kept on the player between the action that starts the mining and the one that ends it, because a server with server-authoritative block breaking animates the cracks itself, every tick, rather than waiting for the client to report each swing.

Properties ​

breakTicks ​

readonly breakTicks: number

Defined in: packages/prismarine/src/world/BlockMining.ts:23

How many ticks the break takes for the tool in hand; infinite for an unbreakable block.

face ​

readonly face: number

Defined in: packages/prismarine/src/world/BlockMining.ts:17

The face being mined, 0 to 5 as the protocol numbers faces.

position ​

readonly position: Vector3

Defined in: packages/prismarine/src/world/BlockMining.ts:15

The block, in block coordinates.

progressPerTick ​

readonly progressPerTick: number

Defined in: packages/prismarine/src/world/BlockMining.ts:21

How much of the 65535 a full break takes one tick is worth.

runtimeId ​

readonly runtimeId: number

Defined in: packages/prismarine/src/world/BlockMining.ts:19

The block's runtime id, which the client textures the particles with.

serverBreaks? ​

readonly optional serverBreaks?: true

Defined in: packages/prismarine/src/world/BlockMining.ts:36

Set when the server breaks the block once its time is up, for a client that never reports the break, such as a Java client mining a borrowed block state.

startedAt ​

readonly startedAt: number

Defined in: packages/prismarine/src/world/BlockMining.ts:25

The server tick the player began mining this block on.

startedAtInput? ​

readonly optional startedAtInput?: number

Defined in: packages/prismarine/src/world/BlockMining.ts:31

How many inputs the client had sent when it began mining this block, which counts the client's own ticks: see PlayerSession.handledInputs. Absent for mining begun without a client to count, such as mining saved before the field existed.

Variables ​

MINING_LATENCY_TICKS ​

const MINING_LATENCY_TICKS: 5 = 5

Defined in: packages/prismarine/src/world/BlockMining.ts:110

How many ticks early a predicted break may arrive. Network jitter can delay the start of mining more than the prediction that ends it, which makes the break look shorter on the server than it was on the client.

Functions ​

blockMiningOf() ​

The mining a player's component keeps, or its absence, as the world animates it.

Param ​

mining

The logged plain data, or null when nothing is mined.

Call Signature ​

blockMiningOf(mining): BlockMining

Defined in: packages/prismarine/src/world/BlockMining.ts:78

The mining a player's component keeps, as the world animates it.

Parameters ​
mining ​

PlayerMining

The logged plain data.

Returns ​

BlockMining

The same block, with its position as a vector.

Call Signature ​

blockMiningOf(mining): BlockMining | null

Defined in: packages/prismarine/src/world/BlockMining.ts:84

The mining a player's component keeps, or its absence, as the world animates it.

Parameters ​
mining ​

PlayerMining | null

The logged plain data, or null when nothing is mined.

Returns ​

BlockMining | null

The same block, with its position as a vector, or null for null.


hastenedBreakTicks() ​

hastenedBreakTicks(mining, effects): number

Defined in: packages/prismarine/src/world/BlockMining.ts:124

How many ticks a break takes the player: the server's break time for the tool in hand, sped up by the miner's strongest haste or conduit power level. Mining fatigue, water and being off the ground only slow a break down, and are left out, so this is never longer than the real break.

Parameters ​

mining ​

Pick<BlockMining, "breakTicks">

What the player is mining.

effects ​

readonly Pick<StatusEffect, "id" | "amplifier">[]

The miner's status effects.

Returns ​

number

The ticks; infinite for a block that never breaks.


minimumBreakTicks() ​

minimumBreakTicks(mining, effects): number

Defined in: packages/prismarine/src/world/BlockMining.ts:146

The fewest ticks a break may have taken before the server accepts a client's prediction that the block gave way: hastenedBreakTicks, with MINING_LATENCY_TICKS off as slack.

Parameters ​

mining ​

Pick<BlockMining, "breakTicks">

What the player is mining.

effects ​

readonly Pick<StatusEffect, "id" | "amplifier">[]

The miner's status effects.

Returns ​

number

The minimum ticks; infinite for a block that never breaks.


playerMiningOf() ​

A player's mining, or its absence, as the logged plain data its component keeps.

Param ​

mining

What the player is mining, or null when nothing.

Call Signature ​

playerMiningOf(mining): PlayerMining

Defined in: packages/prismarine/src/world/BlockMining.ts:44

A player's mining as the logged plain data its component keeps.

Parameters ​
mining ​

BlockMining

What the player is mining.

Returns ​

PlayerMining

The same block as plain data.

Call Signature ​

playerMiningOf(mining): PlayerMining | null

Defined in: packages/prismarine/src/world/BlockMining.ts:50

A player's mining, or its absence, as the logged plain data its component keeps.

Parameters ​
mining ​

BlockMining | null

What the player is mining, or null when nothing.

Returns ​

PlayerMining | null

The same block as plain data, or null for null.