Game API

The split is simple: world is everything in the loaded world, local_player is your own player, minecraft is static game data that exists even outside a world.

world — the loaded world

Every function returns nil while no world is loaded.

FunctionWhat it does
world.exists()returns true while a world is loaded
world.player(name)finds a player by name (case doesn't matter), or nil; your own player is local_player.entity()
world.players()returns every player in the world as an array; you are in the list too — check is_self
world.entities([type_id])returns every entity; pass a type id like "minecraft:item" to keep only that type
world.block(x, y, z)returns the block id at that position, like "minecraft:stone"
world.block_state(x, y, z)returns the full block state table at that position
world.raycast(x1, y1, z1, x2, y2, z2, [fluids])casts a ray against blocks between two points; returns a hit table or nil on a miss; pass true to also hit fluids
world.raycast_entity(x1, y1, z1, x2, y2, z2)casts a ray against entities between two points; returns a hit table or nil; your own player is never hit
world.time()returns the world's time of day
world.dimension()returns the dimension id, like "minecraft:overworld"
for _, p in ipairs(world.players() or {}) do
    if not p.is_self and p.distance < 8 then
        client.print_chat(p.name .. " is close!")
    end
end

minecraft — static game data

FunctionWhat it does
minecraft.item(id)returns the item table for one default item, like minecraft.item("minecraft:netherite_sword"), or nil for an unknown id

local_player — your player

Reads and controls the local player in one place. Every function returns nil (or does nothing) while no player exists, so no guards are needed.

FunctionWhat it does
local_player.entity()the full entity table of your player
local_player.position()returns x, y, z
local_player.velocity()returns x, y, z velocity, in blocks per tick
local_player.rotation()returns yaw, pitch
local_player.health()current health
local_player.food()food level (0–20)
local_player.saturation()saturation level
local_player.on_ground()true while standing on the ground
local_player.effects()your active potion effects as an array of {id, amplifier, duration}
local_player.armor()your worn armor as {head, chest, legs, feet} item tables
local_player.raycast([max_distance])casts a ray from your eyes along your view, against blocks and entities; returns a hit table or nil; default distance is 4.5
local_player.exists()true while a local player exists
local_player.set_velocity(x, y, z)sets the velocity directly, in blocks per tick
local_player.jump()jumps, even mid-air
local_player.set_position(x, y, z)teleports client-side to that position
module:event("tick", function()
    if local_player.on_ground() then
        local vx, _, vz = local_player.velocity()
        local_player.set_velocity(vx * 1.1, 0.42, vz * 1.1)
    end
end)

Entity table

Every function that returns an entity (world.player, world.players, world.entities, local_player.entity) gives you a plain table. It is a snapshot: it shows the moment it was created and does not update by itself.

Fields every entity has:

FieldMeaning
id, uuid, name, typeentity id, UUID, display name and type ("minecraft:player")
is_selftrue when this entity is your own player
alive, agewhether it is alive; how many ticks it has existed
posecurrent pose: "standing", "crouching", "swimming", "gliding", "sleeping", ...
x, y, z, eye_yposition; eye_y is the eye height
prev_x/y/z, delta_x/y/zposition on the previous tick and how far it moved this tick
vel_x/y/zcurrent velocity
yaw, pitchwhere the entity is looking
width, heighthitbox size
distancedistance from your player to this entity
on_ground, sneaking, sprinting, swimming, crawlingmovement state
spectator, invisible, glowing, silent, no_gravitystatus flags
on_fire, fire_ticks, fire_immuneburning state
in_water, wet, submerged, in_lavafluid state; wet also counts rain
frozen_ticks, frozenpowder snow freezing
air, max_airremaining air (drowning)
fall_distancehow far it has been falling
vehiclethe id of the entity it rides, or nil
passengersarray of rider entity ids, or nil when empty

Living entities (mobs, players) also have:

FieldMeaning
health, max_health, absorptionhearts, including the yellow absorption ones
armorarmor points (what the armor bar shows)
hurt_time, death_time, deadred-flash ticks after a hit; death animation ticks
baby, scalewhether it is a baby and its size multiplier
body_yaw, head_yawbody and head rotation (the entity's yaw is the head look)
movement_speedmovement speed attribute
blocking, climbing, gliding, sleeping, jumpingaction state; gliding means elytra flight
using_item, using_riptidewhether it is using an item / riptide-spinning
item_use_time, item_use_time_leftticks the current item has been / still needs to be used
held_item, offhand_itemitem tables of the hands
active_itemthe item being used right now (eating, blocking, ...), or nil
equipmentworn armor as {head, chest, legs, feet} item tables
effectsactive potion effects: array of {id, amplifier, duration, infinite, ambient, visible}
attributeseffective attribute values: table of id -> {base, value}, e.g. attributes["minecraft:attack_damage"].value

Players also have ping and gamemode. Your own player additionally has:

FieldMeaning
food, saturationhunger bar and hidden saturation
xp_level, xp_progress, total_xpexperience level, progress to the next level (0..1) and total points
attack_cooldownattack charge 0..1 — 1 means the next hit is full strength
flying, allow_flying, creativeability flags
walk_speed, fly_speedmovement ability speeds

Item table

Describes one item stack. Returned by held_item, equipment, inventory.item, minecraft.item(id) and others.

FieldMeaning
id, name, countitem id ("minecraft:diamond_sword"), display name and stack size
emptytrue for an empty slot
max_count, stackablehow many fit in one stack
rarity"common", "uncommon", "rare" or "epic"
use_actionwhat using it does: "none", "eat", "drink", "block", "bow", "spear", ...
damage, max_damagedurability used so far and the maximum (0 when not damageable)
damageable, damaged, unbreakabledurability flags
enchantedtrue when the item has any enchantment
enchantmentstable of id -> level, e.g. enchantments["minecraft:sharpness"] == 5
custom_namethe anvil-given name, or nil
food{nutrition, saturation, can_always_eat} for eatable items, or nil
tagsarray of item tag ids, like "minecraft:swords"
attribute_modifiersarray of {attribute, id, value, operation, slot} the item applies, or nil

Two methods query the stack's data components directly:

MethodWhat it does
item:has_component(id)true when the stack has the component, e.g. "minecraft:piercing_weapon"
item:component(id)the component decoded to a plain Lua value; true when present but not decodable; nil when absent
local held = local_player.entity().held_item
if held.enchantments["minecraft:sharpness"] then
    client.print_chat(held.name .. " has Sharpness")
end
if held:has_component("minecraft:piercing_weapon") then
    local weapon = held:component("minecraft:piercing_weapon")
    client.print_chat(held.name .. " dismounts: " .. tostring(weapon.dismounts))
end

Block state table

Returned by world.block_state(x, y, z). Describes the exact block at a position, including its state properties.

FieldMeaning
id, nameblock id ("minecraft:chest") and display name
x, y, zthe queried block position (floored)
air, liquid, solid, replaceablebasic kind flags; replaceable means placing over it works (grass, water, ...)
burnablefire can consume it
tool_requireddrops only when mined with the right tool
opaque, full_cube, has_collisionshape flags
has_block_entityhas extra data like a chest or furnace
random_ticksreceives random ticks (crops grow, ice melts, ...)
emits_redstoneemits redstone power
piston_behavior"normal", "destroy", "block", "push_only", ...
hardness, blast_resistancemining and explosion resistance
slipperinessice-like sliding (0.6 is normal, 0.98 is ice)
velocity_multiplier, jump_velocity_multipliermovement slowdown on/in the block (soul sand, honey)
luminancelight it emits, 0–15
opacityhow much light it blocks
map_colorthe color it has on maps, as a number
propertiestable of state properties as strings, e.g. properties.facing == "north", properties.lit == "true"
fluid{id, level, still} when the block contains a fluid, or nil
tagsarray of block tag ids, like "minecraft:mineable/pickaxe"
local b = world.block_state(x, y, z)
if b and b.properties.lit == "true" then
    client.print_chat(b.name .. " is lit")
end

Raycast hit table

Returned by world.raycast, world.raycast_entity and local_player.raycast. Check type to see what was hit — local_player.raycast can return either kind.

Every hit has:

FieldMeaning
type"block" or "entity"
x, y, zthe exact point the ray hit
distancedistance from the ray start to the hit point

Block hits (type == "block") add:

FieldMeaning
block_x, block_y, block_zthe position of the hit block
sidethe hit face: "up", "down", "north", "south", "east", "west"
insidetrue when the ray started inside the block
statethe full block state table of the hit block

Entity hits (type == "entity") add:

FieldMeaning
entitythe entity table of the hit entity
local hit = local_player.raycast(20)
if hit then
    if hit.type == "entity" then
        client.print_chat("looking at " .. hit.entity.name)
    else
        client.print_chat("looking at " .. hit.state.name .. " (" .. hit.side .. ")")
    end
end

client — client & chat

FunctionWhat it does
client.fps()returns the current FPS
client.ping()returns your ping in milliseconds
client.server()returns the server address, or nil in singleplayer
client.has_screen()returns true while any screen (inventory, chat, menu) is open
client.millis()returns the current time in milliseconds
client.tick_delta()returns the progress between two ticks (0..1) — useful for smooth movement
client.say_chat(text)sends text to the server chat; a leading / sends it as a command
client.command(cmd)sends a command to the server (the leading / is optional)
client.print_chat(text)shows a message in your chat only — nothing is sent to the server
client.key_down(code)returns true while a key is held down (GLFW key code, e.g. 32 is space)

print(...) — the standard Lua print, shown in your chat with the [lua] prefix.

aesthetic

FunctionWhat it does
aesthetic.log(msg)writes a line to the game log file
aesthetic.scriptthe file name of the current script

Standard libraries

math, string, table, bit32, coroutine, a limited os (os.time, os.clock, os.date) and require (see Getting Started) are available.