minerender 2.1.0-alpha.90 → 2.1.0-alpha.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3156,6 +3156,19 @@ declare class ChunkData {
3156
3156
  }
3157
3157
 
3158
3158
  type RegionInput = Uint8Array | ArrayBuffer;
3159
+ /** Reads `c.<x>.<z>.mcc` at absolute chunk coordinates, or returns `undefined` when the file is missing. */
3160
+ type AnvilExternalChunkReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3161
+ interface AnvilParseOptions {
3162
+ /** Region coordinates from `r.<x>.<z>.mca`, required when reading external chunks. */
3163
+ region?: {
3164
+ x: number;
3165
+ z: number;
3166
+ };
3167
+ /** Reads external chunk payloads without their region-file header. */
3168
+ readExternalChunk?: AnvilExternalChunkReader;
3169
+ /** Cancels parsing and forwards the signal to external chunk reads. */
3170
+ signal?: AbortSignal;
3171
+ }
3159
3172
  /** Chunk columns decoded from an Anvil region file. */
3160
3173
  interface AnvilRegion {
3161
3174
  chunks: AnvilChunk[];
@@ -3178,15 +3191,16 @@ declare class AnvilParser {
3178
3191
  x: number;
3179
3192
  z: number;
3180
3193
  }[];
3181
- /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
3182
- static parse(data: RegionInput): Promise<AnvilRegion>;
3194
+ /** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
3195
+ static parse(data: RegionInput, options?: AnvilParseOptions): Promise<AnvilRegion>;
3183
3196
  /**
3184
3197
  * Decodes one chunk for {@link MineRenderWorld.placeChunk}.
3185
3198
  * @param localX - Chunk x within the region, from 0 to 31.
3186
3199
  * @param localZ - Chunk z within the region, from 0 to 31.
3187
3200
  * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
3188
3201
  */
3189
- static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
3202
+ static parseChunk(data: RegionInput, localX: number, localZ: number, options?: AnvilParseOptions): Promise<AnvilChunk | undefined>;
3203
+ private static abortable;
3190
3204
  private static bytes;
3191
3205
  private static locations;
3192
3206
  private static readChunk;
@@ -3207,8 +3221,10 @@ interface WorldChunkSource {
3207
3221
  * Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
3208
3222
  */
3209
3223
  type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3210
- /** Cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3224
+ /** Readers and cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3211
3225
  interface AnvilWorldSourceOptions {
3226
+ /** Reads external `c.<x>.<z>.mcc` payloads at absolute chunk coordinates in the same dimension. */
3227
+ readExternalChunk?: AnvilExternalChunkReader;
3212
3228
  /** Maximum cached regions, including missing regions. Defaults to 4; 0 disables caching. */
3213
3229
  maxCachedRegions?: number;
3214
3230
  /** Maximum retained region bytes. Defaults to 64 MiB; larger regions are read without caching. */
@@ -3221,6 +3237,7 @@ declare class AnvilWorldSource implements WorldChunkSource {
3221
3237
  private readonly pending;
3222
3238
  private readonly maxCachedRegions;
3223
3239
  private readonly maxCachedBytes;
3240
+ private readonly readExternalChunk?;
3224
3241
  private cachedBytes;
3225
3242
  constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
3226
3243
  /** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
@@ -3578,4 +3595,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
3578
3595
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
3579
3596
  }
3580
3597
 
3581
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
3598
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
@@ -3156,6 +3156,19 @@ declare class ChunkData {
3156
3156
  }
3157
3157
 
3158
3158
  type RegionInput = Uint8Array | ArrayBuffer;
3159
+ /** Reads `c.<x>.<z>.mcc` at absolute chunk coordinates, or returns `undefined` when the file is missing. */
3160
+ type AnvilExternalChunkReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3161
+ interface AnvilParseOptions {
3162
+ /** Region coordinates from `r.<x>.<z>.mca`, required when reading external chunks. */
3163
+ region?: {
3164
+ x: number;
3165
+ z: number;
3166
+ };
3167
+ /** Reads external chunk payloads without their region-file header. */
3168
+ readExternalChunk?: AnvilExternalChunkReader;
3169
+ /** Cancels parsing and forwards the signal to external chunk reads. */
3170
+ signal?: AbortSignal;
3171
+ }
3159
3172
  /** Chunk columns decoded from an Anvil region file. */
3160
3173
  interface AnvilRegion {
3161
3174
  chunks: AnvilChunk[];
@@ -3178,15 +3191,16 @@ declare class AnvilParser {
3178
3191
  x: number;
3179
3192
  z: number;
3180
3193
  }[];
3181
- /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
3182
- static parse(data: RegionInput): Promise<AnvilRegion>;
3194
+ /** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
3195
+ static parse(data: RegionInput, options?: AnvilParseOptions): Promise<AnvilRegion>;
3183
3196
  /**
3184
3197
  * Decodes one chunk for {@link MineRenderWorld.placeChunk}.
3185
3198
  * @param localX - Chunk x within the region, from 0 to 31.
3186
3199
  * @param localZ - Chunk z within the region, from 0 to 31.
3187
3200
  * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
3188
3201
  */
3189
- static parseChunk(data: RegionInput, localX: number, localZ: number): Promise<AnvilChunk | undefined>;
3202
+ static parseChunk(data: RegionInput, localX: number, localZ: number, options?: AnvilParseOptions): Promise<AnvilChunk | undefined>;
3203
+ private static abortable;
3190
3204
  private static bytes;
3191
3205
  private static locations;
3192
3206
  private static readChunk;
@@ -3207,8 +3221,10 @@ interface WorldChunkSource {
3207
3221
  * Forward `signal` to file or network I/O; it aborts when every caller waiting for the region cancels.
3208
3222
  */
3209
3223
  type AnvilRegionReader = (x: number, z: number, signal?: AbortSignal) => Promise<Uint8Array | ArrayBuffer | undefined>;
3210
- /** Cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3224
+ /** Readers and cache limits passed to `new AnvilWorldSource(readRegion, options)`. */
3211
3225
  interface AnvilWorldSourceOptions {
3226
+ /** Reads external `c.<x>.<z>.mcc` payloads at absolute chunk coordinates in the same dimension. */
3227
+ readExternalChunk?: AnvilExternalChunkReader;
3212
3228
  /** Maximum cached regions, including missing regions. Defaults to 4; 0 disables caching. */
3213
3229
  maxCachedRegions?: number;
3214
3230
  /** Maximum retained region bytes. Defaults to 64 MiB; larger regions are read without caching. */
@@ -3221,6 +3237,7 @@ declare class AnvilWorldSource implements WorldChunkSource {
3221
3237
  private readonly pending;
3222
3238
  private readonly maxCachedRegions;
3223
3239
  private readonly maxCachedBytes;
3240
+ private readonly readExternalChunk?;
3224
3241
  private cachedBytes;
3225
3242
  constructor(readRegion: AnvilRegionReader, options?: AnvilWorldSourceOptions);
3226
3243
  /** Decodes one column at absolute chunk coordinates. Aborting a caller leaves other shared readers active. */
@@ -3578,4 +3595,4 @@ declare class NodeCache extends PersistentCache<LocalStorage> {
3578
3595
  forEach<T>(callback: (v: T, k: string) => void): Promise<void>;
3579
3596
  }
3580
3597
 
3581
- export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
3598
+ export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, type AnvilExternalChunkReader, type AnvilParseOptions, AnvilParser, type AnvilRegion, type AnvilRegionReader, AnvilWorldSource, type AnvilWorldSourceOptions, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, type BannerPattern, type BannerPatternDraw, BannerPatterns, BasicAssetKey, type BasicMinecraftAsset, BatchedExecutor, type BedrockBone, type BedrockCube, type BedrockEntityDescription, type BedrockEntityFile, type BedrockGeometry, type BedrockGeometryFile, type BitmapFont, type BitmapGlyph, type Block, BlockEntities, type BlockEntityEntry, type BlockEntityIndex, type BlockEntityPart, type BlockEntityRotation, type BlockFluidState, type BlockInfo, type BlockModel, type BlockModelTextures, BlockObject, type BlockObjectOptions, type BlockState, type BlockStateMultipart, type BlockStateProperties, type BlockStateProperty, type BlockStatePropertyDefaults, type BlockStatePropertyValue, BlockStateResolver, type BlockStateVariant, type BlockStateVariants, BlockStates, BlockTints, type BoxGeometryKey, BrowserArchiveProxy, CUBE_FACES, CUBE_FACE_OFFSETS, type CacheKey, Caching, type CameraOptions, CanvasImage, type CapeLayout, Chunk, ChunkData, Colormaps, type CompatCanvas, type CompatImage, type ComposerOptions, type ControlsOptions, CubeFace, CubeFaceIndex, DEFAULT_ELEMENTS, DEFAULT_NAMESPACE, DEFAULT_ROOT, DEFAULT_UV, DISPLAY_POSITIONS, DYE_COLORS, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, type DyeColor, ENTITY_ANIMATION_CHANNELS, type ElementFace, type ElementRotation, Entities, type EntityAnimation, type EntityAnimationBone, type EntityAnimationChannel, type EntityAnimationFile, type EntityAnimationKeyframe, type EntityAnimationOptions, EntityAnimationPlayer, type EntityAnimationPose, type EntityLayer, type EntityModel, type EntityModelCube, type EntityModelFile, type EntityModelLayer, type EntityModelOptions, type EntityModelPart, type EntityModelPass, EntityObject, type EntityObjectOptions, type EntityRenderMode, type EntityTransformOp, Env, type EnvProvider, type ExtractableImageData, type FluidKind, FluidModelObject, type FluidSample, type FluidSampler, Fonts, type FrameCallback, type FromTo, GUI_CONTAINER_LAYOUTS, Geometries, type GuiBookButtonState, type GuiBookOptions, type GuiBossBarColor, type GuiBossBarOptions, type GuiContainerType, GuiHelper, type GuiItemLayer, type GuiLayer, GuiLight, GuiObject, type GuiObjectOptions, type GuiRecipe, type GuiRecipeIngredient, type GuiRecipeOptions, type GuiSpriteScaling, type GuiText, type GuiTextLayer, type GuiTextLayout, type GuiTextOptions, type GuiTextRun, type GuiTextStyle, type GuiTextureLayer, type GuiTooltipOptions, HostedAssetSource, type IModelTextures, ITEM_GENERATED, type ImageInfo, ImageLoader, type ImageSizeInfo, InstanceManager, InstanceReference, type Instanceable, type ItemModel, type ItemModelContext, type ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, LitematicaParser, type LitematicaRegion, type LitematicaStructure, type LoadedSceneDocument, type LoadedSceneObject, MapControls, type MaterialKey, Materials, type Maybe, type MeshKey, Meshes, MineRenderError, MineRenderScene, type MineRenderSceneOptions, MineRenderWorld, type MineRenderWorldOptions, type MinecraftAsset, MinecraftCubeTexture, MinecraftFaceUV, type MinecraftTextureMeta, type Model, ModelCulling, type ModelDisplay, type ModelElement, type ModelFaces, ModelGenerator, ModelMerger, ModelObject, type ModelObjectOptions, ModelTextures, Models, type MultiBlockBlock, type MultiBlockEntity, type MultiBlockStructure, type MultipartCondition, type NBTAsset, NBTHelper, NodeCache, NodeEnv, OrbitControls, type PackFormat, PackFormats, PackMetadata, PersistentCache, type PositionedGuiGlyph, type QuadArray, type RawImageKey, type RenderOptions, Renderer, type RendererFrame, type RendererOptions, type RequestConfig, RequestError, type RequestResponse, Requests, type ResolvedBlockEntity, type ResponseParser, SKIN_PARTS, type SceneBlockDefinition, type SceneDocument, SceneDocumentLoader, type SceneEntityDefinition, SceneExporter, type SceneGLTFExportOptions, type SceneGuiDefinition, type SceneGuiLayer, SceneInspector, type SceneModelDefinition, SceneObject, type SceneObjectDefinition, type SceneObjectDefinitionBase, type SceneObjectOptions, type SceneSkinDefinition, type SceneSkinPosePart, SceneStats, SceneStatsDisplay, SchematicParser, type SchematicParserOptions, type SectionAtlasSize, type SectionGeometryInput, type SectionGeometryPage, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type SectionTemplateData, SectionWorker, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, SpongeSchematicParser, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, type VideoExportOptions, VideoExporter, type WorldChunkSource, WorldStreamer, type WorldStreamerOptions, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, buildSectionGeometry, capeTextureSizes, captureException, changeEvent, clampRotationDegrees, classicSkinGeometries, classicSkinTextureCoordinates, computeMorphedAttributes, createCanvas, createFluidGeometry, createGuiTextGeometry, createGuiTextureGeometry, createImage, entityAnimationTime, estimateBytesUsed, getBlockFluidState, getFluidKind, interleaveAttributes, isAssetKey, isBasicAssetKey, isBlockObject, isDisposable, isDoubleArray, isEntityObject, isGuiObject, isInstanceManager, isInstanceReference, isInstanceable, isInstancedMesh, isMesh, isMineRenderScene, isModelObject, isObject3D, isOrthographicCamera, isPerspectiveCamera, isQuadArray, isSceneObject, isTransformable, isTripleArray, isVector3, layoutGuiText, md5, mergeBufferAttributes, mergeBufferGeometries, mergeVertices, parseSceneDocument, prefix, registerNodeEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, sectionGeometryTransferables, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas, yieldToEventLoop };
@@ -29113,17 +29113,138 @@ var ChunkData = class _ChunkData {
29113
29113
  }
29114
29114
  };
29115
29115
 
29116
+ // src/world/_compression/Lz4.ts
29117
+ init_MineRenderError();
29118
+ function decodeAnvilLz4(data) {
29119
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
29120
+ const blocks = [];
29121
+ let cursor = 0, totalSize = 0;
29122
+ while (true) {
29123
+ if (cursor + 21 > data.length) throw invalid("truncated block header or missing terminator");
29124
+ if (view.getUint32(cursor) !== 1280980034 || view.getUint32(cursor + 4) !== 1819239275) {
29125
+ throw invalid("invalid block signature");
29126
+ }
29127
+ const token = data[cursor + 8];
29128
+ const method = token & 240;
29129
+ const size = view.getInt32(cursor + 9, true);
29130
+ const decodedSize = view.getInt32(cursor + 13, true);
29131
+ const checksum = view.getUint32(cursor + 17, true);
29132
+ cursor += 21;
29133
+ if (method !== 16 && method !== 32) throw invalid("unsupported block method");
29134
+ if (size < 0 || decodedSize < 0 || decodedSize > 2 ** (10 + (token & 15)) || size === 0 !== (decodedSize === 0) || method === 16 && size !== decodedSize) {
29135
+ throw invalid("invalid block lengths");
29136
+ }
29137
+ if (size === 0) {
29138
+ if (checksum !== 0 || cursor !== data.length) throw invalid("invalid terminator or trailing bytes");
29139
+ break;
29140
+ }
29141
+ if (cursor + size > data.length || decodedSize > size * 255) throw invalid("invalid block lengths");
29142
+ blocks.push({ start: cursor, size, decodedSize, raw: method === 16, checksum });
29143
+ totalSize += decodedSize;
29144
+ cursor += size;
29145
+ }
29146
+ const output = new Uint8Array(totalSize);
29147
+ let offset = 0;
29148
+ for (const block of blocks) {
29149
+ const source = data.subarray(block.start, block.start + block.size);
29150
+ const target = output.subarray(offset, offset + block.decodedSize);
29151
+ if (block.raw) target.set(source);
29152
+ else decodeBlock(source, target);
29153
+ if (checksum32(target) !== block.checksum) throw invalid("block checksum mismatch");
29154
+ offset += block.decodedSize;
29155
+ }
29156
+ return output;
29157
+ }
29158
+ function decodeBlock(source, target) {
29159
+ let input = 0, output = 0, matched = false;
29160
+ const length = (nibble) => {
29161
+ let value = nibble;
29162
+ if (value === 15) {
29163
+ let extension;
29164
+ do {
29165
+ if (input === source.length) throw invalid("truncated sequence length");
29166
+ extension = source[input++];
29167
+ value += extension;
29168
+ } while (extension === 255);
29169
+ }
29170
+ return value;
29171
+ };
29172
+ while (input < source.length) {
29173
+ const token = source[input++];
29174
+ const literals = length(token >>> 4);
29175
+ if (input + literals > source.length || output + literals > target.length) {
29176
+ throw invalid("literal sequence exceeds block bounds");
29177
+ }
29178
+ target.set(source.subarray(input, input + literals), output);
29179
+ input += literals;
29180
+ output += literals;
29181
+ if (input === source.length) {
29182
+ if (output !== target.length || matched && literals < 5) throw invalid("invalid final literal sequence");
29183
+ return;
29184
+ }
29185
+ if (input + 2 > source.length) throw invalid("truncated match offset");
29186
+ const distance = source[input] | source[input + 1] << 8;
29187
+ input += 2;
29188
+ if (distance === 0 || distance > output) throw invalid("match offset exceeds block history");
29189
+ const count = length(token & 15) + 4;
29190
+ if (output > target.length - 12 || output + count > target.length - 5) {
29191
+ throw invalid("match exceeds block bounds");
29192
+ }
29193
+ for (let end = output + count; output < end; output++) target[output] = target[output - distance];
29194
+ matched = true;
29195
+ }
29196
+ throw invalid("missing final literal sequence");
29197
+ }
29198
+ function checksum32(data) {
29199
+ const prime1 = 2654435761, prime2 = 2246822519, prime3 = 3266489917, prime4 = 668265263, prime5 = 374761393;
29200
+ const seed = 2538058380;
29201
+ const rotate = (value, bits) => value << bits | value >>> 32 - bits;
29202
+ const round = (value, word) => Math.imul(rotate(value + Math.imul(word, prime2), 13), prime1);
29203
+ const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
29204
+ let cursor = 0, hash;
29205
+ if (data.length >= 16) {
29206
+ let a = seed + prime1 + prime2, b = seed + prime2, c = seed, d = seed - prime1;
29207
+ while (cursor + 16 <= data.length) {
29208
+ a = round(a, view.getUint32(cursor, true));
29209
+ b = round(b, view.getUint32(cursor + 4, true));
29210
+ c = round(c, view.getUint32(cursor + 8, true));
29211
+ d = round(d, view.getUint32(cursor + 12, true));
29212
+ cursor += 16;
29213
+ }
29214
+ hash = rotate(a, 1) + rotate(b, 7) + rotate(c, 12) + rotate(d, 18);
29215
+ } else {
29216
+ hash = seed + prime5;
29217
+ }
29218
+ hash += data.length;
29219
+ while (cursor + 4 <= data.length) {
29220
+ hash = Math.imul(rotate(hash + Math.imul(view.getUint32(cursor, true), prime3), 17), prime4);
29221
+ cursor += 4;
29222
+ }
29223
+ while (cursor < data.length) {
29224
+ hash = Math.imul(rotate(hash + Math.imul(data[cursor++], prime5), 11), prime1);
29225
+ }
29226
+ hash = Math.imul(hash ^ hash >>> 15, prime2);
29227
+ hash = Math.imul(hash ^ hash >>> 13, prime3);
29228
+ return (hash ^ hash >>> 16) & 268435455;
29229
+ }
29230
+ function invalid(detail) {
29231
+ return new MineRenderError(`Invalid Anvil LZ4 stream: ${detail}`);
29232
+ }
29233
+
29116
29234
  // src/world/AnvilParser.ts
29117
29235
  var AnvilParser = class {
29118
29236
  /** Lists occupied chunk positions within the region, using local coordinates from 0 to 31. */
29119
29237
  static getChunkList(data) {
29120
29238
  return this.locations(this.bytes(data)).map(({ x, z }) => ({ x, z }));
29121
29239
  }
29122
- /** Decodes all stored chunks. Gzip, zlib, and uncompressed payloads are supported. */
29123
- static async parse(data) {
29240
+ /** Decodes all stored chunks. Gzip, zlib, LZ4, and uncompressed payloads are supported. */
29241
+ static async parse(data, options = {}) {
29242
+ options.signal?.throwIfAborted();
29124
29243
  const bytes = this.bytes(data);
29125
29244
  const chunks = [];
29126
- for (const location of this.locations(bytes)) chunks.push(await this.readChunk(bytes, location));
29245
+ for (const location of this.locations(bytes)) {
29246
+ chunks.push(await this.abortable(this.readChunk(bytes, location, options), options.signal));
29247
+ }
29127
29248
  return { chunks };
29128
29249
  }
29129
29250
  /**
@@ -29132,13 +29253,28 @@ var AnvilParser = class {
29132
29253
  * @param localZ - Chunk z within the region, from 0 to 31.
29133
29254
  * @returns The chunk with absolute coordinates, or `undefined` if the region has no chunk there.
29134
29255
  */
29135
- static async parseChunk(data, localX, localZ) {
29256
+ static async parseChunk(data, localX, localZ, options = {}) {
29257
+ options.signal?.throwIfAborted();
29136
29258
  if (![localX, localZ].every((value) => Number.isInteger(value) && value >= 0 && value < 32)) {
29137
29259
  throw new RangeError("Region-local chunk coordinates must be integers from 0 to 31");
29138
29260
  }
29139
29261
  const bytes = this.bytes(data);
29140
29262
  const location = this.locations(bytes).find(({ x, z }) => x === localX && z === localZ);
29141
- return location ? this.readChunk(bytes, location) : void 0;
29263
+ return location ? this.abortable(this.readChunk(bytes, location, options), options.signal) : void 0;
29264
+ }
29265
+ static async abortable(promise, signal) {
29266
+ if (!signal) return promise;
29267
+ let abort;
29268
+ const cancelled = new Promise((_, reject) => {
29269
+ abort = () => reject(signal.reason);
29270
+ signal.addEventListener("abort", abort, { once: true });
29271
+ if (signal.aborted) abort();
29272
+ });
29273
+ try {
29274
+ return await Promise.race([promise, cancelled]);
29275
+ } finally {
29276
+ signal.removeEventListener("abort", abort);
29277
+ }
29142
29278
  }
29143
29279
  static bytes(data) {
29144
29280
  return data instanceof Uint8Array ? data : new Uint8Array(data);
@@ -29164,18 +29300,41 @@ var AnvilParser = class {
29164
29300
  }
29165
29301
  return locations;
29166
29302
  }
29167
- static async readChunk(data, location) {
29168
- const compression = data[location.offset + 4];
29169
- if (compression & 128) throw new MineRenderError("External Anvil .mcc chunks are not supported");
29170
- if (compression !== 1 && compression !== 2 && compression !== 3) {
29171
- throw new MineRenderError(`Unsupported Anvil compression ${compression}${compression === 4 ? " (LZ4)" : ""}`);
29303
+ static async readChunk(data, location, options) {
29304
+ options.signal?.throwIfAborted();
29305
+ const format2 = data[location.offset + 4];
29306
+ const external = (format2 & 128) !== 0;
29307
+ const compression = format2 & 127;
29308
+ if (compression !== 1 && compression !== 2 && compression !== 3 && compression !== 4) {
29309
+ throw new MineRenderError(`Unsupported Anvil compression ${compression}`);
29172
29310
  }
29173
29311
  let payload = data.subarray(location.offset + 5, location.offset + 4 + location.length);
29174
- if (compression !== 3) {
29312
+ let expected;
29313
+ if (external) {
29314
+ if (!options.region || !options.readExternalChunk) {
29315
+ throw new MineRenderError("External Anvil .mcc chunks require region coordinates and readExternalChunk");
29316
+ }
29317
+ if (![options.region.x, options.region.z].every(Number.isSafeInteger)) {
29318
+ throw new RangeError("Anvil region coordinates must be safe integers");
29319
+ }
29320
+ expected = { x: options.region.x * 32 + location.x, z: options.region.z * 32 + location.z };
29321
+ if (![expected.x, expected.z].every(Number.isSafeInteger)) {
29322
+ throw new RangeError("External Anvil chunk coordinates must be safe integers");
29323
+ }
29324
+ const externalData = await options.readExternalChunk(expected.x, expected.z, options.signal);
29325
+ options.signal?.throwIfAborted();
29326
+ if (externalData === void 0) throw new MineRenderError(`External Anvil chunk c.${expected.x}.${expected.z}.mcc is missing`);
29327
+ payload = this.bytes(externalData);
29328
+ }
29329
+ if (compression === 4) {
29330
+ payload = decodeAnvilLz4(payload);
29331
+ } else if (compression !== 3) {
29175
29332
  const stream = new Blob([payload]).stream().pipeThrough(new DecompressionStream(compression === 1 ? "gzip" : "deflate"));
29176
29333
  payload = new Uint8Array(await new Response(stream).arrayBuffer());
29177
29334
  }
29335
+ options.signal?.throwIfAborted();
29178
29336
  const nbt = await NBTHelper.fromBuffer(payload, "big");
29337
+ options.signal?.throwIfAborted();
29179
29338
  const root = nbt.value;
29180
29339
  const level = root.Level?.type === "compound" ? root.Level.value : root;
29181
29340
  const dataVersion = root.DataVersion?.type === "int" ? root.DataVersion.value : void 0;
@@ -29188,6 +29347,9 @@ var AnvilParser = class {
29188
29347
  if ((chunk.x % 32 + 32) % 32 !== location.x || (chunk.z % 32 + 32) % 32 !== location.z) {
29189
29348
  throw new MineRenderError("Anvil chunk coordinates do not match its region location");
29190
29349
  }
29350
+ if (expected && (chunk.x !== expected.x || chunk.z !== expected.z)) {
29351
+ throw new MineRenderError(`Anvil chunk coordinates do not match external file c.${expected.x}.${expected.z}.mcc`);
29352
+ }
29191
29353
  for (const section of this.compounds(level.sections ?? level.Sections, "sections")) {
29192
29354
  const y = this.integer(section.Y, "section Y");
29193
29355
  if (section.Blocks || section.Data || section.Add) {
@@ -29319,6 +29481,7 @@ var AnvilWorldSource = class {
29319
29481
  this.cachedBytes = 0;
29320
29482
  this.maxCachedRegions = options.maxCachedRegions ?? 4;
29321
29483
  this.maxCachedBytes = options.maxCachedBytes ?? 64 * 1024 * 1024;
29484
+ this.readExternalChunk = options.readExternalChunk;
29322
29485
  for (const [name, value] of Object.entries({ maxCachedRegions: this.maxCachedRegions, maxCachedBytes: this.maxCachedBytes })) {
29323
29486
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name} must be a nonnegative safe integer`);
29324
29487
  }
@@ -29332,7 +29495,11 @@ var AnvilWorldSource = class {
29332
29495
  const data = await this.getRegion(regionX, regionZ, signal);
29333
29496
  signal?.throwIfAborted();
29334
29497
  if (!data) return void 0;
29335
- const chunk = await abortable2(AnvilParser.parseChunk(data, x - regionX * 32, z - regionZ * 32), signal);
29498
+ const chunk = await AnvilParser.parseChunk(data, x - regionX * 32, z - regionZ * 32, {
29499
+ region: { x: regionX, z: regionZ },
29500
+ readExternalChunk: this.readExternalChunk,
29501
+ signal
29502
+ });
29336
29503
  signal?.throwIfAborted();
29337
29504
  if (chunk && (chunk.x !== x || chunk.z !== z)) {
29338
29505
  throw new MineRenderError(`Anvil chunk coordinates ${chunk.x},${chunk.z} do not match requested column ${x},${z}`);
@@ -29363,7 +29530,7 @@ var AnvilWorldSource = class {
29363
29530
  settled: false,
29364
29531
  promise: Promise.resolve().then(() => {
29365
29532
  controller.signal.throwIfAborted();
29366
- return this.readRegion(x, z, controller.signal);
29533
+ return abortable2(this.readRegion(x, z, controller.signal), controller.signal);
29367
29534
  }).then((data) => {
29368
29535
  controller.signal.throwIfAborted();
29369
29536
  let bytes = data instanceof Uint8Array ? data : data === void 0 ? void 0 : new Uint8Array(data);