UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

115 lines (114 loc) 4.95 kB
import LevelKeyValue from "./LevelKeyValue"; import BlockPalette from "./BlockPalette"; import BlockVolume from "./BlockVolume"; import Block from "./Block"; import MCWorld from "./MCWorld"; import BlockActor from "./blockActors/BlockActor"; import ChunkEntity from "./ChunkEntity"; export declare enum SubChunkFormatType { paletteFrom1dot2dot13 = 0, subChunk1dot0 = 1 } export default class WorldChunk { checksumKey: LevelKeyValue | undefined; subChunks: LevelKeyValue[]; subChunkVersions: number[] | undefined; chunkVersion: LevelKeyValue | undefined; biomesAndElevation: LevelKeyValue | undefined; finalizedState: LevelKeyValue | undefined; entity: LevelKeyValue | undefined; blockActorKeys: LevelKeyValue[]; private _hasContent?; private _blockActorsRelLoc; private _blockActors; private _entities; private _entitiesEnsured; pendingTicks: LevelKeyValue | undefined; biomeState: LevelKeyValue | undefined; blockTops: number[][] | undefined; data3dRecord: LevelKeyValue | undefined; blockActorsEnsured: boolean; absoluteZeroY: number; chunkMinY: number; legacyVersion: number | undefined; world: MCWorld; legacyTerrainBytes: Uint8Array | undefined; bitsPerBlock: number[]; blockDataStart: number[]; blockPalettes: (BlockPalette | undefined)[]; subChunkFormatType: SubChunkFormatType[]; actorDigests: string[]; auxBitsPerBlock: number[]; auxBlockDataStart: number[]; auxBlockPalettes: BlockPalette[]; pendingSubChunksToProcess: boolean[]; x: number; z: number; maxSubChunkIndex: number; minSubChunkIndex: number; get absoluteMinY(): number; get minY(): number; get maxY(): number; get absoluteMaxY(): number; get blockActors(): BlockActor[]; /** * Gets the entities in this chunk. * Entities are parsed lazily from the entity LevelKeyValue on first access. */ get entities(): ChunkEntity[]; constructor(world: MCWorld, inX: number, inZ: number); _checkNotCleared(): void; /** * Clears cached/parsed data to free memory while preserving the ability to re-parse later. * Use this after processing a chunk to reduce memory usage. * The raw LevelKeyValue data is preserved, allowing getBlock() to re-parse on demand. */ clearCachedData(): void; /** * Aggressively clears all chunk data including raw LevelKeyValue bytes. * Call this when the chunk data is no longer needed and will not be re-accessed. * WARNING: After calling this, the chunk cannot be re-parsed from its data. */ clearAllData(): void; addActorDigest(digest: string): void; translateSubChunkIndex(storageSubChunk: number): number; processSubChunk(index: number): void; addKeyValue(keyValue: LevelKeyValue): void; clearKeyValue(keyBytes: string): void; ensureBlockActors(): void; /** * Parses entity data from the chunk's entity LevelKeyValue. * This handles legacy entity storage (pre-1.18.30) where entity data * is stored as concatenated NBT compound tags per chunk (type 50). * * Modern worlds (1.18.30+) store actors individually via actorprefix keys, * which are parsed into MCWorld.actorsById instead. * * See: https://learn.microsoft.com/en-us/minecraft/creator/documents/actorstorage */ ensureEntities(): void; removeBlockActorAtLoc(x: number, y: number, z: number): void; getSubChunkCube(subChunkId: number): BlockVolume; fillCubeLegacy(cube: BlockVolume, cubeX: number, cubeY: number, cubeZ: number, maxCubeX: number, maxCubeY: number, maxCubeZ: number, internalOffsetX: number, internalOffsetY: number, internalOffsetZ: number): void; fillCube(cube: BlockVolume, cubeX: number, cubeY: number, cubeZ: number, maxCubeX: number, maxCubeY: number, maxCubeZ: number, internalOffsetX: number, internalOffsetY: number, internalOffsetZ: number): void; getTopBlockY(x: number, z: number): number; getTopBlock(x: number, z: number): Block; _getBlockLegacy(x: number, y: number, z: number): Block; _getBlockLegacyList(): Block[]; doesBlockPaletteExist(y: number): boolean; getBlock(x: number, y: number, z: number): Block; /** * Returns a count of block types in this chunk without allocating Block objects. * This is much more memory-efficient than getBlockList() for statistical analysis. * @returns A Map of block type names to their counts in this chunk */ countBlockTypes(): Map<string, number>; getBlockList(): any[]; _determineBlockTopsLegacy(): void; determineBlockTops(): void; getSubChunkIndexFromY(y: number): number; getStartYFromSubChunkIndex(subChunkIndex: number): number; getBlockPaletteIndex(x: number, y: number, z: number): number; getBlockPaletteIndexList(subChunkId: number): any[]; parseSubChunk(subChunkIndex: number): void; }