World
A global API dedicated to reading information from the Minecraft world.
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()
.
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:
Type | Description |
---|---|
Boolean | - |
Example:
world.exists()
getBiome()
Gets the Biome located at the given position
- Overload 1
- Overload 2
getBiome(pos)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos | Vector3 | The position in the world to get the biome of | Required |
Returns:
Type | Description |
---|---|
Biome | Biome of the given position |
getBiome(x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Number | The x world position in the world to get the biome of | Required |
y | Number | The y world position in the world to get the biome of | Required |
z | Number | The z world position in the world to get the biome of | Required |
Returns:
Type | Description |
---|---|
Biome | Biome 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:
Type | Description |
---|---|
Integer | Minimum build height |
Integer | Maximum build height |
Example:
local min, max = world.getBuildHeight()
getDimension()
Gets the dimension name of this world
getDimension()
Returns:
Type | Description |
---|---|
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
- Overload 1
- Overload 2
Example:
world.getHeight(player:getPos().xz)
getSpawnPoint()
Returns a vector with the coordinates of the world spawn
getSpawnPoint()
Returns:
Type | Description |
---|---|
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()
- Overload 1
- Overload 2
Example:
world.isChunkLoaded(player:getPos())
isOpenSky()
Gets whether or not the sky is open at the given position
- Overload 1
- Overload 2
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
- Overload 1
- Overload 2
getBlockState(pos)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos | Vector3 | The position of a block in the world to get the BlockState of | Required |
Returns:
Type | Description |
---|---|
BlockState | BlockState of the given position |
getBlockState(x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Number | The x position of a block in the world to get the BlockState of | Required |
y | Number | The y position of a block in the world to get the BlockState of | Required |
z | Number | The z position of a block in the world to get the BlockState of | Required |
Returns:
Type | Description |
---|---|
BlockState | BlockState 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
- Overload 1
- Overload 2
- Overload 3
- Overload 4
getBlocks(min, max)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min | Vector3 | - | - |
max | Vector3 | - | - |
Returns:
Type | Description |
---|---|
Table | - |
getBlocks(minX, minY, minZ, max)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
minX | Number | - | - |
minY | Number | - | - |
minZ | Number | - | - |
max | Vector3 | - | - |
Returns:
Type | Description |
---|---|
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
- Overload 1
- Overload 2
- Overload 3
newBlock(block, pos)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block | String | - | - |
pos | Vector3 | - | - |
Returns:
Type | Description |
---|---|
BlockState | - |
newBlock(block, x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block | String | - | - |
x | Number | - | - |
y | Number | - | - |
z | Number | - | - |
Returns:
Type | Description |
---|---|
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
- Overload 1
- Overload 2
- Overload 3
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:
Type | Description |
---|---|
Table | - |
Example:
world.avatarVars()
getEntity()
Returns an EntityAPI object from this UUID's entity, or nil if no entity was found
getEntity(UUID)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
UUID | String | - | - |
Returns:
Type | Description |
---|---|
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:
Type | Description |
---|---|
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
- Overload 1
- Overload 2
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
- Overload 1
- Overload 2
Example:
world.getDayTime()
getMoonPhase()
Gets the current moon phase of the world, stored as an integer
getMoonPhase()
Returns:
Type | Description |
---|---|
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
- Overload 1
- Overload 2
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
- Overload 1
- Overload 2
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.
- Overload 1
- Overload 2
getBlockLightLevel(pos)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos | Vector3 | The position in the world to get the block light level of | Required |
Returns:
Type | Description |
---|---|
Integer | The light level (0-15) |
getBlockLightLevel(x, y, z)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x | Number | The x position in the world to get the block light level of | Required |
y | Number | The y position in the world to get the block light level of | Required |
z | Number | The z position in the world to get the block light level of | Required |
Returns:
Type | Description |
---|---|
Integer | The light level (0-15) |
Example:
world.getBlockLightLevel(player:getPos())
getLightLevel()
Gets the overall light level of the block at the given position
- Overload 1
- Overload 2
Example:
world.getLightLevel(player:getPos())
getSkyLightLevel()
Gets the skylight level of the block at the given position
- Overload 1
- Overload 2
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
- Overload 1
- Overload 2
Example:
world.getRainGradient()
isThundering()
Gets whether or not there is currently thunder/lightning happening in the world
isThundering()
Returns:
Type | Description |
---|---|
Boolean | - |
Example:
world.isThundering()
Redstone
getRedstonePower()
Gets the redstone power level of the block at the given position
- Overload 1
- Overload 2
Example:
world.getRedstonePower(player:getPos())
getStrongRedstonePower()
Gets the direct redstone power level of the block at the given position
- Overload 1
- Overload 2
Example:
world.getStrongRedstonePower(player:getPos())