Skip to content

API reference / @jsprismarine/prismarine / Block

Class: Block ​

Defined in: prismarine/src/block/Block.ts:112

One block state, as the rest of the server holds one.

A data record rather than a base class: there are no subclasses any more, because the 1477 blocks and their 22079 states come out of the pack stack and their behavior out of @jsprismarine/block-behaviors's 49 families. What a block yields comes from its active minecraft:loot component, or from the mapped Java loot table when it has no component, rather than from a method an author overrode. That is why the 260 classes this replaced were able to go.

Constructors ​

Constructor ​

new Block(__namedParameters): Block

Defined in: prismarine/src/block/Block.ts:122

Parameters ​

__namedParameters ​

BlockProps

Returns ​

Block

Properties ​

name ​

readonly name: string

Defined in: prismarine/src/block/Block.ts:114

The namespaced Bedrock block identifier.


states ​

readonly states: Readonly<Record<string, BlockStateValue>>

Defined in: prismarine/src/block/Block.ts:116

The state values the block carries.

Accessors ​

[toStringTag] ​

Get Signature ​

get [toStringTag](): string

Defined in: prismarine/src/block/Block.ts:130

Returns ​

string

Methods ​

canBePlaced() ​

canBePlaced(): boolean

Defined in: prismarine/src/block/Block.ts:271

Whether the block can be placed at all.

Returns ​

boolean


canBeReplaced() ​

canBeReplaced(): boolean

Defined in: prismarine/src/block/Block.ts:251

Whether the block gives way to a placement rather than blocking it.

The resolved state's minecraft:replaceable component or tag answers for short grass, leaf litter, water, and other blocks a placement goes into instead of on top of. The client makes the same call when it predicts a placement, so a server that answered no for leaf litter put the block above it while the client showed it in the litter's place.

The tag names Java blocks, so the state goes through @jsprismarine/mapping first: Bedrock's snow_layer is Java's snow and its deadbush is Java's dead_bush. A block built without content has no tags to read, and only air gives way.

Snow is in the tag at every depth, but Java's snow layer block overrides it: only a single layer gives way to a placed block. Not yet measured against BDS.

Returns ​

boolean


getBlastResistance() ​

getBlastResistance(): number

Defined in: prismarine/src/block/Block.ts:207

Java's explosion resistance.

Returns ​

number


getBreakTime() ​

getBreakTime(item, _server?): number

Defined in: prismarine/src/block/Block.ts:194

How long, in seconds, the block takes to break.

Hardness on its own is not that time. Vanilla scales it by whether the tool in hand can actually harvest the block - 1.5x when it can, 5x when it cannot, which is why dirt takes 0.75s by hand and stone 7.5s - and then divides by how fast the tool mines. Those two factors are Java's destroyProgress written the other way up: speed / hardness / 30 for a correct tool and / 100 for anything else, in progress per tick.

The divisor is what Efficiency moves: the enchantment is an add_value on minecraft:mining_efficiency, which Java adds to the tool's speed.

Parameters ​

item ​

Item | null

What is in hand, or null for a bare fist.

_server? ​

unknown

Returns ​

number


getDrops() ​

getDrops(item, server?): (Item | Block | null)[]

Defined in: prismarine/src/block/Block.ts:314

What the block yields when it breaks, from its active loot component or its mapped Java loot table.

Silk touch, fortune, the shears branches and gravel's one-in-ten flint are in the table rather than here, so this is a roll rather than a decision tree. A server with no content build has no tables to roll and yields the block itself.

Parameters ​

item ​

Item | null

What broke it, which the table's predicates read.

server? ​

BlockDropServer

The server, for its content and its source of chance.

Returns ​

(Item | Block | null)[]


getFlammability() ​

getFlammability(): number

Defined in: prismarine/src/block/Block.ts:222

Fire's odds of consuming the block once lit.

Returns ​

number


getFriction() ​

getFriction(): number

Defined in: prismarine/src/block/Block.ts:227

Ground friction, which decides how far a player slides across the block.

Returns ​

number


getHardness() ​

getHardness(): number

Defined in: prismarine/src/block/Block.ts:175

Java's destroy time in seconds; -1 marks the unbreakable blocks.

Returns ​

number


getJavaTags() ​

getJavaTags(): readonly string[]

Defined in: prismarine/src/block/Block.ts:158

The Java datapack tags attached to this Bedrock block type.

Returns ​

readonly string[]


getLightFilter() ​

getLightFilter(): number

Defined in: prismarine/src/block/Block.ts:217

How much light the block swallows, 0 to 15.

Returns ​

number


getLightLevel() ​

getLightLevel(): number

Defined in: prismarine/src/block/Block.ts:212

The light the block emits, 0 to 15.

Returns ​

number


getName() ​

getName(): string

Defined in: prismarine/src/block/Block.ts:138

The block's namespaced identifier.

Returns ​

string


getStateName() ​

getStateName(): string

Defined in: prismarine/src/block/Block.ts:143

The vanilla block state to place, which is name unless overridden.

Returns ​

string


getTags() ​

getTags(): readonly string[]

Defined in: prismarine/src/block/Block.ts:148

The Bedrock tags attached to this block state, or an empty list when it has no type.

Returns ​

readonly string[]


hasJavaTag() ​

hasJavaTag(tag): boolean

Defined in: prismarine/src/block/Block.ts:168

Whether a Java datapack tag includes this block type.

Parameters ​

tag ​

string

Returns ​

boolean


hasTag() ​

hasTag(tag): boolean

Defined in: prismarine/src/block/Block.ts:153

Whether this block state carries one of its Bedrock tags.

Parameters ​

tag ​

string

Returns ​

boolean


isBreakable() ​

isBreakable(): boolean

Defined in: prismarine/src/block/Block.ts:276

Whether mining ever removes the block.

Returns ​

boolean


isCompatibleWithTool() ​

isCompatibleWithTool(item, content?): boolean

Defined in: prismarine/src/block/Block.ts:296

Whether what is in hand harvests the block rather than destroying it for nothing.

Java's rule in one line: a block without requires_correct_tool yields to anything, including a bare fist, and one with it yields only to a tool whose minecraft:tool rules say the block is correct for drops.

A server with no content build answers yes either way. Those rules name their blocks by tag - #minecraft:mineable/pickaxe, #minecraft:incorrect_for_stone_tool - and the merged tag set only exists once a pack stack is loaded, so without one no tool could ever read as the right one and nothing needing a tool would drop at all.

Parameters ​

item ​

Item | null

What is in hand, or null for a bare fist.

content? ​

ServerContent | undefined = ...

Returns ​

boolean


isPartOfCreativeInventory() ​

isPartOfCreativeInventory(): boolean

Defined in: prismarine/src/block/Block.ts:330

Whether the creative menu shows the block.

Returns ​

boolean


isSolid() ​

isSolid(): boolean

Defined in: prismarine/src/block/Block.ts:232

Whether anything can stand on the block.

Returns ​

boolean


toString() ​

toString(): string

Defined in: prismarine/src/block/Block.ts:133

Returns ​

string