Skip to content

API reference / @jsprismarine/prismarine / BlockView

Class: BlockView ​

Defined in: prismarine/src/entity/ai/BlockView.ts:114

Constructors ​

Constructor ​

new BlockView(world): BlockView

Defined in: prismarine/src/entity/ai/BlockView.ts:115

Parameters ​

world ​

World

Returns ​

BlockView

Methods ​

blocksBox() ​

blocksBox(x, feet, z, width, height): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:230

Whether a body of this size, standing here, runs into anything.

The continuous form, in world coordinates, and the one the physics asks: every cell the box reaches into is tested against the part of it the block actually fills, so a mob may stand with its feet inside a carpet and its head under a fence rail without either counting.

Parameters ​

x ​

number

Center of the box.

feet ​

number

The bottom of the box, which is where an entity's position is.

z ​

number

Center of the box.

width ​

number

Blocks across.

height ​

number

Blocks tall.

Returns ​

boolean

Whether anything solid overlaps it.


breaksAFall() ​

breaksAFall(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:171

Whether landing in or on this block costs nothing.

Parameters ​

x ​

number

Block x.

y ​

number

Block y.

z ​

number

Block z.

Returns ​

boolean

true for water, hay, cobweb and the rest.


canStandAt() ​

canStandAt(x, y, z, height?, width?): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:354

Whether a mob can stand with its feet in this block: clear space for its body, and something solid holding it up.

Parameters ​

x ​

number

World x.

y ​

number

World y, where the mob's feet would be.

z ​

number

World z.

height? ​

number = 2

How tall the mob is.

width? ​

number = 1

How wide the mob is.

Returns ​

boolean

Whether it could stand there.


floorAt() ​

floorAt(x, z): number | null

Defined in: prismarine/src/entity/ai/BlockView.ts:185

The lowest block this column can hold.

From the chunk rather than from the world's dimension, so that everything a mob needs to know about where it is comes through one reader. Null where nothing is loaded, which the caller should read as "no idea" rather than as "no floor".

Parameters ​

x ​

number

Block x.

z ​

number

Block z.

Returns ​

number | null

The world's floor here, or null if the chunk is not in memory.


groundBelow() ​

groundBelow(x, y, z, limit?, height?, width?): number | null

Defined in: prismarine/src/entity/ai/BlockView.ts:370

The first solid ground at or below a position, or null within limit blocks. Used to drop a spawn or a wander target onto the floor rather than into the air.

Parameters ​

x ​

number

y ​

number

z ​

number

limit? ​

number = 8

height? ​

number = 2

width? ​

number = 1

Returns ​

number | null


groundUnder() ​

groundUnder(x, feet, z, width, reach?): number | null

Defined in: prismarine/src/entity/ai/BlockView.ts:267

The height of the highest surface under a box, or null if there is none within reach.

What a mob lands on, and what tells a step from a wall. Surfaces above the box's feet are ignored: this answers "what is holding it up", not "what is it stuck in".

Parameters ​

x ​

number

Center of the box.

feet ​

number

The bottom of the box, in world coordinates.

z ​

number

Center of the box.

width ​

number

Blocks across.

reach? ​

number = 4

How far down to look, in blocks.

Returns ​

number | null

A world height, not an offset within a cell.


harmAt() ​

harmAt(x, y, z): DamageCause | null

Defined in: prismarine/src/entity/ai/BlockView.ts:160

What standing in this block does to something, if anything.

The pathfinder only needs isHazard; the damage code needs to know which kind, since burning and being pricked are different deaths with different rules about armor.

Parameters ​

x ​

number

Block x.

y ​

number

Block y.

z ​

number

Block z.

Returns ​

DamageCause | null

What it does, or null for a block that is simply a block.


hasRoomAt() ​

hasRoomAt(x, y, z, height?, width?): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:305

Whether a mob's body fits standing in this block, ignoring what is underneath.

The grid form, for the route planner, which works in whole cells. The cell the feet are in may hold something low enough to step onto - that is what STEP_HEIGHT is for - and the body is then measured from the top of it, so a mob on a slab still needs its full height of clearance above the slab rather than above the floor.

Parameters ​

x ​

number

World x of the cell.

y ​

number

World y of the cell the feet are in.

z ​

number

World z of the cell.

height? ​

number = 2

How tall the mob is.

width? ​

number = 1

Blocks across; the box is centered in the cell.

Returns ​

boolean

Whether the body fits.


isHazard() ​

isHazard(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:146

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

boolean


isLiquid() ​

isLiquid(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:142

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

boolean


isLoaded() ​

isLoaded(x, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:213

Whether the chunk holding a position is in memory at all.

Parameters ​

x ​

number

z ​

number

Returns ​

boolean


isPassable() ​

isPassable(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:134

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

boolean


isSolid() ​

isSolid(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:138

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

boolean


isSubmerged() ​

isSubmerged(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:362

The block a mob standing here would be swimming in.

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

boolean


isUnjumpable() ​

isUnjumpable(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:380

Whether something in this cell is too tall to be jumped, whatever a mob does.

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

boolean


seesSky() ​

seesSky(x, y, z): boolean

Defined in: prismarine/src/entity/ai/BlockView.ts:201

Whether nothing but air stands between this block and the sky.

What decides whether the morning kills a zombie. Unloaded reads as open, which is the conservative answer for a spawner - it will not put a monster somewhere the sun may reach - and the forgiving one for burning, since nothing should catch fire on the strength of a chunk nobody has loaded.

Parameters ​

x ​

number

Block x.

y ​

number

The block to look up from; itself not counted.

z ​

number

Block z.

Returns ​

boolean

true if the sky is visible from here.


topAt() ​

topAt(x, y, z): number

Defined in: prismarine/src/entity/ai/BlockView.ts:130

How high the collision surface in this cell sits above the cell's own floor.

Parameters ​

x ​

number

y ​

number

z ​

number

Returns ​

number