cChunkDesc


Index:
Articles
Classes
Hooks

Quick navigation:
BannerPattern
BossBarColor
BossBarDivisionType
cArrowEntity
cBeaconEntity
cBedEntity
cBlockArea
cBlockEntity
cBlockEntityWithItems
cBlockInfo
cBoat
cBoundingBox
cBrewingstandEntity
cChatColor
cChestEntity
cChunkDesc
cClientHandle
cColor
cCommandBlockEntity
cCompositeChat
cCraftingGrid
cCraftingRecipe
cCryptoHash
cCuboid
cDispenserEntity
cDropperEntity
cDropSpenserEntity
cEnchantments
cEnderCrystal
cEntity
cEntityEffect
cExpBottleEntity
cExpOrb
cFallingBlock
cFile
cFireChargeEntity
cFireworkEntity
cFloater
cFlowerPotEntity
cFurnaceEntity
cGhastFireballEntity
cHangingEntity
cHopperEntity
cIniFile
cInventory
cItem
cItemFrame
cItemGrid
cItems
cJson
cJukeboxEntity
cLeashKnot
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
cStringCompression
cTCPLink
cTeam
cThrownEggEntity
cThrownEnderPearlEntity
cThrownSnowballEntity
cTNTEntity
cUDPEndpoint
cUrlClient
cUrlParser
CustomStatistic
cUUID
cWebAdmin
cWindow
cWitherSkullEntity
cWorld
EffectID
HTTPFormData
HTTPRequest
HTTPTemplateRequest
ItemCategory
lxp
SmokeDirection
sqlite3
StatisticsManager
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. Calls to any setter of this class will not trigger simulator updates (lava, water, redstone).


Functions

NameParametersReturn valueNotes
FillBlocks
BlockTypenumber
BlockMetanumber
Fills the entire chunk with the specified blocks
FillRelCuboid
RelCuboidcCuboid
BlockTypenumber
BlockMetanumber
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
MinRelXnumber
MaxRelXnumber
MinRelYnumber
MaxRelYnumber
MinRelZnumber
MaxRelZnumber
BlockTypenumber
BlockMetanumber
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
RelCuboidcCuboid
BlockTypenumber
BlockMetanumber
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
MinRelXnumber
MaxRelXnumber
MinRelYnumber
MaxRelYnumber
MinRelZnumber
MaxRelZnumber
BlockTypenumber
BlockMetanumber
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
RelXnumber
RelZnumber
EMCSBiome
Returns the biome at the specified relative coords
GetBlockEntity
RelXnumber
RelYnumber
RelZnumber
cBlockEntity
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
RelXnumber
RelYnumber
RelZnumber
NIBBLETYPEnumber
Returns the block meta at the specified relative coords
GetBlockType
RelXnumber
RelYnumber
RelZnumber
BLOCKTYPEnumber
Returns the block type at the specified relative coords
GetBlockTypeMeta
RelXnumber
RelYnumber
RelZnumber
BLOCKTYPEnumber
NIBBLETYPEnumber
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
RelXnumber
RelZnumber
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
boolean
Returns true if the chunk is set to use default biome generator
IsUsingDefaultComposition
boolean
Returns true if the chunk is set to use default composition generator
IsUsingDefaultFinish
boolean
Returns true if the chunk is set to use default finishers
IsUsingDefaultHeight
boolean
Returns true if the chunk is set to use default height generator
RandomFillRelCuboid
RelCuboidcCuboid
BlockTypenumber
BlockMetanumber
RandomSeednumber
ChanceOutOf10knumber
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
MinRelXnumber
ChanceOutOf10knumber
MaxRelXnumber
MinRelYnumber
MaxRelYnumber
MinRelZnumber
MaxRelZnumber
BlockTypenumber
BlockMetanumber
RandomSeednumber
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
BlockAreacBlockArea
MinRelXnumber
MaxRelXnumber
MinRelYnumber
MaxRelYnumber
MinRelZnumber
MaxRelZnumber
Reads data from the chunk into the block area object. Block types and metas are processed.
ReplaceRelCuboid
RelCuboidcCuboid
SrcBlockTypenumber
SrcBlockMetanumber
DstBlockTypenumber
DstBlockMetanumber
Replaces all SrcBlockType + SrcBlockMeta blocks in the cuboid (specified in relative coords) with DstBlockType + DstBlockMeta blocks. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
ReplaceRelCuboid
MinRelXnumber
MaxRelXnumber
MinRelYnumber
MaxRelYnumber
MinRelZnumber
MaxRelZnumber
SrcBlockTypenumber
SrcBlockMetanumber
DstBlockTypenumber
DstBlockMetanumber
Replaces all SrcBlockType + SrcBlockMeta blocks in the cuboid (specified in relative coords) with DstBlockType + DstBlockMeta blocks. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled.
SetBiome
RelXnumber
RelZnumber
BiomeEMCSBiome
Sets the biome at the specified relative coords.
SetBlockMeta
RelXnumber
RelYnumber
RelZnumber
BlockMetanumber
Sets the block meta at the specified relative coords.
SetBlockType
RelXnumber
RelYnumber
RelZnumber
BlockTypenumber
Sets the block type at the specified relative coords
SetBlockTypeMeta
RelXnumber
RelYnumber
RelZnumber
BlockTypenumber
BlockMetanumber
Sets the block type and meta at the specified relative coords
SetHeight
RelXnumber
RelZnumber
Heightnumber
Sets the height at the specified relative coords
SetUseDefaultBiomes
ShouldUseDefaultBiomesboolean
Sets the chunk to use default biome generator or not
SetUseDefaultComposition
ShouldUseDefaultCompositionboolean
Sets the chunk to use default composition generator or not
SetUseDefaultFinish
ShouldUseDefaultFinishboolean
Sets the chunk to use default finishers or not
SetUseDefaultHeight
ShouldUseDefaultHeightboolean
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
BlockAreacBlockArea
MinRelXnumber
MinRelYnumber
MinRelZnumber
MergeStrategycBlockArea
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 by APIDump on 2024-10-25 05:01:00, Build ID Unknown, Commit approx: 0325de7dacaf1e2feaea5eaab4791bc23d78f9e7