world

properties

world.players // a list of `player` values in the game
world.entities // a list of `entity` values in the world (players NOT included, see world.players for those)

methods

world.spawnEntity(type, location)
world.setBlock(location, material)
world.getBlock(location)
world.fillBlocks(from, to, material)
world.playSound(sound, location, volume = 1, pitch = 1)

spawnEntity

world.spawnEntity("zombie", player.location)

type is a case insensitive entity type name, returns an entity value. spawning is capped (500 entities in the world at once), once you hit that cap, further spawn attempts are a runtime error, so wrap spawning in a check if you're doing it a lot:

function spawnWave(count, location) {
    for (i in 1..count) {
        world.spawnEntity("zombie", location)
    }
}

world.entities

for (e in world.entities) {
    if (e.type == "zombie") {
        e.setGlowing(true)
    }
}

every nonplayer entity currently in the world, as a list of entity values. use world.players instead if you want the players

setBlock / getBlock

world.setBlock(player.location, "glass")
val currentBlock = world.getBlock(player.location) // "glass"

material is a case insensitive vanilla block material name (nonblock materials like "diamond_sword" are a runtime error).

fillBlocks

world.fillBlocks({ "x": 0, "y": 60, "z": 0 }, { "x": 10, "y": 65, "z": 10 }, "stone")

fills every block in the box between from and to with material. capped at 4096 blocks total per call, going over that is a runtime error telling you the volume you tried and the cap, so split big fills into chunks:

function fillLargeArea(from, to, material) {
    // split into smaller boxes yourself and call fillBlocks per chunk
}

playSound

world.playSound("entity_wither_spawn", player.location)
world.playSound("entity_wither_spawn", player.location, volume = 2.0, pitch = 0.8)

plays at a fixed location and everyone is able to hear it, rather than player.playSound which plays specifically to one player