minerender 2.1.0-alpha.77 → 2.1.0-alpha.78
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.
- package/dist/browser/index.d.mts +57 -2
- package/dist/browser/index.d.ts +57 -2
- package/dist/browser/index.js +127 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +127 -3
- package/dist/browser/index.mjs.map +1 -1
- package/dist/bundle.js +127 -3
- package/dist/bundle.js.map +1 -1
- package/dist/node/index.d.mts +57 -2
- package/dist/node/index.d.ts +57 -2
- package/dist/node/index.js +128 -3
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +127 -3
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.d.mts
CHANGED
|
@@ -2334,8 +2334,45 @@ declare class SceneExporter {
|
|
|
2334
2334
|
static toGLTF(root: Object3D, options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
2335
2335
|
}
|
|
2336
2336
|
|
|
2337
|
+
/** Container coordinates in GUI pixels. Crops refer to vanilla's 256×256 sheets; {@link GuiHelper.container} scales them for resource packs. */
|
|
2338
|
+
declare const GUI_CONTAINER_LAYOUTS: {
|
|
2339
|
+
readonly generic_54: {
|
|
2340
|
+
readonly texture: "minecraft:gui/container/generic_54";
|
|
2341
|
+
readonly crop: readonly [0, 0, 176, 222];
|
|
2342
|
+
readonly slotOrigin: readonly [8, 18];
|
|
2343
|
+
readonly slotOffset: readonly [18, 18];
|
|
2344
|
+
readonly rowSize: 9;
|
|
2345
|
+
readonly slotCount: 54;
|
|
2346
|
+
};
|
|
2347
|
+
readonly crafting_table: {
|
|
2348
|
+
readonly texture: "minecraft:gui/container/crafting_table";
|
|
2349
|
+
readonly crop: readonly [0, 0, 176, 166];
|
|
2350
|
+
readonly slotOrigin: readonly [30, 17];
|
|
2351
|
+
readonly slotOffset: readonly [18, 18];
|
|
2352
|
+
readonly rowSize: 3;
|
|
2353
|
+
readonly slotCount: 9;
|
|
2354
|
+
readonly resultPosition: readonly [124, 35];
|
|
2355
|
+
};
|
|
2356
|
+
};
|
|
2357
|
+
type GuiContainerType = keyof typeof GUI_CONTAINER_LAYOUTS;
|
|
2358
|
+
type GuiBossBarColor = "pink" | "blue" | "red" | "green" | "yellow" | "purple" | "white";
|
|
2359
|
+
type GuiBookButtonState = "hidden" | "normal" | "hover";
|
|
2337
2360
|
/** Creates GUI positions and layer lists for {@link MineRenderScene.addGui}. */
|
|
2338
2361
|
declare class GuiHelper {
|
|
2362
|
+
/**
|
|
2363
|
+
* Creates a 182×5 boss bar using the active resource pack. Finite progress is clamped to 0–1.
|
|
2364
|
+
* The fill crops the source image; explicit crops do not apply `.mcmeta` sprite scaling.
|
|
2365
|
+
*/
|
|
2366
|
+
static bossBar(options?: GuiBossBarOptions): Promise<GuiLayer[]>;
|
|
2367
|
+
/**
|
|
2368
|
+
* Creates a 192×192 book page with optional arrows and supplied text. Buttons are hidden by default.
|
|
2369
|
+
* Callers choose the page content and button states; this helper does not paginate or handle clicks.
|
|
2370
|
+
*/
|
|
2371
|
+
static book(options?: GuiBookOptions): Promise<GuiLayer[]>;
|
|
2372
|
+
/** Creates a container background. Use {@link GUI_CONTAINER_LAYOUTS} with {@link inventorySlot} to place its items. */
|
|
2373
|
+
static container(type: GuiContainerType, position?: [number, number]): Promise<GuiLayer[]>;
|
|
2374
|
+
private static validatePosition;
|
|
2375
|
+
private static cropTexture;
|
|
2339
2376
|
/** Sizes a tooltip around supplied text; the first entry is its title. */
|
|
2340
2377
|
static tooltip(lines: readonly GuiText[], options?: GuiTooltipOptions): Promise<GuiLayer[]>;
|
|
2341
2378
|
/**
|
|
@@ -2345,10 +2382,28 @@ declare class GuiHelper {
|
|
|
2345
2382
|
* @param offset - Horizontal and vertical spacing between slot origins, in pixels.
|
|
2346
2383
|
* @param rowSize - Slots per row when `slot` is an index.
|
|
2347
2384
|
*/
|
|
2348
|
-
static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
|
|
2385
|
+
static inventorySlot(slot: number | readonly [number, number], origin?: readonly [number, number], offset?: readonly [number, number], rowSize?: number): [number, number];
|
|
2349
2386
|
/** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
|
|
2350
2387
|
static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
|
|
2351
2388
|
}
|
|
2389
|
+
/** Settings passed to {@link GuiHelper.bossBar}. */
|
|
2390
|
+
interface GuiBossBarOptions {
|
|
2391
|
+
/** Vanilla sprite color. Defaults to `pink`. */
|
|
2392
|
+
color?: GuiBossBarColor;
|
|
2393
|
+
/** Fill from 0 to 1, rounded to vanilla's discrete pixel width. Defaults to 1. */
|
|
2394
|
+
progress?: number;
|
|
2395
|
+
/** Top-left position in GUI pixels. Defaults to `[0, 0]`. */
|
|
2396
|
+
position?: [number, number];
|
|
2397
|
+
}
|
|
2398
|
+
/** Settings passed to {@link GuiHelper.book}. Text defaults to black, unshadowed, and wrapped at 114 pixels. */
|
|
2399
|
+
interface GuiBookOptions extends GuiTextOptions {
|
|
2400
|
+
/** Top-left position of the book background in GUI pixels. Defaults to `[0, 0]`. */
|
|
2401
|
+
position?: [number, number];
|
|
2402
|
+
previous?: GuiBookButtonState;
|
|
2403
|
+
next?: GuiBookButtonState;
|
|
2404
|
+
/** Content for one page. The caller keeps it within the 128-pixel text height. */
|
|
2405
|
+
text?: GuiText;
|
|
2406
|
+
}
|
|
2352
2407
|
/** Settings passed to {@link GuiHelper.tooltip}. Its default `lineHeight` is 10 GUI pixels. */
|
|
2353
2408
|
interface GuiTooltipOptions extends GuiTextOptions {
|
|
2354
2409
|
/** Top-left text position, inside the tooltip's padding. */
|
|
@@ -3155,4 +3210,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
3155
3210
|
*/
|
|
3156
3211
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
3157
3212
|
|
|
3158
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, 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, BrowserCache, BrowserEnv, 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, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, 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, Geometries, 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 ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, 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, 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, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, 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, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|
|
3213
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, 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, BrowserCache, BrowserEnv, 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, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, 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 ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, 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, 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, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, 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, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -2334,8 +2334,45 @@ declare class SceneExporter {
|
|
|
2334
2334
|
static toGLTF(root: Object3D, options?: SceneGLTFExportOptions): Promise<Record<string, any> | ArrayBuffer>;
|
|
2335
2335
|
}
|
|
2336
2336
|
|
|
2337
|
+
/** Container coordinates in GUI pixels. Crops refer to vanilla's 256×256 sheets; {@link GuiHelper.container} scales them for resource packs. */
|
|
2338
|
+
declare const GUI_CONTAINER_LAYOUTS: {
|
|
2339
|
+
readonly generic_54: {
|
|
2340
|
+
readonly texture: "minecraft:gui/container/generic_54";
|
|
2341
|
+
readonly crop: readonly [0, 0, 176, 222];
|
|
2342
|
+
readonly slotOrigin: readonly [8, 18];
|
|
2343
|
+
readonly slotOffset: readonly [18, 18];
|
|
2344
|
+
readonly rowSize: 9;
|
|
2345
|
+
readonly slotCount: 54;
|
|
2346
|
+
};
|
|
2347
|
+
readonly crafting_table: {
|
|
2348
|
+
readonly texture: "minecraft:gui/container/crafting_table";
|
|
2349
|
+
readonly crop: readonly [0, 0, 176, 166];
|
|
2350
|
+
readonly slotOrigin: readonly [30, 17];
|
|
2351
|
+
readonly slotOffset: readonly [18, 18];
|
|
2352
|
+
readonly rowSize: 3;
|
|
2353
|
+
readonly slotCount: 9;
|
|
2354
|
+
readonly resultPosition: readonly [124, 35];
|
|
2355
|
+
};
|
|
2356
|
+
};
|
|
2357
|
+
type GuiContainerType = keyof typeof GUI_CONTAINER_LAYOUTS;
|
|
2358
|
+
type GuiBossBarColor = "pink" | "blue" | "red" | "green" | "yellow" | "purple" | "white";
|
|
2359
|
+
type GuiBookButtonState = "hidden" | "normal" | "hover";
|
|
2337
2360
|
/** Creates GUI positions and layer lists for {@link MineRenderScene.addGui}. */
|
|
2338
2361
|
declare class GuiHelper {
|
|
2362
|
+
/**
|
|
2363
|
+
* Creates a 182×5 boss bar using the active resource pack. Finite progress is clamped to 0–1.
|
|
2364
|
+
* The fill crops the source image; explicit crops do not apply `.mcmeta` sprite scaling.
|
|
2365
|
+
*/
|
|
2366
|
+
static bossBar(options?: GuiBossBarOptions): Promise<GuiLayer[]>;
|
|
2367
|
+
/**
|
|
2368
|
+
* Creates a 192×192 book page with optional arrows and supplied text. Buttons are hidden by default.
|
|
2369
|
+
* Callers choose the page content and button states; this helper does not paginate or handle clicks.
|
|
2370
|
+
*/
|
|
2371
|
+
static book(options?: GuiBookOptions): Promise<GuiLayer[]>;
|
|
2372
|
+
/** Creates a container background. Use {@link GUI_CONTAINER_LAYOUTS} with {@link inventorySlot} to place its items. */
|
|
2373
|
+
static container(type: GuiContainerType, position?: [number, number]): Promise<GuiLayer[]>;
|
|
2374
|
+
private static validatePosition;
|
|
2375
|
+
private static cropTexture;
|
|
2339
2376
|
/** Sizes a tooltip around supplied text; the first entry is its title. */
|
|
2340
2377
|
static tooltip(lines: readonly GuiText[], options?: GuiTooltipOptions): Promise<GuiLayer[]>;
|
|
2341
2378
|
/**
|
|
@@ -2345,10 +2382,28 @@ declare class GuiHelper {
|
|
|
2345
2382
|
* @param offset - Horizontal and vertical spacing between slot origins, in pixels.
|
|
2346
2383
|
* @param rowSize - Slots per row when `slot` is an index.
|
|
2347
2384
|
*/
|
|
2348
|
-
static inventorySlot(slot: number | [number, number], origin?: [number, number], offset?: [number, number], rowSize?: number): [number, number];
|
|
2385
|
+
static inventorySlot(slot: number | readonly [number, number], origin?: readonly [number, number], offset?: readonly [number, number], rowSize?: number): [number, number];
|
|
2349
2386
|
/** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
|
|
2350
2387
|
static recipe(recipe: GuiRecipe, options?: GuiRecipeOptions): GuiLayer[];
|
|
2351
2388
|
}
|
|
2389
|
+
/** Settings passed to {@link GuiHelper.bossBar}. */
|
|
2390
|
+
interface GuiBossBarOptions {
|
|
2391
|
+
/** Vanilla sprite color. Defaults to `pink`. */
|
|
2392
|
+
color?: GuiBossBarColor;
|
|
2393
|
+
/** Fill from 0 to 1, rounded to vanilla's discrete pixel width. Defaults to 1. */
|
|
2394
|
+
progress?: number;
|
|
2395
|
+
/** Top-left position in GUI pixels. Defaults to `[0, 0]`. */
|
|
2396
|
+
position?: [number, number];
|
|
2397
|
+
}
|
|
2398
|
+
/** Settings passed to {@link GuiHelper.book}. Text defaults to black, unshadowed, and wrapped at 114 pixels. */
|
|
2399
|
+
interface GuiBookOptions extends GuiTextOptions {
|
|
2400
|
+
/** Top-left position of the book background in GUI pixels. Defaults to `[0, 0]`. */
|
|
2401
|
+
position?: [number, number];
|
|
2402
|
+
previous?: GuiBookButtonState;
|
|
2403
|
+
next?: GuiBookButtonState;
|
|
2404
|
+
/** Content for one page. The caller keeps it within the 128-pixel text height. */
|
|
2405
|
+
text?: GuiText;
|
|
2406
|
+
}
|
|
2352
2407
|
/** Settings passed to {@link GuiHelper.tooltip}. Its default `lineHeight` is 10 GUI pixels. */
|
|
2353
2408
|
interface GuiTooltipOptions extends GuiTextOptions {
|
|
2354
2409
|
/** Top-left text position, inside the tooltip's padding. */
|
|
@@ -3155,4 +3210,4 @@ declare class BrowserCache extends PersistentCache<LocalForage> {
|
|
|
3155
3210
|
*/
|
|
3156
3211
|
declare function probeImageSize(data: Uint8Array): ImageSizeInfo;
|
|
3157
3212
|
|
|
3158
|
-
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, 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, BrowserCache, BrowserEnv, 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, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, 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, Geometries, 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 ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, 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, 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, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, 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, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|
|
3213
|
+
export { AXES, type AnimationFrame, type AnimationMeta, type AnimatorFunction, type AnvilChunk, AnvilParser, type AnvilRegion, ArchiveAssetSource, type ArchiveAssetSourceOptions, type ArchiveEntry, type ArchiveProxy, AssetKey, AssetLoadError, AssetLoader, AssetParser, AssetSource, type AssetType, Assets, Axis, BUILTIN_ENTITY, BUILTIN_GENERATED, 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, BrowserCache, BrowserEnv, 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, type DebugOptions, type DeepPartial, DefaultBlockStates, DisplayPosition, DisplayTransforms, type Disposable, type DoubleArray, 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 ItemModelTextures, type ItemTintColor, type ItemTintSource, ItemTints, type ListAsset, 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, 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, SectionMesh, type SectionMeshEntry, type SectionMeshTemplate, SectionModels, type Serializable, type SkinGeometries, SkinImage, SkinObject, type SkinObjectOptions, SkinPart, type SkinTexture, type SkinTextureCoordinates, SkinTextures, Skins, type SpecialItemPart, type SpecialItemRenderer, SpecialItems, type StructureNBT, StructureParser, type TextureAsset, TextureAtlas, type TextureKey, TextureLoader, Textures, Ticker, type TickerFunction, TintColors, type Transformable, type TripleArray, UVMapper, WrappedImage, addBox3WireframeToObject, addWireframeToMesh, addWireframeToObject, applyElementRotation, applyGenericRotation, axisToVec3, base64decode, base64encode, 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, probeImageSize, registerBrowserEnv, sampleEntityAnimation, sampleEntityKeyframes, sampleFluid, serializeBoxGeometryKey, serializeImageKey, serializeMaterialKey, serializeMeshKey, serializeTextureKey, sha1, sha256, sha512, shutdown, sleep, slimSkinGeometries, slimSkinTextureCoordinates, timingEnd, timingStart, toDegrees, toRadians, toTrianglesDrawMode, trimCanvas };
|
package/dist/browser/index.js
CHANGED
|
@@ -5970,6 +5970,7 @@ __export(index_browser_exports, {
|
|
|
5970
5970
|
Env: () => Env,
|
|
5971
5971
|
FluidModelObject: () => FluidModelObject,
|
|
5972
5972
|
Fonts: () => Fonts,
|
|
5973
|
+
GUI_CONTAINER_LAYOUTS: () => GUI_CONTAINER_LAYOUTS,
|
|
5973
5974
|
Geometries: () => Geometries,
|
|
5974
5975
|
GuiHelper: () => GuiHelper,
|
|
5975
5976
|
GuiLight: () => GuiLight,
|
|
@@ -9401,6 +9402,7 @@ function copyDataTexture(source) {
|
|
|
9401
9402
|
|
|
9402
9403
|
// src/gui/GuiHelper.ts
|
|
9403
9404
|
init_AssetKey();
|
|
9405
|
+
init_ModelTextures();
|
|
9404
9406
|
|
|
9405
9407
|
// src/gui/GuiText.ts
|
|
9406
9408
|
var import_three20 = require("three");
|
|
@@ -9510,7 +9512,128 @@ function createGuiTextGeometry(layout, shadow = true) {
|
|
|
9510
9512
|
}
|
|
9511
9513
|
|
|
9512
9514
|
// src/gui/GuiHelper.ts
|
|
9515
|
+
var GUI_CONTAINER_LAYOUTS = {
|
|
9516
|
+
generic_54: {
|
|
9517
|
+
texture: "minecraft:gui/container/generic_54",
|
|
9518
|
+
crop: [0, 0, 176, 222],
|
|
9519
|
+
slotOrigin: [8, 18],
|
|
9520
|
+
slotOffset: [18, 18],
|
|
9521
|
+
rowSize: 9,
|
|
9522
|
+
slotCount: 54
|
|
9523
|
+
},
|
|
9524
|
+
crafting_table: {
|
|
9525
|
+
texture: "minecraft:gui/container/crafting_table",
|
|
9526
|
+
crop: [0, 0, 176, 166],
|
|
9527
|
+
slotOrigin: [30, 17],
|
|
9528
|
+
slotOffset: [18, 18],
|
|
9529
|
+
rowSize: 3,
|
|
9530
|
+
slotCount: 9,
|
|
9531
|
+
resultPosition: [124, 35]
|
|
9532
|
+
}
|
|
9533
|
+
};
|
|
9513
9534
|
var GuiHelper = class {
|
|
9535
|
+
/**
|
|
9536
|
+
* Creates a 182×5 boss bar using the active resource pack. Finite progress is clamped to 0–1.
|
|
9537
|
+
* The fill crops the source image; explicit crops do not apply `.mcmeta` sprite scaling.
|
|
9538
|
+
*/
|
|
9539
|
+
static async bossBar(options = {}) {
|
|
9540
|
+
const { color: color2 = "pink", progress = 1, position = [0, 0] } = options;
|
|
9541
|
+
this.validatePosition(position);
|
|
9542
|
+
if (!["pink", "blue", "red", "green", "yellow", "purple", "white"].includes(color2)) {
|
|
9543
|
+
throw new Error(`Unsupported boss bar color: ${color2}`);
|
|
9544
|
+
}
|
|
9545
|
+
if (!Number.isFinite(progress)) throw new Error("Boss bar progress must be finite");
|
|
9546
|
+
const value = Math.max(0, Math.min(1, progress));
|
|
9547
|
+
const width = value > 0 ? Math.floor(value * 181) + 1 : 0;
|
|
9548
|
+
const texture = `minecraft:gui/sprites/boss_bar/${color2}`;
|
|
9549
|
+
const layers = [{
|
|
9550
|
+
name: "boss-bar-background",
|
|
9551
|
+
texture: `${texture}_background`,
|
|
9552
|
+
position: [...position],
|
|
9553
|
+
size: [182, 5]
|
|
9554
|
+
}];
|
|
9555
|
+
if (width > 0) {
|
|
9556
|
+
layers.push({
|
|
9557
|
+
...await this.cropTexture(`${texture}_progress`, [0, 0, width, 5], [182, 5], position),
|
|
9558
|
+
name: "boss-bar-progress"
|
|
9559
|
+
});
|
|
9560
|
+
}
|
|
9561
|
+
return layers;
|
|
9562
|
+
}
|
|
9563
|
+
/**
|
|
9564
|
+
* Creates a 192×192 book page with optional arrows and supplied text. Buttons are hidden by default.
|
|
9565
|
+
* Callers choose the page content and button states; this helper does not paginate or handle clicks.
|
|
9566
|
+
*/
|
|
9567
|
+
static async book(options = {}) {
|
|
9568
|
+
const {
|
|
9569
|
+
position = [0, 0],
|
|
9570
|
+
previous = "hidden",
|
|
9571
|
+
next = "hidden",
|
|
9572
|
+
text: text2,
|
|
9573
|
+
color: color2 = 0,
|
|
9574
|
+
shadow = false,
|
|
9575
|
+
maxWidth = 114,
|
|
9576
|
+
lineHeight = 9,
|
|
9577
|
+
...style
|
|
9578
|
+
} = options;
|
|
9579
|
+
this.validatePosition(position);
|
|
9580
|
+
for (const state of [previous, next]) {
|
|
9581
|
+
if (!["hidden", "normal", "hover"].includes(state)) throw new Error(`Unsupported book button state: ${state}`);
|
|
9582
|
+
}
|
|
9583
|
+
const layers = [{
|
|
9584
|
+
...await this.cropTexture("minecraft:gui/book", [0, 0, 192, 192], [256, 256], position),
|
|
9585
|
+
name: "book-background"
|
|
9586
|
+
}];
|
|
9587
|
+
for (const [name, direction, state, x] of [
|
|
9588
|
+
["previous", "backward", previous, 43],
|
|
9589
|
+
["next", "forward", next, 116]
|
|
9590
|
+
]) {
|
|
9591
|
+
if (state === "hidden") continue;
|
|
9592
|
+
layers.push({
|
|
9593
|
+
name: `book-${name}`,
|
|
9594
|
+
texture: `minecraft:gui/sprites/widget/page_${direction}${state === "hover" ? "_highlighted" : ""}`,
|
|
9595
|
+
position: [position[0] + x, position[1] + 157],
|
|
9596
|
+
size: [23, 13]
|
|
9597
|
+
});
|
|
9598
|
+
}
|
|
9599
|
+
if (text2 !== void 0) {
|
|
9600
|
+
layers.push({
|
|
9601
|
+
name: "book-text",
|
|
9602
|
+
text: text2,
|
|
9603
|
+
position: [position[0] + 36, position[1] + 30],
|
|
9604
|
+
color: color2,
|
|
9605
|
+
shadow,
|
|
9606
|
+
maxWidth,
|
|
9607
|
+
lineHeight,
|
|
9608
|
+
...style
|
|
9609
|
+
});
|
|
9610
|
+
}
|
|
9611
|
+
return layers;
|
|
9612
|
+
}
|
|
9613
|
+
/** Creates a container background. Use {@link GUI_CONTAINER_LAYOUTS} with {@link inventorySlot} to place its items. */
|
|
9614
|
+
static async container(type, position = [0, 0]) {
|
|
9615
|
+
this.validatePosition(position);
|
|
9616
|
+
if (type !== "generic_54" && type !== "crafting_table") throw new Error(`Unsupported GUI container: ${type}`);
|
|
9617
|
+
const layout = GUI_CONTAINER_LAYOUTS[type];
|
|
9618
|
+
return [{ ...await this.cropTexture(layout.texture, layout.crop, [256, 256], position), name: "background" }];
|
|
9619
|
+
}
|
|
9620
|
+
static validatePosition(position) {
|
|
9621
|
+
if (!Array.isArray(position) || position.length !== 2 || !position.every(Number.isFinite)) {
|
|
9622
|
+
throw new Error("GUI position must contain two finite coordinates");
|
|
9623
|
+
}
|
|
9624
|
+
}
|
|
9625
|
+
static async cropTexture(texture, crop, referenceSize, position) {
|
|
9626
|
+
const image = await ModelTextures.preload(AssetKey.parse("textures", texture));
|
|
9627
|
+
if (!image) throw new Error(`Could not load GUI texture ${texture}`);
|
|
9628
|
+
const [x, y, width, height] = crop;
|
|
9629
|
+
const scaleX = image.width / referenceSize[0], scaleY = image.height / referenceSize[1];
|
|
9630
|
+
return {
|
|
9631
|
+
texture,
|
|
9632
|
+
crop: [x * scaleX, y * scaleY, width * scaleX, height * scaleY],
|
|
9633
|
+
position: [...position],
|
|
9634
|
+
size: [width, height]
|
|
9635
|
+
};
|
|
9636
|
+
}
|
|
9514
9637
|
/** Sizes a tooltip around supplied text; the first entry is its title. */
|
|
9515
9638
|
static async tooltip(lines, options = {}) {
|
|
9516
9639
|
if (!lines.length) return [];
|
|
@@ -9545,8 +9668,9 @@ var GuiHelper = class {
|
|
|
9545
9668
|
}
|
|
9546
9669
|
/** Creates crafting-table layers for ingredients and the result; stack counts are not drawn. */
|
|
9547
9670
|
static recipe(recipe, options = {}) {
|
|
9671
|
+
const layout = GUI_CONTAINER_LAYOUTS.crafting_table;
|
|
9548
9672
|
const layers = [
|
|
9549
|
-
{ name: "background", texture:
|
|
9673
|
+
{ name: "background", texture: layout.texture, crop: [...layout.crop] }
|
|
9550
9674
|
];
|
|
9551
9675
|
const itemKey = (ingredient) => {
|
|
9552
9676
|
const item = typeof ingredient === "string" && !ingredient.startsWith("#") ? ingredient : typeof ingredient === "object" && "item" in ingredient ? ingredient.item : options.resolveIngredient?.(ingredient);
|
|
@@ -9561,7 +9685,7 @@ var GuiHelper = class {
|
|
|
9561
9685
|
layers.push({
|
|
9562
9686
|
name: `ingredient-${slot}`,
|
|
9563
9687
|
item: itemKey(ingredient),
|
|
9564
|
-
position: this.inventorySlot(slot,
|
|
9688
|
+
position: this.inventorySlot(slot, layout.slotOrigin, layout.slotOffset, layout.rowSize)
|
|
9565
9689
|
});
|
|
9566
9690
|
};
|
|
9567
9691
|
switch (recipe.type) {
|
|
@@ -9596,7 +9720,7 @@ var GuiHelper = class {
|
|
|
9596
9720
|
layers.push({
|
|
9597
9721
|
name: "result",
|
|
9598
9722
|
item: itemKey("id" in recipe.result ? recipe.result.id : recipe.result.item),
|
|
9599
|
-
position: [
|
|
9723
|
+
position: [...layout.resultPosition]
|
|
9600
9724
|
});
|
|
9601
9725
|
return layers;
|
|
9602
9726
|
}
|