Table of Contents

Interface IChunkBlocks

Namespace
Vintagestory.API.Common
Assembly
VintagestoryAPI.dll
public interface IChunkBlocks

Properties

this[int]

Retrieves the first solid block, if that one is empty, retrieves the first fluid block

int this[int index3d] { get; set; }

Parameters

index3d int

Property Value

int

Length

int Length { get; }

Property Value

int

Methods

ClearBlocks()

void ClearBlocks()

ClearBlocksAndPrepare()

Same as ClearBlocks but initialises the chunkdata palette, so that SetBlockUnsafe can be used (useful in worldgen)

void ClearBlocksAndPrepare()

ContainsBlock(int)

Does this chunk contain any examples of the specified block?
(If the result is false, this is a very fast lookup because it quickly scans the blocks palette, not every block individually.)

bool ContainsBlock(int blockId)

Parameters

blockId int

Returns

bool

FuzzyListBlockIds(List<int>)

Populates the list with all block IDs which are present in this chunk. The list may contain false positives (i.e. blocks which used to be here but were removed) so that's why it's called a "Fuzzy" list. There will be no false negatives, therefore useful as a first-pass filter when scanning chunks for various types of block e.g. ITickable

void FuzzyListBlockIds(List<int> reusableList)

Parameters

reusableList List<int>

GetBlockId(int, int)

int GetBlockId(int index3d, int layer)

Parameters

index3d int
layer int

Returns

int

GetBlockIdUnsafe(int)

Like get (i.e. this[]) but not threadsafe - only for use where setting and getting is guaranteed to be all on the same thread (e.g. during worldgen)

int GetBlockIdUnsafe(int index3d)

Parameters

index3d int

Returns

int

GetFluid(int)

int GetFluid(int index3d)

Parameters

index3d int

Returns

int

ReleaseBulkReadLock()

Leave a locked section for bulk block reads from this ChunkData, using Unsafe read methods

void ReleaseBulkReadLock()

SetBlockAir(int)

void SetBlockAir(int index3d)

Parameters

index3d int

SetBlockBulk(int, int, int, int)

Efficiently bulk-set a single block id in a chunk throughout a y-layer. lenX will be ignored (always treated as 32), the y-position is specified in index3d, the width lenZ will be respected

void SetBlockBulk(int index3d, int lenX, int lenZ, int value)

Parameters

index3d int
lenX int
lenZ int
value int

SetBlockUnsafe(int, int)

Not threadsafe, used only in cases where we know that the chunk already has a palette (e.g. in worldgen when replacing rock with other blocks)

void SetBlockUnsafe(int index3d, int value)

Parameters

index3d int
value int

SetFluid(int, int)

Used to place blocks into the fluid layer instead of the solid blocks layer; calling code must do this

void SetFluid(int index3d, int value)

Parameters

index3d int
value int

TakeBulkReadLock()

Enter a locked section for bulk block reads from this ChunkData, using Unsafe read methods

void TakeBulkReadLock()