Skip to main content

World

A global API dedicated to reading information from the Minecraft world.

warning

This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.

The world API is accessed through the world global. Like so: world.getTime().

info

The functions in the World API never receive self as a parameter. Because of this they should be called with a . instead of :

world:getBlockState(player:getPos())

world.getBlockState(player:getPos())

Enviroment

exists()

Checks whether or not a world currently exists

This will almost always be true, but might be false on some occasions such as while traveling between dimensions

exists()

Returns:

TypeDescription
Boolean-

Example:

world.exists()

getBiome()

Gets the Biome located at the given position

getBiome(pos)

Parameters:

NameTypeDescriptionDefault
posVector3The position in the world to get the biome ofRequired

Returns:

TypeDescription
BiomeBiome of the given position

Example:

world.getBiome(player:getPos())

getBuildHeight()

Returns the minimum and maximum build height of the world, as multiple results

getBuildHeight()

Returns:

TypeDescription
IntegerMinimum build height
IntegerMaximum build height

Example:

local min, max = world.getBuildHeight()

getDimension()

Gets the dimension name of this world

getDimension()

Returns:

TypeDescription
String-

Example:

world.getDimension()

getHeight()

Returns the highest point at the given position according to the provided heightmap

Defaults to MOTION_BLOCKING if no heightmap is provided

getHeight(pos, heightmap)

Parameters:

NameTypeDescriptionDefault
posVector2--
heightmapString--

Returns:

TypeDescription
Integer-

Example:

world.getHeight(player:getPos().xz)

getSpawnPoint()

Returns a vector with the coordinates of the world spawn

getSpawnPoint()

Returns:

TypeDescription
Vector3-

Example:

world.getSpawnPoint()

isChunkLoaded()

Checks if the position has a chunk loaded

If you need to access the block, it's usually more efficient to use getBlockState()

isChunkLoaded(pos)

Parameters:

NameTypeDescriptionDefault
posVector3--

Returns:

TypeDescription
Boolean-

Example:

world.isChunkLoaded(player:getPos())

isOpenSky()

Gets whether or not the sky is open at the given position

isOpenSky(pos)

Parameters:

NameTypeDescriptionDefault
posVector3--

Returns:

TypeDescription
Boolean-

Example:

world.isOpenSky(player:getPos())

Blocks and Items

getBlockState()

Gets the BlockState of the block at the given position

If it is not loaded, returns void_air

getBlockState(pos)

Parameters:

NameTypeDescriptionDefault
posVector3The position of a block in the world to get the BlockState ofRequired

Returns:

TypeDescription
BlockStateBlockState of the given position

Example:

world.getBlockState(player:getPos())

getBlocks()

Gets a list of all BlockStates in the specified area

The maximum area size is 8 x 8 x 8

getBlocks(min, max)

Parameters:

NameTypeDescriptionDefault
minVector3--
maxVector3--

Returns:

TypeDescription
Table-

Example:

local pos = player:getPos()
local min = pos - vec(4, 4, 4)
local max = pos + vec(4, 4, 4)
local blocks = world.getBlocks(min, max)

newBlock()

Parses and creates a new BlockState from the given string

A world position can be optionally given for the blockstate functions that rely on its position

newBlock(block)

Parameters:

NameTypeDescriptionDefault
blockString--

Returns:

TypeDescription
BlockState-

Example:

world.newBlock("minecraft:dirt")

newItem()

Parses and creates a new ItemStack from the given string

A count and damage can be given, to be applied on this itemstack

newItem(item)

Parameters:

NameTypeDescriptionDefault
itemString--

Returns:

TypeDescription
ItemStack-

Example:

world.newItem("grass_block", 64, 5)

Entities

avatarVars()

Returns a table containing variables stored from all loaded Avatars "avatar:store()" function

The table will be indexed by the avatar's owner UUID

avatarVars()

Returns:

TypeDescription
Table-

Example:

world.avatarVars()

getEntity()

Returns an EntityAPI object from this UUID's entity, or nil if no entity was found

getEntity(UUID)

Parameters:

NameTypeDescriptionDefault
UUIDString--

Returns:

TypeDescription
EntityAPI-

Example:

world.getEntity("5003b2ce-7a8d-4c56-8b91-ec705985fe08")

getPlayers()

Returns a table containing instances of Player for all players in the world

The players are indexed by their names

getPlayers()

Returns:

TypeDescription
Table-

Example:

for _, value in pairs(world.getPlayers()) do
log(value)
end

Time

getDay()

Gets the current day

If delta is passed in, then it adds delta to the time

The default value of delta is zero

getDay()

Returns:

TypeDescription
Number-

Example:

world.getDay()

getDayTime()

Gets the time of the current day between 0 and 24000

If delta is passed in, then it adds delta to the time

The default value of delta is zero

getDayTime()

Returns:

TypeDescription
Number-

Example:

world.getDayTime()

getMoonPhase()

Gets the current moon phase of the world, stored as an integer

getMoonPhase()

Returns:

TypeDescription
Integer-

Example:

world.getMoonPhase()

getTime()

Gets the current game time of the world

If delta is passed in, then it adds delta to the time

The default value of delta is zero

getTime()

Returns:

TypeDescription
Number-

Example:

world.getTime()

getTimeOfDay()

Gets the current day time of the world

If delta is passed in, then it adds delta to the time

The default value of delta is zero

getTimeOfDay()

Returns:

TypeDescription
Number-

Example:

world.getTimeOfDay()

Light

getBlockLightLevel()

Gets the block light level of the block at the given position. Read more about block light on the Minecraft Wiki.

getBlockLightLevel(pos)

Parameters:

NameTypeDescriptionDefault
posVector3The position in the world to get the block light level ofRequired

Returns:

TypeDescription
IntegerThe light level (0-15)

Example:

world.getBlockLightLevel(player:getPos())

getLightLevel()

Gets the overall light level of the block at the given position

getLightLevel(pos)

Parameters:

NameTypeDescriptionDefault
posVector3--

Returns:

TypeDescription
Integer-

Example:

world.getLightLevel(player:getPos())

getSkyLightLevel()

Gets the skylight level of the block at the given position

getSkyLightLevel(pos)

Parameters:

NameTypeDescriptionDefault
posVector3--

Returns:

TypeDescription
Integer-

Example:

world.getSkyLightLevel(player:getPos())

Weather

getRainGradient()

Gets the current rain gradient in the world, interpolated from the previous tick to the current one

The default value of delta is 1, which is the current tick

getRainGradient()

Returns:

TypeDescription
Number-

Example:

world.getRainGradient()

isThundering()

Gets whether or not there is currently thunder/lightning happening in the world

isThundering()

Returns:

TypeDescription
Boolean-

Example:

world.isThundering()

Redstone

getRedstonePower()

Gets the redstone power level of the block at the given position

getRedstonePower(pos)

Parameters:

NameTypeDescriptionDefault
posVector3--

Returns:

TypeDescription
Integer-

Example:

world.getRedstonePower(player:getPos())

getStrongRedstonePower()

Gets the direct redstone power level of the block at the given position

getStrongRedstonePower(pos)

Parameters:

NameTypeDescriptionDefault
posVector3--

Returns:

TypeDescription
Integer-

Example:

world.getStrongRedstonePower(player:getPos())