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.
| Namespace | Use |
|---|---|
mc.world | Blocks, positions, tags, scans, and world state |
mc.entities | Players, entity lookup, properties, and spawning |
mc.inventory | Items, containers, slots, recipes, and screens |
mc.server, mc.tasks, mc.util | Commands, dimensions, scheduling, NBT, and utilities |
mc.scoreboard | Objectives, scores, teams, and boss bars |
mc.events | Event 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.
| Value | JavaScript representation |
|---|---|
| Boolean, number, or string | The corresponding JavaScript primitive. |
| List | A JavaScript array. Coordinates are often returned as [x, y, z]. |
| String-keyed map | A plain JavaScript object. Use it for configuration or block-state properties. |
| Missing value | Usually null. Check it before accessing a result. |
| Entity, block, NBT, screen, or task | A 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.