World and Blocks
Block positions accept [x, y, z] or three separate numbers in common calls. Those numbers are relative to the current script origin, which is [0, 0, 0] for ordinary /script run and app command calls. Many functions also accept a positioned block handle.
Blocks and positions
Call under mc.world | Result |
|---|---|
block(pos) | A handle for the block at the position. String(handle) returns its block ID. |
block("minecraft:oak_log[axis=x]") | A block state without a world position. Use it as a source for set or to query a property. |
block_state(block[, property]) | An object of state properties, a single property value, or null for a missing property. |
block_data(block) | Block entity data as an NBT handle, or null if unavailable. |
pos(blockOrEntity) | Coordinates of a positioned block or an entity. |
pos_offset(pos, direction[, distance]) | Offset position. The default distance is one block. |
set(pos, block[, properties][, nbt]) | Places the given state. Pass properties as an object, for example {axis: "x"}. Returns the placed block handle or false if the edit did not change a block. |
without_updates(callback) | Evaluates a function with Carpet's block update suppression enabled and returns its result. |
function placeTestLog() {
const target = [0, 64, 0];
mc.world.set(target, "minecraft:oak_log", {axis: "x"});
return mc.world.block_state(target, "axis");
}
Tags, scans, and checks
Call under mc.world | Result |
|---|---|
block_list([tag]) | All block IDs, or the members of a block tag. Pass tag IDs without #, such as "minecraft:wool". |
block_tags([block][, tag]) | Lists registered tags or a block's tags. With a block and a tag, tests membership. |
scan(center, range[, upperRange], callback) | Visits an inclusive region around a center and counts truthy callback results. A range is a three-element array of distances. |
volume(from, to, callback) | Visits the inclusive box with the given corners and counts truthy results. |
air(pos), solid(pos), liquid(pos) | Check whether a block is air, solid, or liquid. |
loaded(pos), loaded_status(pos) | Check whether the chunk is loaded, or read its numeric full status. |
top(type, pos) | Reads the heightmap at a column. Types include "surface", "motion", "terrain", and "ocean_floor". |
weather() | Returns "clear", "rain", or "thunder". |
In scan and volume, _ is the current block and _x, _y, _z are its block coordinates. Read them inside the callback.
const airCount = mc.world.scan([0, 64, 0], [2, 1, 2],
() => mc.world.air(_));
console.log(airCount);
Related functions
| Area | Functions |
|---|---|
| Block behavior and light | flammable, transparent, suffocates, blocks_movement, emitted_light, block_light, sky_light, light, effective_light, see_sky, brightness, hardness, blast_resistance, power, block_sound, map_colour |
| Positions and iteration | neighbours, rect, diamond |
| Changes and simulation | destroy, harvest, place_item, update, ticks_randomly, block_tick, random_tick, create_explosion |
| Biomes, points of interest, and chunks | biome, set_biome, poi, set_poi, in_slime_chunk, is_chunk_generated, generation_status, chunk_tickets, add_chunk_ticket, inhabited_time, spawn_potential |
| Structures and noise | structures, structure_references, structure_eligibility, sample_noise |