### Install Dependencies Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/README.md Installs all necessary project dependencies from the root of the repository. ```bash npm install ``` -------------------------------- ### Install and Build Minecraft API Docs Generator Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/README.md Instructions for installing Node.js, cloning the repository, and installing dependencies to build the @minecraft/api-docs-generator package. ```bash npm install npm run build ``` -------------------------------- ### Example CLI Command for API Docs Generation Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/README.md An example command demonstrating how to use the minecraft-api-docs-generator CLI with specific input, output, documentation directories, and markup generators. ```bash minecraft-api-docs-generator -i ./input -o ./out -d ./docs -g msdocs ts ``` -------------------------------- ### Global Turbo Installation Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/README.md Installs the turbo build tool globally, which is used for managing build scripts within the repository. ```bash npm install --global turbo ``` -------------------------------- ### Generating API Types with NPM Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/README.md Steps to globally install the api-docs-generator and markup generators plugin using NPM, clone the bedrock-samples repository, and run the generator with a specified input directory. ```bash npm install -g @minecraft/api-docs-generator @minecraft/markup-generators-plugin minecraft-api-docs-generator -i C:\bedrock-samples\metadata -o .\out ``` -------------------------------- ### Custom Markup Generator Implementation (TypeScript) Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/ARCHITECTURE.md Example of implementing a custom MarkupGenerator for the api-docs-generator. It defines an interface for generator options and a class that implements the MarkupGenerator interface, including a method for generating files. ```typescript import { GeneratorContext, MarkupGenerator, MarkupGeneratorOptions, MinecraftRelease } from '@minecraft/api-docs-generator'; interface ExampleOptions extends MarkupGeneratorOptions { option: string; } class ExampleGenerator implements MarkupGenerator { generateFiles( context: GeneratorContext, _releases: MinecraftRelease[], outputDirectory: string, options: ExampleOptions ): Promise { ... } readonly id: string = 'example-generator'; ... } ``` -------------------------------- ### Build All Packages Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/README.md Builds all packages within the repository in the correct order using the turbo tool. This command is equivalent to running 'turbo build'. ```bash npm run build ``` -------------------------------- ### Run Tests Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/README.md Executes tests for all packages using vitest. Tests are authored with the '.test.ts' suffix. Includes functionality to update snapshot tests if changes are expected. ```bash npm run test ``` ```bash npm run test:update ``` -------------------------------- ### Run Linting Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/README.md Executes ESLint to validate all packages with consistent rules and enforce styling via prettier. Includes an option to automatically fix some linting issues. ```bash npm run lint ``` ```bash npm run lint:fix ``` -------------------------------- ### CLI Usage for Minecraft API Docs Generator Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/README.md Demonstrates the command-line interface for the minecraft-api-docs-generator, including various options for input, output, documentation directories, and generator selection. ```bash minecraft-api-docs-generator [options] Options: -i, --input-directory Directory of the API metadata JSON input files. -o, --output-directory Directory to output generated types and documentation to. -d, --docs-directory Directory of the documentation info.JSON files that provide description strings for API modules. -g, --run-generators IDs of markup generators to render output files with. -m, --include-modules Mode which determines which input modules should be included in generation. -b, --include-base If set, will include base modules in generation for metadata that would be merged to a parent module. --changelog-strategy String ID of the changelog strategy to use when comparing modules. -p, --plugin Plugin packages to import generators and templates from. -c, --config Path to a config file with options. --no-config If set, will not look for any config files. -l, --log Logging options. -s, --suppress Suppresses all output except for errors --version Show version number -h, --help Show help ``` -------------------------------- ### Running Specific Tests with Vitest Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/README.md Instructions on how to execute specific tests within the @minecraft/api-docs-generator package using Vitest, allowing for targeted debugging and validation. ```bash npm run test -- -- --test ``` -------------------------------- ### Development Scripts for Minecraft API Docs Generator Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/README.md A collection of npm scripts for developing the @minecraft/api-docs-generator package, including building, linting, testing, cleaning, and packaging. ```bash npm run build npm run lint npm run lint:fix npm run test npm run test:update npm run clean npm run package ``` -------------------------------- ### Vector2 Constants and Builder Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/api-report/math.api.md Provides a zero vector constant for Vector2 and a builder class for creating and manipulating 2D vectors. The builder allows for string parsing and custom string formatting. ```typescript export const VECTOR2_ZERO: Vector2; // @public export class Vector2Builder implements Vector2 { constructor(vecStr: string, delim?: string); constructor(vec: Vector2, arg?: never); constructor(x: number, y: number); // (undocumented) toString(options?: { decimals?: number; delimiter?: string; }): string; // (undocumented) x: number; // (undocumented) y: number; } ``` -------------------------------- ### Vector3 Builder Pattern Operations (TypeScript) Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/README.md Illustrates the builder pattern for Vector3 operations using the Vector3Builder class. This style allows for method chaining and mutates the Vector3 object directly. It also shows how a Vector3Builder instance can be used with Minecraft server APIs. ```TypeScript import { Vector3, world } from '@minecraft/server'; import { Vector3Builder } from '@minecraft/math'; import { MinecraftDimensionTypes } from '@minecraft/vanilla-data'; const vectorA: Vector3Builder = new Vector3Builder({x: 1, y: 2, z:3}); const vectorB: Vector3 = {x: 4, y: 5, z:6}; const vectorC: Vector3 = {x: 1, y: 3, z:5}; // Mutates vectorA directly each time vectorA.add(vectorB).subtract(vectorC).cross(vectorB); // Final result {x:4, y:-8, z:4} console.log(vectorA.toString()); // Prints out "4, -8, 4" // Vector3Builder type can directly be used in APIs that accept Vector3 const dimension = world.getDimension(MinecraftDimensionTypes.Overworld); dimension.spawnParticle("minecraft:colored_flame_particle", vectorA); ``` -------------------------------- ### Lint Code with ESLint Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/CONTRIBUTING.md Run ESLint to check for code quality and style issues. This command also utilizes Prettier to format the code. ```bash npm run lint ``` -------------------------------- ### API Docs Generator Generator Options Configuration (MJS) Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/ARCHITECTURE.md Configuration file for the api-docs-generator, specifying options for custom generators. This allows passing specific configurations to generators identified by their IDs. ```javascript export default { generators: { 'example-generator': { option: 'Example' }, } } ``` -------------------------------- ### Vector3 Pure Functional Operations (TypeScript) Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/README.md Demonstrates the pure functional style for Vector3 operations using the Vector3Utils class. This approach avoids mutation and uses static methods for calculations like addition, subtraction, and cross product. It shows how to integrate these operations with Minecraft server APIs. ```TypeScript import { Vector3, world } from '@minecraft/server'; import { MinecraftDimensionTypes } from '@minecraft/vanilla-data'; import { Vector3Utils } from '@minecraft/math'; const vectorA: Vector3 = {x: 1, y: 2, z:3}; const vectorB: Vector3 = {x: 4, y: 5, z:6}; const resultAdd = Vector3Utils.add(vectorA, vectorB); // {x:5, y:7, z:9} const resultSubtract = Vector3Utils.subtract(vectorA, vectorB); // {x:-3, y:-3, z:-3} const resultCross = Vector3Utils.cross(vectorA, vectorB); // {x:-3, y:6, z:-3} console.log(toString(vectorA)); // Prints out "1, 2, 3" // Use your vectors with any @minecraft/server API const dimension = world.getDimension(MinecraftDimensionTypes.Overworld); dimension.spawnParticle("minecraft:colored_flame_particle", resultAdd); ``` -------------------------------- ### Run Specific Vitest Tests Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator-test-snapshots/README.md Executes specific vitest snapshot tests based on a provided name pattern. This is useful for isolating and debugging individual test scenarios. ```Shell npm run test -- -- --test ``` -------------------------------- ### API Docs Generator Configuration (MJS) Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator/ARCHITECTURE.md Configuration file for the api-docs-generator, specifying external plugin packages to be used. This allows for extending the generator's functionality with custom logic and templates. ```javascript export default { plugins: ['name-of-plugin'] } ``` -------------------------------- ### Generate TypeDoc Documentation for Minecraft APIs Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/markup-generators-plugin/README.md Generates documentation in TypeDoc format for the Minecraft APIs. This generator depends on the 'ts' and 'ts-source' generators being executed first. ```typescript typedoc ``` -------------------------------- ### Vector3 Utility Functions Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/api-report/math.api.md Provides static methods for performing various mathematical operations on Vector3 objects, including addition, subtraction, dot product, cross product, normalization, and interpolation. It also includes functions for converting between string and Vector3 representations. ```typescript // @public export class Vector3Utils { static add(v1: Vector3, v2: Partial): Vector3; static clamp(v: Vector3, limits?: { min?: Partial; max?: Partial; }): Vector3; static cross(a: Vector3, b: Vector3): Vector3; static distance(a: Vector3, b: Vector3): number; static dot(a: Vector3, b: Vector3): number; static equals(v1: Vector3, v2: Vector3): boolean; static floor(v: Vector3): Vector3; static fromString(str: string, delimiter?: string): Vector3 | undefined; static lerp(a: Vector3, b: Vector3, t: number): Vector3; static magnitude(v: Vector3): number; static multiply(a: Vector3, b: Vector3): Vector3; static normalize(v: Vector3): Vector3; static rotateX(v: Vector3, a: number): Vector3; static rotateY(v: Vector3, a: number): Vector3; static rotateZ(v: Vector3, a: number): Vector3; static scale(v1: Vector3, scale: number): Vector3; static slerp(a: Vector3, b: Vector3, t: number): Vector3; static subtract(v1: Vector3, v2: Partial): Vector3; static toString(v: Vector3, options?: { decimals?: number; delimiter?: string; }): string; } ``` -------------------------------- ### Generate Change Files with Beachball Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/CONTRIBUTING.md Use the Beachball tool to generate change files for PRs, indicating the severity of changes. This command automatically updates versions and publishes to NPM. ```bash npm run change ``` -------------------------------- ### Package Minecraft APIs as an NPM Module Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/markup-generators-plugin/README.md Packages the generated Minecraft API definitions and source code into an NPM module. This generator requires both the 'ts' and 'ts-source' generators to have been run. ```typescript npm ``` -------------------------------- ### Fix Linting and Formatting Issues Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/CONTRIBUTING.md Execute this command to automatically fix code style and linting issues identified by ESLint and Prettier. ```bash npm run lint:fix ``` -------------------------------- ### Vector2 Utility Functions Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/api-report/math.api.md Offers utility functions for Vector2 operations, including parsing from strings and converting to strings with customizable delimiters and decimal precision. ```typescript // @public export class Vector2Utils { static fromString(str: string, delimiter?: string): Vector2 | undefined; static toString(v: Vector2, options?: { decimals?: number; delimiter?: string; }): string; } ``` -------------------------------- ### Vector3 Constants and Builder Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/api-report/math.api.md Defines numerous constants for common 3D vector directions and values (e.g., ZERO, ONE, NORTH, EAST). Includes a Vector3Builder class for creating and modifying 3D vectors with methods for addition, subtraction, rotation, and more. ```typescript export const VECTOR3_BACK: Vector3; export const VECTOR3_DOWN: Vector3; export const VECTOR3_EAST: Vector3; export const VECTOR3_FORWARD: Vector3; export const VECTOR3_HALF: Vector3; export const VECTOR3_LEFT: Vector3; export const VECTOR3_NEGATIVE_ONE: Vector3; export const VECTOR3_NORTH: Vector3; export const VECTOR3_ONE: Vector3; export const VECTOR3_RIGHT: Vector3; export const VECTOR3_SOUTH: Vector3; export const VECTOR3_UP: Vector3; export const VECTOR3_WEST: Vector3; export const VECTOR3_ZERO: Vector3; // @public export class Vector3Builder implements Vector3 { constructor(vecStr: string, delim?: string, arg2?: never); constructor(vec: Vector3, arg?: never, arg2?: never); constructor(x: number, y: number, z: number); add(v: Partial): this; assign(vec: Vector3): this; clamp(limits: { min?: Partial; max?: Partial; }): this; cross(vec: Vector3): this; distance(vec: Vector3): number; dot(vec: Vector3): number; equals(v: Vector3): boolean; floor(): this; lerp(vec: Vector3, t: number): this; magnitude(): number; multiply(vec: Vector3): this; normalize(): this; rotateX(a: number): this; rotateY(a: number): this; rotateZ(a: number): this; scale(val: number): this; slerp(vec: Vector3, t: number): this; subtract(v: Partial): this; toString(options?: { decimals?: number; delimiter?: string; }): string; // (undocumented) x: number; // (undocumented) y: number; // (undocumented) z: number; } ``` -------------------------------- ### Generate JSON Changelog for API Module Versions Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/markup-generators-plugin/README.md Outputs a changelog in JSON format, summarizing the changes between different API module versions. This generator is not set to run by default. ```json changelog-json ``` -------------------------------- ### Generate Markdown Changelog for API Module Versions Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/markup-generators-plugin/README.md Creates a changelog in Markdown format, detailing the differences between various versions of the API module. This is a default generator. ```markdown msdocs changelog ``` -------------------------------- ### Update Vitest Snapshots Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/api-docs-generator-test-snapshots/README.md Updates the vitest snapshot tests for the api-docs-generator. This command should be run when changes to the generator are expected to alter the generated markup or file structure. ```Shell npm run test:update ``` -------------------------------- ### Generate TypeScript Source for Minecraft Vanilla Data APIs Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/markup-generators-plugin/README.md Generates TypeScript source code for Minecraft's vanilla-data APIs. This generator is also a default option and is typically required for NPM packaging and TypeDoc generation. ```typescript ts-source ``` -------------------------------- ### Generate TypeScript Definitions for Minecraft APIs Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/markup-generators-plugin/README.md Generates TypeScript type definitions for Minecraft APIs. This is a default generator and is often a prerequisite for other generators like NPM and TypeDoc. ```typescript ts ``` -------------------------------- ### Add New ESLint Rule Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/tools/eslint-plugin-minecraft-linting/README.md Demonstrates how to add a new rule to the Minecraft Types ESLint Plugin. This involves creating a new file in the 'src/rules' directory and registering it in 'src/index.ts'. ```TypeScript import { ESLintUtils } from "@typescript-eslint/utils"; // Create a new rule using ESLintUtils const myNewRule = ESLintUtils.RuleCreator.withoutDocs({ name: "my-new-rule", meta: { type: "suggestion", docs: { description: "A description for my new rule", recommended: "warn", }, fixable: "code", schema: [], // or your rule's options schema }, defaultOptions: [], create(context) { return { // visitor methods }; }, }); // Export the rule export { myNewRule }; ``` ```TypeScript // In src/index.ts import { myNewRule } from "./rules/my-new-rule"; export = { rules: { "my-new-rule": myNewRule, }, configs: { recommended: { plugins: ["@minecraft/core"], rules: { "@minecraft/core/my-new-rule": "warn", }, }, }, }; ``` -------------------------------- ### Clamp Number Function Source: https://github.com/mojang/minecraft-scripting-libraries/blob/main/libraries/math/api-report/math.api.md Clamps a given number within a specified minimum and maximum range. This function is useful for ensuring values stay within defined boundaries. ```typescript import type { Vector2 } from '@minecraft/server'; import type { Vector3 } from '@minecraft/server'; // @public export function clampNumber(val: number, min: number, max: number): number; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.