cChunkDesc


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


cChunkDesc class

The cChunkDesc class is a container for chunk data while the chunk is being generated. As such, it is only used as a parameter for the OnChunkGenerating and OnChunkGenerated hooks and cannot be constructed on its own. Plugins can use this class in both those hooks to manipulate generated chunks.


Functions

NameParametersReturn valueNotes
FillBlocks BlockType, BlockMeta Fills the entire chunk with the specified blocks
FillRelCuboid MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta Fills the cuboid, specified in relative coords, by the specified block type and block meta. The cuboid may reach outside of the chunk, only the part intersecting with this chunk is filled.
FillRelCuboid RelCuboid, BlockType, BlockMeta Fills the cuboid, specified in relative coords, by the specified block type and block meta. The cuboid may reach outside of the chunk, only the part intersecting with this chunk is filled.
FloorRelCuboid MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
FloorRelCuboid RelCuboid, BlockType, BlockMeta Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
GetBiome RelX, RelZ EMCSBiome Returns the biome at the specified relative coords
GetBlockEntity RelX, RelY, RelZ cBlockEntity descendant Returns the block entity for the block at the specified coords. Creates it if it doesn't exist. Returns nil if the block has no block entity capability.
GetBlockMeta RelX, RelY, RelZ NIBBLETYPE Returns the block meta at the specified relative coords
GetBlockType RelX, RelY, RelZ BLOCKTYPE Returns the block type at the specified relative coords
GetBlockTypeMeta RelX, RelY, RelZ BLOCKTYPE, NIBBLETYPE Returns the block type and meta at the specified relative coords
GetChunkX number Returns the X coord of the chunk contained.
GetChunkZ number Returns the Z coord of the chunk contained.
GetHeight RelX, RelZ number Returns the height at the specified relative coords
GetMaxHeight number Returns the maximum height contained in the heightmap.
GetMinHeight number Returns the minimum height value in the heightmap.
IsUsingDefaultBiomes bool Returns true if the chunk is set to use default biome generator
IsUsingDefaultComposition bool Returns true if the chunk is set to use default composition generator
IsUsingDefaultFinish bool Returns true if the chunk is set to use default finishers
IsUsingDefaultHeight bool Returns true if the chunk is set to use default height generator
RandomFillRelCuboid MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta, RandomSeed, ChanceOutOf10k Fills the specified relative cuboid with block type and meta in random locations. RandomSeed is used for the random number genertion (same seed produces same results); ChanceOutOf10k specifies the density (how many out of every 10000 blocks should be filled). Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
RandomFillRelCuboid RelCuboid, BlockType, BlockMeta, RandomSeed, ChanceOutOf10k Fills the specified relative cuboid with block type and meta in random locations. RandomSeed is used for the random number genertion (same seed produces same results); ChanceOutOf10k specifies the density (how many out of every 10000 blocks should be filled). Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
ReadBlockArea BlockArea, MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ Reads data from the chunk into the block area object. Block types and metas are processed.
ReplaceRelCuboid MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, SrcType, SrcMeta, DstType, DstMeta Replaces all SrcType+SrcMeta blocks in the cuboid (specified in relative coords) with DstType+DstMeta blocks. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
ReplaceRelCuboid RelCuboid, SrcType, SrcMeta, DstType, DstMeta Replaces all SrcType+SrcMeta blocks in the cuboid (specified in relative coords) with DstType+DstMeta blocks. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
SetBiome RelX, RelZ, EMCSBiome Sets the biome at the specified relative coords
SetBlockMeta RelX, RelY, RelZ, BlockMeta Sets the block meta at the specified relative coords
SetBlockType RelX, RelY, RelZ, BlockType Sets the block type at the specified relative coords
SetBlockTypeMeta RelX, RelY, RelZ, BlockType, BlockMeta Sets the block type and meta at the specified relative coords
SetHeight RelX, RelZ, Height Sets the height at the specified relative coords
SetUseDefaultBiomes bool Sets the chunk to use default biome generator or not
SetUseDefaultComposition bool Sets the chunk to use default composition generator or not
SetUseDefaultFinish bool Sets the chunk to use default finishers or not
SetUseDefaultHeight bool Sets the chunk to use default height generator or not
UpdateHeightmap Updates the heightmap to match current contents. The plugins should do that if they modify the contents and don't modify the heightmap accordingly; Cuberite expects (and checks in Debug mode) that the heightmap matches the contents when the cChunkDesc is returned from a plugin.
WriteBlockArea BlockArea, MinRelX, MinRelY, MinRelZ, [MergeStrategy] Writes data from the block area into the chunk

Manipulating block entities

To manipulate block entities while the chunk is generated, first use SetBlockTypeMeta() to set the correct block type and meta at the position. Then use the GetBlockEntity() to create and return the correct block entity instance. Finally, use tolua.cast() to cast to the proper type.

Note that you don't need to check if a block entity has previously existed at the place, because GetBlockEntity() will automatically re-create the correct type for you.

The following code is taken from the Debuggers plugin, it creates a sign at each chunk's [0, 0] coords, with the text being the chunk coords:

function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
	-- Get the topmost block coord:
	local Height = a_ChunkDesc:GetHeight(0, 0);

	-- Create a sign there:
	a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0);
	local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0);
	if (BlockEntity ~= nil) then
		LOG("Setting sign lines...");
		local SignEntity = tolua.cast(BlockEntity, "cSignEntity");
		SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)");
	end

	-- Update the heightmap:
	a_ChunkDesc:SetHeight(0, 0, Height + 1);
end
Generated on 2016-08-22 23:53:06, Build ID Unknown, Commit approx: 2ed4af74edd14ae17e1c6c64d44caa7b7fc30d5a