Docs » API reference » Block

Block

One block in the world: what it is and where.

Plain data, copied between the server and the plugin. You get one from world.block(at), and events.

Fields

FieldDescription
at: BlockPosBlockPos at()Where it is.
r#type: BlockTypeBlockType type()What it is.
sky_light: i64long skyLight()Daylight reaching it, 0 to 15.
block_light: i64long blockLight()Light from torches, lava and lamps, 0 to 15.
paint: Option<Paint>Optional<Paint> paint()A blank block's paint, if it is painted ([World.paint_block]).

BlockType

A kind of block.

A handle to something in the game. Once that thing is gone, its calls fail with Gone.

MethodDescription
fn id(&self) -> Result<i64>long id()Its lasting number.
fn name(&self) -> Result<String>String name()Its name.
fn solid(&self) -> Result<bool>boolean solid()Whether bodies stand on it and cannot pass.
fn liquid(&self) -> Result<bool>boolean liquid()Water or lava.
fn light(&self) -> Result<i64>long light()Light it gives, 0 to 15.
fn hardness(&self) -> Result<f64>double hardness()Seconds to break it by hand.
fn item(&self) -> Result<Option<ItemType>>Optional<ItemType> item()The item it is as carried.
fn named(name: &str) -> Result<Option<BlockType>>static Optional<BlockType> named(String name)A block by its name (any case).
fn by_id(id: i64) -> Result<Option<BlockType>>static Optional<BlockType> byId(long id)A block by its number.
fn air() -> Result<BlockType>static BlockType air()Air: nothing.

Paint

A blank block's paint (BLANK BLOCK, BLANK SLAB, BLANK STAIRS): a colour, and the block whose texture it shows. Painted blocks cost nothing more to draw than any block.

Plain data, copied between the server and the plugin.

FieldDescription
colour: ColourColour colour()Its colour, kept to 32 steps a part (each part's three lowest bits are dropped).
surface: Option<BlockType>Optional<BlockType> surface()The block whose texture it shows (a plain opaque full block: not an ore, log, leaves, glass, ice, a slab or a stair); none for the blank's own plain surface. Blank slabs and stairs show planks, stone bricks or bricks as they are, and every other surface plain.

Events

Related events: BlockBreaking, BlockBroken, BlockPlacing, BlockPlaced, BlockChanged.