cWorld


Index:
Articles
Classes
Hooks

Quick navigation:
cArrowEntity
cBeaconEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEntity
cEntityEffect
cExpBottleEntity
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLineBlockTracer
cLuaWindow
cMap
cMapManager
cMobHeadEntity
cMobSpawnerEntity
cMojangAPI
cMonster
cNetwork
cNoteEntity
cObjective
cPainting
cPawn
cPickup
cPlayer
cPlugin
cPluginLua
cPluginManager
cProjectileEntity
cRankManager
cRoot
cScoreboard
cServer
cServerHandle
cSignEntity
cSplashPotionEntity
cStatManager
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cTracer
cUDPEndpoint
cUrlClient
cUrlParser
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
sqlite3
TakeDamageInfo
tolua
Vector3d
Vector3f
Vector3i
Globals

Contents


cWorld class

cWorld is the game world. It is the hub of all the information managed by individual classes, providing convenient access to them. Cuberite supports multiple worlds in any combination of world types. You can have two overworlds, three nethers etc. To enumerate all world the server provides, use the cRoot:ForEachWorld() function.

The world data is held in individual chunks. Each chunk consists of 16 (x) * 16 (z) * 256 (y) blocks, each block is specified by its block type (8-bit) and block metadata (4-bit). Additionally, each block has two light values calculated - skylight (how much daylight it receives) and blocklight (how much light from light-emissive blocks it receives), both 4-bit.

Each world runs several separate threads used for various housekeeping purposes, the most important of those is the Tick thread. This thread updates the game logic 20 times per second, and it is the thread where all the gameplay actions are evaluated. Liquid physics, entity interactions, player ovement etc., all are applied in this thread.

Additional threads include the generation thread (generates new chunks as needed, storage thread (saves and loads chunk from the disk), lighting thread (updates block light values) and the chunksender thread (compresses chunks to send to the clients).

The world provides access to all its players, entities and block entities. Because of multithreading issues, individual objects cannot be retrieved for indefinite handling, but rather must be modified in callbacks, within which they are guaranteed to stay valid.

Physics for individual blocks are handled by the simulators. These will fire in each tick for all blocks that have been scheduled for simulator update ("simulator wakeup"). The simulators include liquid physics, falling blocks, fire spreading and extinguishing and redstone.

Game time is also handled by the world. It provides the time-of-day and the total world age.


Functions

NameParametersReturn valueNotes
AreCommandBlocksEnabled bool Returns whether command blocks are enabled on the (entire) server
BroadcastBlockAction BlockX, BlockY, BlockZ, ActionByte1, ActionByte2, BlockType, [ExcludeClient] Broadcasts the BlockAction packet to all clients who have the appropriate chunk loaded (except ExcludeClient). The contents of the packet are specified by the parameters for the call, the blocktype needn't match the actual block that is present in the world data at the specified location.
BroadcastChat Message, [ExcludeClient], [ChatPrefix] Sends the Message to all players in this world, except the optional ExcludeClient. No formatting is done by the server.
BroadcastChatDeath Message, [ExcludeClient] Prepends Gray [DEATH] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For when a player dies.
BroadcastChatFailure Message, [ExcludeClient] Prepends Rose [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For a command that failed to run because of insufficient permissions, etc.
BroadcastChatFatal Message, [ExcludeClient] Prepends Red [FATAL] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For a plugin that crashed, or similar.
BroadcastChatInfo Message, [ExcludeClient] Prepends Yellow [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For informational messages, such as command usage.
BroadcastChatSuccess Message, [ExcludeClient] Prepends Green [INFO] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For success messages.
BroadcastChatWarning Message, [ExcludeClient] Prepends Rose [WARN] / colours entire text (depending on ShouldUseChatPrefixes()) and broadcasts message. For concerning events, such as plugin reload etc.
BroadcastEntityAnimation TargetEntity, Animation, [ExcludeClient] Sends an animation of an entity to all clienthandles (except ExcludeClient if given)
BroadcastParticleEffect ParticleName, X, Y, Z, OffSetX, OffSetY, OffSetZ, ParticleData, ParticleAmount, [ExcludeClient] Spawns the specified particles to all players in the world exept the optional ExeptClient. A list of available particles by thinkofdeath can be found Here
BroadcastSoundEffect SoundName, X, Y, Z, Volume, Pitch, [ExcludeClient] Sends the specified sound effect to all players in this world, except the optional ExceptClient
BroadcastSoundParticleEffect EffectID, X, Y, Z, EffectData, [ExcludeClient] Sends the specified effect to all players in this world, except the optional ExceptClient
CastThunderbolt X, Y, Z Creates a thunderbolt at the specified coords
ChangeWeather Forces the weather to change in the next game tick. Weather is changed according to the normal rules: wSunny <-> wRain <-> wStorm
ChunkStay ChunkCoordTable, OnChunkAvailable, OnAllChunksAvailable Queues the specified chunks to be loaded or generated and calls the specified callbacks once they are loaded. ChunkCoordTable is an arra-table of chunk coords, each coord being a table of 2 numbers: { {Chunk1x, Chunk1z}, {Chunk2x, Chunk2z}, ...}. When any of those chunks are made available (including being available at the start of this call), the OnChunkAvailable() callback is called. When all the chunks are available, the OnAllChunksAvailable() callback is called. The function signatures are:
function OnChunkAvailable(ChunkX, ChunkZ)
function OnAllChunksAvailable()
All return values from the callbacks are ignored.
CreateProjectile X, Y, Z, ProjectileKind, Creator, Originating Item, [Speed] Creates a new projectile of the specified kind at the specified coords. The projectile's creator is set to Creator (may be nil). The item that created the projectile entity, commonly the player's currently equipped item, is used at present for fireworks to correctly set their entity metadata. It is not used for any other projectile. Optional speed indicates the initial speed for the projectile.
DigBlock X, Y, Z Replaces the specified block with air, without dropping the usual pickups for the block. Wakes up the simulators for the block and its neighbors.
DoExplosionAt Force, X, Y, Z, CanCauseFire, Source, SourceData Creates an explosion of the specified relative force in the specified position. If CanCauseFire is set, the explosion will set blocks on fire, too. The Source parameter specifies the source of the explosion, one of the esXXX constants. The SourceData parameter is specific to each source type, usually it provides more info about the source.
DoWithBeaconAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a beacon at the specified coords, calls the CallbackFunction with the cBeaconEntity parameter representing the beacon. The CallbackFunction has the following signature:
function Callback(BeaconEntity)
The function returns false if there is no beacon, or if there is, it returns the bool value that the callback has returned.
DoWithBlockEntityAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a block entity at the specified coords, calls the CallbackFunction with the cBlockEntity parameter representing the block entity. The CallbackFunction has the following signature:
function Callback(BlockEntity)
The function returns false if there is no block entity, or if there is, it returns the bool value that the callback has returned. Use tolua.cast() to cast the Callback's BlockEntity parameter to the correct cBlockEntity descendant.
DoWithBrewingstandAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a brewingstand at the specified coords, calls the CallbackFunction with the cBrewingstandEntity parameter representing the brewingstand. The CallbackFunction has the following signature:
function Callback(cBrewingstandEntity)
The function returns false if there is no brewingstand, or if there is, it returns the bool value that the callback has returned.
DoWithChestAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a chest at the specified coords, calls the CallbackFunction with the cChestEntity parameter representing the chest. The CallbackFunction has the following signature:
function Callback(ChestEntity)
The function returns false if there is no chest, or if there is, it returns the bool value that the callback has returned.
DoWithCommandBlockAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a command block at the specified coords, calls the CallbackFunction with the cCommandBlockEntity parameter representing the command block. The CallbackFunction has the following signature:
function Callback(CommandBlockEntity)
The function returns false if there is no command block, or if there is, it returns the bool value that the callback has returned.
DoWithDispenserAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a dispenser at the specified coords, calls the CallbackFunction with the cDispenserEntity parameter representing the dispenser. The CallbackFunction has the following signature:
function Callback(DispenserEntity)
The function returns false if there is no dispenser, or if there is, it returns the bool value that the callback has returned.
DoWithDropSpenserAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a dropper or a dispenser at the specified coords, calls the CallbackFunction with the cDropSpenserEntity parameter representing the dropper or dispenser. The CallbackFunction has the following signature:
function Callback(DropSpenserEntity)
Note that this can be used to access both dispensers and droppers in a similar way. The function returns false if there is neither dispenser nor dropper, or if there is, it returns the bool value that the callback has returned.
DoWithDropperAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a dropper at the specified coords, calls the CallbackFunction with the cDropperEntity parameter representing the dropper. The CallbackFunction has the following signature:
function Callback(DropperEntity)
The function returns false if there is no dropper, or if there is, it returns the bool value that the callback has returned.
DoWithEntityByID EntityID, CallbackFunction bool If an entity with the specified ID exists, calls the callback with the cEntity parameter representing the entity. The CallbackFunction has the following signature:
function Callback(Entity)
The function returns false if the entity was not found, and it returns the same bool value that the callback has returned if the entity was found.
DoWithFlowerPotAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a flower pot at the specified coords, calls the CallbackFunction with the cFlowerPotEntity parameter representing the flower pot. The CallbackFunction has the following signature:
function Callback(FlowerPotEntity)
The function returns false if there is no flower pot, or if there is, it returns the bool value that the callback has returned.
DoWithFurnaceAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a furnace at the specified coords, calls the CallbackFunction with the cFurnaceEntity parameter representing the furnace. The CallbackFunction has the following signature:
function Callback(FurnaceEntity)
The function returns false if there is no furnace, or if there is, it returns the bool value that the callback has returned.
DoWithMobHeadAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a mob head at the specified coords, calls the CallbackFunction with the cMobHeadEntity parameter representing the furnace. The CallbackFunction has the following signature:
function Callback(MobHeadEntity)
The function returns false if there is no mob head, or if there is, it returns the bool value that the callback has returned.
DoWithNoteBlockAt BlockX, BlockY, BlockZ, CallbackFunction bool If there is a note block at the specified coords, calls the CallbackFunction with the cNoteEntity parameter representing the note block. The CallbackFunction has the following signature:
function Callback(NoteEntity)
The function returns false if there is no note block, or if there is, it returns the bool value that the callback has returned.
DoWithPlayer PlayerName, CallbackFunction bool If there is a player of the specified name (exact match), calls the CallbackFunction with the cPlayer parameter representing the player. The CallbackFunction has the following signature:
function Callback(Player)
The function returns false if the player was not found, or whatever bool value the callback returned if the player was found.
DoWithPlayerByUUID PlayerUUID, CallbackFunction bool If there is the player with the uuid, calls the CallbackFunction with the cPlayer parameter representing the player. The CallbackFunction has the following signature:
function Callback(Player)
The function returns false if the player was not found, or whatever bool value the callback returned if the player was found.
FastSetBlock BlockX, BlockY, BlockZ, BlockType, BlockMeta Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!
FastSetBlock BlockCoords, BlockType, BlockMeta Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!
FindAndDoWithPlayer PlayerName, CallbackFunction bool Calls the given callback function for the player with the name best matching the name string provided.
This function is case-insensitive and will match partial names.
Returns false if player not found or there is ambiguity, true otherwise. The CallbackFunction has the following signature:
function Callback(Player)
ForEachBlockEntityInChunk ChunkX, ChunkZ, CallbackFunction bool Calls the specified callback for each block entity in the chunk. Returns true if all block entities in the chunk have been processed (including when there are zero block entities), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
function Callback(BlockEntity)
The callback should return false or no value to continue with the next block entity, or true to abort the enumeration. Use tolua.cast() to cast the Callback's BlockEntity parameter to the correct cBlockEntity descendant.
ForEachBrewingstandInChunk ChunkX, ChunkZ, CallbackFunction bool Calls the specified callback for each brewingstand in the chunk. Returns true if all brewingstands in the chunk have been processed (including when there are zero brewingstands), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
function Callback(cBrewingstandEntity)
The callback should return false or no value to continue with the next brewingstand, or true to abort the enumeration.
ForEachChestInChunk ChunkX, ChunkZ, CallbackFunction bool Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
function Callback(ChestEntity)
The callback should return false or no value to continue with the next chest, or true to abort the enumeration.
ForEachEntity CallbackFunction bool Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
function Callback(Entity)
The callback should return false or no value to continue with the next entity, or true to abort the enumeration.
ForEachEntityInBox Box, CallbackFunction bool Calls the specified callback for each entity in the specified bounding box. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. If any chunk within the bounding box is not valid, it is silently skipped without any notification. The callback function has the following signature:
function Callback(Entity)
The callback should return false or no value to continue with the next entity, or true to abort the enumeration.
ForEachEntityInChunk ChunkX, ChunkZ, CallbackFunction bool Calls the specified callback for each entity in the specified chunk. Returns true if all the entities have been processed (including when there are zero entities), or false if the chunk is not loaded or the callback function has aborted the enumeration by returning true. The callback function has the following signature:
function Callback(Entity)
The callback should return false or no value to continue with the next entity, or true to abort the enumeration.
ForEachFurnaceInChunk ChunkX, ChunkZ, CallbackFunction bool Calls the specified callback for each furnace in the chunk. Returns true if all furnaces in the chunk have been processed (including when there are zero furnaces), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
function Callback(FurnaceEntity)
The callback should return false or no value to continue with the next furnace, or true to abort the enumeration.
ForEachLoadedChunk (undocumented)
ForEachPlayer CallbackFunction bool Calls the specified callback for each player in the loaded world. Returns true if all the players have been processed (including when there are zero players), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
function Callback(Player)
The callback should return false or no value to continue with the next player, or true to abort the enumeration.
GenerateChunk ChunkX, ChunkZ Queues the specified chunk in the chunk generator. Ignored if the chunk is already generated (use RegenerateChunk() to force chunk re-generation).
GetBiomeAt BlockX, BlockZ eBiome Returns the biome at the specified coords. Reads the biome from the chunk, if it is loaded, otherwise it uses the chunk generator to provide the biome value.
GetBlock BlockX, BlockY, BlockZ BLOCKTYPE Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlock BlockCoords BLOCKTYPE Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlockBlockLight BlockX, BlockY, BlockZ number Returns the amount of block light at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlockBlockLight {{Vector3i|Pos} number Returns the amount of block light at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlockInfo BlockX, BlockY, BlockZ BlockValid, BlockType, BlockMeta, BlockSkyLight, BlockBlockLight Returns the complete block info for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true.
GetBlockMeta BlockX, BlockY, BlockZ number Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlockMeta BlockCoords number Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlockSkyLight BlockX, BlockY, BlockZ number Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded.
GetBlockTypeMeta BlockX, BlockY, BlockZ BlockValid, BlockType, BlockMeta Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true.
GetDefaultWeatherInterval eWeather Returns the default weather interval for the specific weather type. Returns -1 for any unknown weather.
GetDimension eDimension Returns the dimension of the world - dimOverworld, dimNether or dimEnd.
GetGameMode eGameMode Returns the gamemode of the world - gmSurvival, gmCreative or gmAdventure.
GetGeneratorQueueLength number Returns the number of chunks that are queued in the chunk generator.
GetHeight BlockX, BlockZ number Returns the maximum height of the particula block column in the world. If the chunk is not loaded, it waits for it to load / generate. WARNING: Do not use, Use TryGetHeight() instead for a non-waiting version, otherwise you run the risk of a deadlock!
GetIniFileName string Returns the name of the world.ini file that the world uses to store the information.
GetLightingQueueLength number Returns the number of chunks in the lighting thread's queue.
GetLinkedEndWorldName string Returns the name of the end world this world is linked to.
GetLinkedNetherWorldName string Returns the name of the Netherworld linked to this world.
GetLinkedOverworldName string Returns the name of the world this world is linked to.
GetMapManager cMapManager Returns the MapManager object used by this world.
GetMaxCactusHeight number Returns the configured maximum height to which cacti will grow naturally.
GetMaxNetherPortalHeight number Returns the maximum height for a nether portal
GetMaxNetherPortalWidth number Returns the maximum width for a nether portal
GetMaxSugarcaneHeight number Returns the configured maximum height to which sugarcane will grow naturally.
GetMaxViewDistance number Returns the maximum viewdistance that players can see in this world. The view distance is the amount of chunks around the player that the player can see.
GetMinNetherPortalHeight number Returns the minimum height for a nether portal
GetMinNetherPortalWidth number Returns the minimum width for a nether portal
GetName string Returns the name of the world, as specified in the settings.ini file.
GetNumChunks number Returns the number of chunks currently loaded.
GetScoreBoard cScoreBoard Returns the ScoreBoard object used by this world.
GetSeed number Returns the seed of the world.
GetSignLines BlockX, BlockY, BlockZ IsValid, [Line1, Line2, Line3, Line4] Returns true and the lines of a sign at the specified coords, or false if there is no sign at the coords.
GetSpawnX number Returns the X coord of the default spawn
GetSpawnY number Returns the Y coord of the default spawn
GetSpawnZ number Returns the Z coord of the default spawn
GetStorageLoadQueueLength number Returns the number of chunks queued up for loading
GetStorageSaveQueueLength number Returns the number of chunks queued up for saving
GetTNTShrapnelLevel ShrapnelLevel Returns the shrapnel level, representing the block types that are propelled outwards following an explosion. Based on this value and a random picker, blocks are selectively converted to physics entities (FallingSand) and flung outwards.
GetTicksUntilWeatherChange number Returns the number of ticks that will pass before the weather is changed
GetTimeOfDay number Returns the number of ticks that have passed from the sunrise, 0 .. 24000.
GetWeather eWeather Returns the current weather in the world (wSunny, wRain, wStorm). To check for weather, use IsWeatherXXX() functions instead.
GetWorldAge number Returns the total age of the world, in ticks. The age always grows, cannot be set by plugins and is unrelated to TimeOfDay.
GrowCactus BlockX, BlockY, BlockZ, NumBlocksToGrow number Grows a cactus block at the specified coords, by up to the specified number of blocks. Adheres to the world's maximum cactus growth (GetMaxCactusHeight()). Returns the amount of blocks the cactus grew inside this call.
GrowMelonPumpkin BlockX, BlockY, BlockZ, StemType bool Grows a melon or pumpkin, based on the stem type specified (assumed to be in the coords provided). Checks for normal melon / pumpkin growth conditions - stem not having another produce next to it and suitable ground below. Returns true if the melon or pumpkin grew successfully.
GrowRipePlant BlockX, BlockY, BlockZ, IsByBonemeal bool Grows the plant at the specified coords. If IsByBonemeal is true, checks first if the specified plant type is bonemealable in the settings. Returns true if the plant was grown, false if not.
GrowSugarcane BlockX, BlockY, BlockZ, NumBlocksToGrow number Grows a sugarcane block at the specified coords, by up to the specified number of blocks. Adheres to the world's maximum sugarcane growth (GetMaxSugarcaneHeight()). Returns the amount of blocks the sugarcane grew inside this call.
GrowTree BlockX, BlockY, BlockZ Grows a tree based at the specified coords. If there is a sapling there, grows the tree based on that sapling, otherwise chooses a tree image based on the biome.
GrowTreeByBiome BlockX, BlockY, BlockZ Grows a tree based at the specified coords. The tree type is picked from types available for the biome at those coords.
GrowTreeFromSapling BlockX, BlockY, BlockZ, SaplingMeta Grows a tree based at the specified coords. The tree type is determined from the sapling meta (the sapling itself needn't be present).
IsBlockDirectlyWatered BlockX, BlockY, BlockZ bool Returns true if the specified block has a water block right next to it (on the X/Z axes)
IsDaylightCycleEnabled bool Returns true if the daylight cycle is enabled.
IsDeepSnowEnabled bool Returns whether the configuration has DeepSnow enabled.
IsGameModeAdventure bool Returns true if the current gamemode is gmAdventure.
IsGameModeCreative bool Returns true if the current gamemode is gmCreative.
IsGameModeSpectator bool Returns true if the current gamemode is gmSpectator.
IsGameModeSurvival bool Returns true if the current gamemode is gmSurvival.
IsPVPEnabled bool Returns whether PVP is enabled in the world settings.
IsTrapdoorOpen BlockX, BlockY, BlockZ bool Returns false if there is no trapdoor there or if the block isn't a trapdoor or if the chunk wasn't loaded. Returns true if trapdoor is open.
IsWeatherRain bool Returns true if the current world is raining.
IsWeatherRainAt BlockX, BlockZ bool Returns true if the specified location is raining (takes into account biomes).
IsWeatherStorm bool Returns true if the current world is stormy.
IsWeatherStormAt BlockX, BlockZ bool Returns true if the specified location is stormy (takes into account biomes).
IsWeatherSunny bool Returns true if the current weather is sunny.
IsWeatherSunnyAt BlockX, BlockZ bool Returns true if the current weather is sunny at the specified location (takes into account biomes).
IsWeatherWet bool Returns true if the current world has any precipitation (rain or storm).
IsWeatherWetAt BlockX, BlockZ bool Returns true if the specified location has any precipitation (rain or storm) (takes into account biomes).
PrepareChunk ChunkX, ChunkZ, [Callback] Queues the chunk for preparing - making sure that it's generated and lit. It is legal to call with no callback. The callback function has the following signature:
function Callback(ChunkX, ChunkZ)
QueueBlockForTick BlockX, BlockY, BlockZ, TicksToWait Queues the specified block to be ticked after the specified number of gameticks.
QueueSaveAllChunks Queues all chunks to be saved in the world storage thread
QueueTask TaskFunction Queues the specified function to be executed in the tick thread. This is the primary means of interaction with a cWorld from the WebAdmin page handlers (see WebWorldThreads). The function signature is
function()
All return values from the function are ignored. Note that this function is actually called *after* the QueueTask() function returns. Note that it is unsafe to store references to Cuberite objects, such as entities, across from the caller to the task handler function; store the EntityID instead.
QueueUnloadUnusedChunks Queues a cTask that unloads chunks that are no longer needed and are saved.
RegenerateChunk ChunkX, ChunkZ Queues the specified chunk to be re-generated, overwriting the current data. To queue a chunk for generating only if it doesn't exist, use the GenerateChunk() instead.
ScheduleTask DelayTicks, TaskFunction Queues the specified function to be executed in the world's tick thread after a the specified number of ticks. This enables operations to be queued for execution in the future. The function signature is
function(World)
All return values from the function are ignored. Note that it is unsafe to store references to Cuberite objects, such as entities, across from the caller to the task handler function; store the EntityID instead.
SendBlockTo BlockX, BlockY, BlockZ, Player Sends the block at the specified coords to the specified player's client, as an UpdateBlock packet.
SetAreaBiome MinX, MaxX, MinZ, MaxZ, EMCSBiome bool Sets the biome in the rectangular area specified. Returns true if successful, false if any of the chunks were unloaded.
SetAreaBiome Cuboid, EMCSBiome bool Sets the biome in the cuboid specified. Returns true if successful, false if any of the chunks were unloaded. The cuboid needn't be sorted.
SetBiomeAt BlockX, BlockZ, EMCSBiome bool Sets the biome at the specified block coords. Returns true if successful, false otherwise.
SetBlock BlockX, BlockY, BlockZ, BlockType, BlockMeta, [ShouldSendToClients] Sets the block at the specified coords, replaces the block entities for the previous block type, creates a new block entity for the new block, if appropriate, and wakes up the simulators. This is the preferred way to set blocks, as opposed to FastSetBlock(), which is only to be used under special circumstances. If ShouldSendToClients is true (default), the change is broadcast to all players who have this chunk loaded; if false, the change is made server-side only.
SetBlockMeta BlockX, BlockY, BlockZ, BlockMeta, [ShouldMarkChunkDirty], [ShouldSendToClients] Sets the meta for the block at the specified coords. If ShouldMarkChunkDirty is true (default), the chunk is marked dirty and will be saved later on. If ShouldSendToClients is true (default), the change is broadcast to all clients who have the chunk loaded, if false, the change is kept server-side only.
SetBlockMeta BlockCoords, BlockMeta Sets the meta for the block at the specified coords.
SetChunkAlwaysTicked ChunkX, ChunkZ, IsAlwaysTicked Sets the chunk to always be ticked even when it doesn't contain any clients. IsAlwaysTicked set to true turns forced ticking on, set to false turns it off. Every call with 'true' should be paired with a later call with 'false', otherwise the ticking won't stop. Multiple actions can request ticking independently, the ticking will continue until the last call with 'false'. Note that when the chunk unloads, it loses the value of this flag.
SetCommandBlockCommand BlockX, BlockY, BlockZ, Command bool Sets the command to be executed in a command block at the specified coordinates. Returns if command was changed.
SetCommandBlocksEnabled IsEnabled (bool) Sets whether command blocks should be enabled on the (entire) server.
SetDaylightCycleEnabled bool Starts or stops the daylight cycle.
SetLinkedEndWorldName string Sets the name of the world that the end portal should link to.
SetLinkedNetherWorldName string Sets the name of the world that the nether portal should link to.
SetLinkedOverworldName string Sets the name of the world that the nether portal should link to?
SetMaxNetherPortalHeight number Sets the maximum height for a nether portal
SetMaxNetherPortalWidth number Sets the maximum width for a nether portal
SetMaxViewDistance number Sets the maximum viewdistance of the players in the world.
SetMinNetherPortalHeight number Sets the minimum height for a nether portal
SetMinNetherPortalWidth number Sets the minimum width for a nether portal
SetNextBlockTick BlockX, BlockY, BlockZ Sets the blockticking to start at the specified block in the next tick.
SetShouldUseChatPrefixes ShouldUse (bool) Sets whether coloured chat prefixes such as [INFO] is used with the SendMessageXXX() or BroadcastChatXXX(), or simply the entire message is coloured in the respective colour.
SetSignLines X, Y, Z, Line1, Line2, Line3, Line4, [Player] Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil.
SetSpawn X, Y, Z bool Sets the default spawn at the specified coords.
SetTNTShrapnelLevel ShrapnelLevel Sets the Shrampel level of the world.
SetTicksUntilWeatherChange NumTicks Sets the number of ticks after which the weather will be changed.
SetTimeOfDay TimeOfDayTicks Sets the time of day, expressed as number of ticks past sunrise, in the range 0 .. 24000.
SetTrapdoorOpen BlockX, BlockY, BlockZ, bool Opens or closes a trapdoor at the specific coordinates.
SetWeather Weather Sets the current weather (wSunny, wRain, wStorm) and resets the TicksUntilWeatherChange to the default value for the new weather. The normal weather-changing hooks are called for the change.
ShouldBroadcastAchievementMessages bool Returns true if the server should broadcast achievement messages in this world.
ShouldBroadcastDeathMessages bool Returns true if the server should broadcast death messages in this world.
ShouldLavaSpawnFire bool Returns true if the world is configured to spawn fires near lava (world.ini: [Physics].ShouldLavaSpawnFire value)
ShouldUseChatPrefixes bool Returns whether coloured chat prefixes are prepended to chat messages or the entire message is simply coloured.
SpawnBoat X, Y, Z EntityID Spawns a boat at the specific coordinates. Returns the entity ID of the new boat, or cEntity.NO_ID if no boat was created.
SpawnExperienceOrb X, Y, Z, Reward EntityID Spawns an experience orb at the specified coords, with the given reward
SpawnFallingBlock X, Y, Z, BlockType, BlockMeta EntityID Spawns an Falling Block entity at the specified coords with the given block type/meta
SpawnItemPickups Pickups, X, Y, Z, SpeedX, SpeedY, SpeedZ, [IsPlayerCreated] Spawns the specified pickups at the position specified. All the pickups fly away from the spawn position using the specified speed. The IsPlayerCreated parameter (default: false) is used to initialize the created cPickup object's IsPlayerCreated value.
SpawnItemPickups Pickups, X, Y, Z, [FlyAwaySpeed], [IsPlayerCreated] Spawns the specified pickups at the position specified. The FlyAwaySpeed is a coefficient (default: 1) used to initialize the random speed in which the pickups fly away from the spawn position. The IsPlayerCreated parameter (default: false) is used to initialize the created cPickup object's IsPlayerCreated value.
SpawnMinecart X, Y, Z, MinecartType, [Item], [BlockHeight] EntityID Spawns a minecart at the specific coordinates. MinecartType is the item type of the minecart. If the minecart is an empty minecart then the given Item (default: empty) is the block to be displayed inside the minecart, and BlockHeight (default: 1) is the relative distance of the block from the minecart. Returns the entity ID of the new minecart, or cEntity.NO_ID if no minecart was created.
SpawnMob X, Y, Z, MonsterType, [IsBaby] EntityID Spawns the specified type of mob at the specified coords. If the Baby parameter is true, the mob will be a baby. Returns the EntityID of the creates entity, or -1 on failure.
SpawnPrimedTNT X, Y, Z, FuseTicks, InitialVelocityCoeff Spawns a primed TNT entity at the specified coords, with the given fuse ticks. The entity gets a random speed multiplied by the InitialVelocityCoeff, 1 being the default value.
TryGetHeight BlockX, BlockZ IsValid, Height Returns true and height of the highest non-air block if the chunk is loaded, or false otherwise.
UpdateSign X, Y, Z, Line1, Line2, Line3, Line4, [Player] (DEPRECATED) Please use SetSignLines().
UseBlockEntity Player, BlockX, BlockY, BlockZ Makes the specified Player use the block entity at the specified coords (open chest UI, etc.) If the cords are in an unloaded chunk or there's no block entity, ignores the call.
VillagersShouldHarvestCrops Returns true if villagers can harvest crops.
WakeUpSimulators BlockX, BlockY, BlockZ Wakes up the simulators for the specified block.
WakeUpSimulatorsInArea MinBlockX, MaxBlockX, MinBlockY, MaxBlockY, MinBlockZ, MaxBlockZ Wakes up the simulators for all the blocks in the specified area (edges inclusive).

Using callbacks

To avoid problems with stale objects, the cWorld class will not let plugins get a direct pointer to an entity, block entity or a player. Such an object could be modified or even destroyed by another thread while the plugin holds it, so it would be rather unsafe.

Instead, the cWorld provides access to these objects using callbacks. The plugin provides a function that is called and receives the object as a parameter; cWorld guarantees that while the callback is executing, the object will stay valid. If a plugin needs to "remember" the object outside of the callback, it needs to store the entity ID, blockentity coords or player name.

The following code examples show how to use the callbacks

This code teleports player Player to another player named ToName in the same world:

-- Player is a cPlayer object
-- ToName is a string
-- World is a cWorld object
World:ForEachPlayer(
	function (a_OtherPlayer)
	if (a_OtherPlayer:GetName() == ToName) then
		Player:TeleportToEntity(a_OtherPlayer);
	end
);

This code fills each furnace in the chunk with 64 coals:

-- Player is a cPlayer object
-- World is a cWorld object
World:ForEachFurnaceInChunk(Player:GetChunkX(), Player:GetChunkZ(),
	function (a_Furnace)
		a_Furnace:SetFuelSlot(cItem(E_ITEM_COAL, 64));
	end
);

This code teleports all spiders up by 100 blocks:

-- World is a cWorld object
World:ForEachEntity(
	function (a_Entity)
		if not(a_Entity:IsMob()) then
			return;
		end

		-- Get the cMonster out of cEntity, now that we know the entity represents one.
		local Monster = tolua.cast(a_Entity, "cMonster");
		if (Monster:GetMobType() == mtSpider) then
			Monster:TeleportToCoords(Monster:GetPosX(), Monster:GetPosY() + 100, Monster:GetPosZ());
		end
	end
);

Generated on 2016-08-22 23:53:06, Build ID Unknown, Commit approx: 2ed4af74edd14ae17e1c6c64d44caa7b7fc30d5a