@jsprismarine/prismarine
Version:
Dedicated Minecraft Bedrock Edition server written in TypeScript
73 lines • 3.06 kB
TypeScript
import { LegacyId } from '../../block/BlockMappings';
import { default as BinaryStream } from '../../../../jsbinaryutils/src/index.ts';
import { Vector3 } from '../../../../math/src/index.ts';
import { Block } from '../../block/Block';
import { default as SubChunk } from './SubChunk';
export default class Chunk {
private x;
private z;
private hasChanged;
private subChunks;
private static readonly EMPTY_SUBCHUNK;
constructor(chunkX?: number, chunkZ?: number, _subChunks?: Map<number, SubChunk>);
getX(): number;
getZ(): number;
getHasChanged(): boolean;
getHeight(): number;
/**
* Returns the highest empty sub chunk (so we don't send empty sub chunks).
* @returns {number} The highest empty sub chunk.
*/
getTopEmpty(): number;
/**
* Returns the Chunk slice at the given layer.
* @param {number} y - The layer to get.
*/
getSubChunk(y: number): SubChunk | null;
getOrCreateSubChunk(y: number): SubChunk;
getSubChunks(): Map<number, SubChunk>;
getHighestBlockAt(_x: number, _z: number): number;
/**
* Returns block legacy id (DATA) in the corresponding sub chunk.
* Use world to get the actual block instance (this is to keep code clean).
* @param {Vector3 | number} x - block x.
* @param {number} [y=0] - block y.
* @param {number} [z=0] - block z.
* @param {number} [layer=0] - block storage layer (0 for blocks, 1 for liquids).
*/
getBlock(x: Vector3 | number, y?: number, z?: number, layer?: number): LegacyId;
/**
* Sets a block into the chunk by its runtime Id.
* @param {number} x - block x
* @param {number} y - block y
* @param {number} z - block z
* @param {Block} block - block to set
* @param {number} [layer=0] - block storage layer (0 for blocks, 1 for liquids)
*/
setBlock(x: number, y: number, z: number, block: Block, layer?: number): void;
/**
* Helper method used to hash into a single 64 bits integer
* both Chunk X and Z coordinates.
* @param {number} chunkX - Target Chunk X coordinate.
* @param {number} chunkZ - Target Chunk Z coordinate.
* @returns {bigint} A 64 bit intger containing a hash of X and Z.
*/
static packXZ(chunkX: number, chunkZ: number): bigint;
/**
* Helper method used to decode a 64 bit hash containing
* both Chunk X and Z coordinates.
* @param {bigint} packed - Target Chunk coordinate hash.
* @returns {number[]} An array containing decoded Chunk X and Z coordinates.
*/
static unpackXZ(packed: bigint): number[];
networkSerialize(): Buffer;
/**
* Deserialize network stream into chunk
* useful for client applications and/or our Filesystem impl
* @param {BinaryStream} stream - the network stream
* @param {number} [x] - the chunk x coordinate
* @param {number} [z] - the chunk z coordinate
*/
static networkDeserialize(stream: BinaryStream, x?: number, z?: number): Chunk;
}
//# sourceMappingURL=Chunk.d.ts.map