Skip to main content

API Reference

Use this reference with Carpet 1.0-beta.2 and Rhino. The tables describe commonly used signatures. Related functions appear by name so you can find them by namespace.

NamespaceUse
mc.worldBlocks, positions, tags, scans, and world state
mc.entitiesPlayers, entity lookup, properties, and spawning
mc.inventoryItems, containers, slots, recipes, and screens
mc.server, mc.tasks, mc.utilCommands, dimensions, scheduling, NBT, and utilities
mc.scoreboardObjectives, scores, teams, and boss bars
mc.eventsEvent callbacks, cancellation, and entity event examples

Calling convention​

A function such as mc.entities.player("all") can also be available as mc.player("all") and player("all"). Use the grouped name in shared code to make the source explicit. Tables use [argument] for an optional argument and ...args for additional arguments.

ValueJavaScript representation
Boolean, number, or stringThe corresponding JavaScript primitive.
ListA JavaScript array. Coordinates are often returned as [x, y, z].
String-keyed mapA plain JavaScript object. Use it for configuration or block-state properties.
Missing valueUsually null. Check it before accessing a result.
Entity, block, NBT, screen, or taskA Carpet handle. Pass it back to the corresponding API. Handles expose .type and support String(handle).
const players = mc.entities.player("all");
const names = players.map(player => mc.entities.query(player, "name"));
console.log(names.join(", "));

When an API evaluates code later or in a different context, pass a function. For example, mc.server.in_dimension("minecraft:the_nether", () => mc.world.block(0, 64, 0)) performs the lookup in the Nether. Calling block(...) before passing it would read the current dimension.

Runtime limits​

Scripts can access the Minecraft functions exposed by Carpet. Rhino does not expose arbitrary Java classes. Carpet limits JavaScript execution and rejects circular or deeply nested data passed across the API. Split large edits into bounded batches with scheduled callbacks.