Struct mc_core::world::chunk::Chunk[][src]

pub struct Chunk { /* fields omitted */ }
Expand description

A vertical chunk, 16x16 blocks. This vertical chunk is composed of multiple SubChunks, each sub chunk has stores blocks, biomes, lights. This structure however stores metadata about the chunk like inhabited time and generation status. All entities and block entities are also stored in the chunk.

Implementations

Get the chunk position (x, z).

Return the configured height for the level owning this chunk.

Return the linear non-negative offset of the chunk at the given position, the position can be negative. None is returned if the chunk position is not within the chunk’s height.

Ensure that a sub chunk is existing at a specific chunk-Y coordinate, if this coordinate is out of the height of the level, Err(ChunkError::SubChunkOutOfRange) is returned.

Replace the sub chunk at the given Y chunk coordinate by the given one.

Panics (debug only):

The method panics if the given sub chunk has not the same sub chunk environment as self.

Get a sub chunk reference at a specified index.

Get a sub chunk mutable reference at a specified index.

Return the number of sub chunks in the height of this chunk.

Iterator over all sub chunks with their Y coordinate, sub chunks may be not loaded (None).

Iterator only over loaded sub chunks.

Return the index of the first sub chunk (starting from the top sub chunk) that is loaded AND contains a non null block.

Get the block at a specific position.

Returns Ok(&BlockState) if the block is found and valid, Err(ChunkError::SubChunkOutOfRange) if the given y coordinate is out of the chunk height, if the Y coordinate is valid but the sub chunk is yet loaded, the “null-block” is returned.

Panics (debug-only)

This method panics if either X or Z is higher than 15.

Same description as get_block but accept level coordinates instead of relative ones. This method ignore if the given coordinates are not actually pointing to this chunk, it only take the 4 least significant bits.

Set the block at a specific position relative to this chunk.

Return Ok(()) if the biome was successfully set, Err(ChunkError::SubChunkOutOfRange) if the given Y coordinate is invalid for the level or Err(ChunkError::IllegalBlock) if the given block state is not registered in the current world.

Panics (debug-only)

This method panics if either X or Z is higher than 15.

Same description as set_block but accept level coordinates instead of relative ones. This method ignore if the given coordinates are not actually pointing to this chunk, it only take the 4 least significant bits.

Get a biome at specific biome coordinates, biome coordinates are different from block coordinates because there is only 4x4x4 biomes samples for each sub chunk. Given X and Z coordinates must be lower than 4 and given Y coordinate must be valid for the chunk height.

Returns Ok(biome) or Err(ChunkError::SubChunkOutOfRange) if the given Y coordinate is not supported by this chunk’s height.

Panics (debug-only)

This method panics if either X or Z is higher than 3.

Get a biome at specific biome coordinates, biome coordinates are different from block coordinates because there is only 4x4x4 biomes samples for each sub chunk. Given X and Z coordinates must be lower than 4 and given Y coordinate must be valid for the chunk height.

Returns Ok(biome) or Err(ChunkError::SubChunkOutOfRange) if the given Y coordinate is not supported by this chunk’s height.

Panics (debug-only)

This method panics if either X or Z is higher than 3.

Set all biome quads in this chunk according a to a 2D biomes rectangle (16x16). The implementation currently take the lower coordinates biome in each 4x4 rectangle and set it to the whole chunk height.

Expose internal biomes storage, retuning an iterator with each biomes in this chunk, ordered by X, Z then Y.

Set the value of a specific heightmap at specific coordinates. This is very unsafe to do that manually, you should ensure that the condition of the given heightmap type are kept.

Get the value of a specific heightmap at specific coordinates.

Public method that you can use to recompute a single column for all heightmaps.

Direct access method to internal packed array, returning each of the 256 values from the given heightmap type if it exists, ordered by X then Z.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.