### Install and Deploy Deferred Lighting Starter Pack Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/VibrantVisuals/UseBlockbenchToCreateModelsWithTextures.md This example shows the command-line steps to install dependencies and deploy the deferred lighting starter resource pack from GitHub. This pack provides fundamental settings for Vibrant Visuals. ```bash npm i npm run local-deploy ``` -------------------------------- ### Full Script Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/scripting/introduction.md A complete script demonstrating how to get player information, determine their dimension, and conditionally spawn entities. Includes necessary imports and helper functions. ```javascript import { world, system } from "@minecraft/server"; function getPlayer() { const allPlayers = world.getAllPlayers(); if (allPlayers.length === 0) { return undefined; } return allPlayers[0]; } function getPlayerDimension() { const player = getPlayer(); if (player === undefined) { return undefined; } return player.dimension; } function getPlayerLocation() { const player = getPlayer(); if (player === undefined) { return undefined; } return player.location; } function mainTick() { if (system.currentTick % 200 === 0) { const playerDimension = getPlayerDimension(); const playerLocation = getPlayerLocation(); ``` -------------------------------- ### Example: Basic Teleportation Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/TeleportOptions.md This example demonstrates how to teleport a spawned entity to a new location with specified teleport options. ```APIDOC ## Example: Basic Teleportation This example shows how to teleport a spawned entity to a new location with specified teleport options. ### Request Example ```typescript import { system, DimensionLocation } from '@minecraft/server'; import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; function teleport(targetLocation: DimensionLocation) { const cow = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Cow, targetLocation); system.runTimeout(() => { cow.teleport( { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 2 }, { facingLocation: targetLocation, } ); }, 20); } ``` (preview) Work with this sample on the [MCTools.dev](https://mctools.dev/?open=gp/teleport.ts) code sandbox. ``` -------------------------------- ### Install and Use Minecraft Creator Tools CLI Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/MCToolsOverview.md Installs the creator tools globally and provides basic commands for project creation, adding entities, and validation. Ensure Node.js 22 or later is installed. ```powershell # Install the tools globally npm install -g @minecraft/creator-tools # Create a new project (interactive prompts walk you through setup) npx mct create # Add a new entity to an existing project npx mct add entity d:\mycontent\myproject # Validate your project against the default rule suite npx mct validate d:\mycontent\myproject ``` -------------------------------- ### Example Ocean Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/VibrantVisuals/WaterCustomization.md An example JSON configuration for an ocean, demonstrating the usage of various water settings. ```APIDOC ## Example Ocean Configuration The following example JSON can be used as a starting point for an ocean: ```json { "format_version": "1.26.0", "minecraft:water_settings": { "description": { "identifier": "my_pack:default_water" }, "particle_concentrations": { "chlorophyll": 0.5, "suspended_sediment": 0.5, "cdom": 1 }, "waves": { "enabled": true, "depth": 1, "direction_increment": 80.0, "frequency": 1, "frequency_scaling": 1.2, "mix": 0.2, "octaves": 28, "pull": 0.38, "sampleWidth": 0.01, "shape": 1.5, "speed": 2, "speed_scaling": 1.03 }, "caustics": { "enabled": true, "frame_length": 0.05, "power": 2, "scale": 0.5 }, "biome_water_color_contribution": 0.2 } } ``` ``` -------------------------------- ### Install Node Tools and Libraries Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/CameraSystem/FreeCameraScriptAPITutorial.md Run this command in your project's directory to install necessary Node tools and libraries for scripting. ```bash npm i ``` -------------------------------- ### Sample Minecraft Cubemap Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/VibrantVisuals/CubemapCustomization.md An example JSON file demonstrating how to configure cubemap settings for a Minecraft resource pack. This sample includes a specific identifier and custom lighting values for ambient light, sky light, directional light, and scattering effects. It serves as a practical starting point for creating custom cubemaps. ```json { "format_version": "1.21.130", "minecraft:cubemap_settings": { "description": { "identifier": "my_pack:mycubemap" }, "lighting": { "ambient_light_illuminance": { "0.00000": 4.0, "1.000000": 4.0 }, "sky_light_contribution": 1.0, "directional_light_contribution": 1.0, "affected_by_atmospheric_scattering": true, "affected_by_volumetric_scattering": true } } } ``` -------------------------------- ### Example: Adding and Setting Text on a Sign Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/BlockSignComponent.md This example demonstrates how to add a standing sign to the world and set its text using the BlockSignComponent. ```APIDOC ## Example: addSign.ts ### Description This TypeScript code snippet shows how to add a standing sign to the Minecraft world at a specified location and set its text content. ### Method This example primarily uses client-side scripting to interact with the game world. ### Endpoint N/A (Client-side script) ### Parameters This example does not directly use API endpoints but relies on game world objects and their methods. ### Request Example ```typescript import { world, BlockPermutation, BlockSignComponent, BlockComponentTypes, DimensionLocation } from '@minecraft/server'; import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; function addSign(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) { const players = world.getPlayers(); const dim = players[0].dimension; const signBlock = dim.getBlock(targetLocation); if (!signBlock) { log('Could not find a block at specified location.'); return -1; } const signPerm = BlockPermutation.resolve(MinecraftBlockTypes.StandingSign, { ground_sign_direction: 8 }); signBlock.setPermutation(signPerm); const signComponent = signBlock.getComponent(BlockComponentTypes.Sign) as BlockSignComponent; signComponent?.setText(`Basic sign!\nThis is green on the front.`); } ``` (preview) Work with this sample on the [MCTools.dev](https://mctools.dev/?open=gp/addSign.ts) code sandbox. ``` -------------------------------- ### RGB Color Format and Examples Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/CommandsReference/Examples/CommandTypes/type_rgb.md Explains the format for RGB color values and provides examples. ```APIDOC ## RGB Color Color value as red, green, blue components. **Format:** `0-255 for each component` ### Examples #### Values | Example | Description | |:--------|------------| | `255 0 0` | Red | | `0 255 0` | Green | | `0 0 255` | Blue | | `255 255 255` | White | | `0 0 0` | Black | ``` -------------------------------- ### Example: Teleportation with Movement Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/TeleportOptions.md This example demonstrates continuous teleportation of an entity over time, simulating movement with changing coordinates. ```APIDOC ## Example: Teleportation with Movement This example demonstrates continuous teleportation of an entity over time, simulating movement with changing coordinates. ### Request Example ```typescript import { system, DimensionLocation } from '@minecraft/server'; import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; function teleportMovement(targetLocation: DimensionLocation) { const pig = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Pig, targetLocation); let inc = 1; const runId = system.runInterval(() => { pig.teleport( { x: targetLocation.x + inc / 4, y: targetLocation.y + inc / 4, z: targetLocation.z + inc / 4 }, { facingLocation: targetLocation, } ); if (inc > 100) { system.clearRun(runId); } inc++; }, 4); } ``` (preview) Work with this sample on the [MCTools.dev](https://mctools.dev/?open=gp/teleportMovement.ts) code sandbox. ``` -------------------------------- ### Comprehensive blocks.json example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/BlockReference/Examples/BlocksJsonFileStructure.md A full example file illustrating multiple block definitions with varying sound types, texture mapping strategies, and carried texture overrides. ```json { "format_version": "1.19.30", "demo:simple_stone": { "sound": "stone", "textures": "demo_stone" }, "demo:wooden_crate": { "sound": "wood", "textures": { "up": "crate_top", "down": "crate_bottom", "side": "crate_side" }, "carried_textures": "crate_item" }, "demo:glass_block": { "sound": "glass", "textures": "demo_glass", "isotropic": true }, "demo:die": { "sound": "stone", "textures": { "up": "die_1", "down": "die_6", "north": "die_3", "south": "die_4", "east": "die_2", "west": "die_5" }, "carried_textures": "die_red" } } ``` -------------------------------- ### Function Path Examples Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/CommandsReference/Examples/CommandTypes/type_pathcommand.md Examples of valid Function Path formats, including functions in a specific namespace, functions in subfolders, and functions in the default namespace. ```minecraft-commands mypack:setup ``` ```minecraft-commands mypack:utils/helper ``` ```minecraft-commands tick ``` -------------------------------- ### Implement minecraft:search_feature Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/FeaturesReference/Examples/Features/minecraftSearch_feature.md A practical example of using the search_feature to find valid positions for an apple feature within a 7x7x7 volume, requiring 3 successful placements. ```json { "format_version": "1.13.0", "minecraft:search_feature": { "description": { "identifier": "example:find_valid_apples_feature" }, "places_feature": "example:apple_feature", "search_volume": { "min": [ -3, -3, -3 ], "max": [ 3, 3, 3 ] }, "search_axis": "-y", "required_successes": 3 } } ``` -------------------------------- ### Example Multiface Feature Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/FeaturesReference/Examples/Features/minecraftMultiface_feature.md An example JSON configuration for the minecraft:multiface_feature, demonstrating how to set up blue vines to grow in caves on various surfaces. ```json { "format_version": "1.13.0", "minecraft:multiface_feature": { "description": { "identifier": "example:blue_vines_feature" }, "places_block": "example:blue_vine", "search_range": 64, "can_place_on_floor": true, "can_place_on_ceiling": true, "can_place_on_wall": true, "chance_of_spreading": 0.5, "can_place_on": [ "minecraft:stone" ] } } ``` -------------------------------- ### Configure cave vine ceiling snap example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/FeaturesReference/Examples/Features/minecraftSnap_to_surface_feature.md An example configuration showing how to snap a cave vine feature to the ceiling within a 12-block range, specifically targeting cobblestone blocks. ```json { "format_version": "1.13.0", "minecraft:snap_to_surface_feature": { "description": { "identifier": "example:cave_vine_snapped_to_ceiling_feature" }, "feature_to_snap": "example:cave_vine_feature", "vertical_search_range": 12, "surface": "ceiling", "allowed_surface_blocks": { { "name": "minecraft:cobblestone" } } } } ``` -------------------------------- ### Block Fabricator Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/BlockReference/Examples/BlockComponents/minecraftBlock_crafting_table.md This example demonstrates configuring a block as a 'fabricator' using a specific crafting tag and a UI name. This is useful for creating unique crafting stations with distinct identifiers. ```json "minecraft:crafting_table": { "crafting_tags": [ "graywave_fabricator" ], "table_name": "Fabricator" } ``` -------------------------------- ### GET /minecraft:health Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/EntityComponents/minecraftComponent_health.md Defines the health configuration for an entity, including maximum health and starting health values. ```APIDOC ## GET minecraft:health ### Description Defines the health pool for an entity, measured in health points (1 point = half a heart). ### Method GET ### Endpoint minecraft:health ### Parameters #### Request Body - **max** (Integer) - Optional - Maximum health this entity can have. - **value** (Integer) - Optional - Starting health for this entity. - **value (Object)** (Object) - Optional - Contains range_min and range_max properties. ### Request Example { "minecraft:health": { "value": 20, "max": 20 } } ### Response #### Success Response (200) - **max** (Integer) - The maximum health capacity. - **value** (Integer) - The current or starting health value. #### Response Example { "minecraft:health": { "value": 20, "max": 20 } } ``` -------------------------------- ### activateTutorial Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/BuiltInUIManager.md Activates the tutorial overlay for the player. ```APIDOC ## activateTutorial ### Description Activates tutorial overlay. ### Method `activateTutorial(): void` ### Returns * void ``` -------------------------------- ### Example Minecraft Ocean Water Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/VibrantVisuals/WaterCustomization.md An example JSON configuration for an ocean in Minecraft, demonstrating how to set particle concentrations, wave properties, and caustics effects. This serves as a starting point for creating custom water appearances. ```json { "format_version": "1.26.0", "minecraft:water_settings": { "description": { "identifier": "my_pack:default_water" }, "particle_concentrations": { "chlorophyll": 0.5, "suspended_sediment": 0.5, "cdom": 1 }, "waves": { "enabled": true, "depth": 1, "direction_increment": 80.0, "frequency": 1, "frequency_scaling": 1.2, "mix": 0.2, "octaves": 28, "pull": 0.38, "sampleWidth": 0.01, "shape": 1.5, "speed": 2, "speed_scaling": 1.03 }, "caustics": { "enabled": true, "frame_length": 0.05, "power": 2, "scale": 0.5 }, "biome_water_color_contribution": 0.2 } } ``` -------------------------------- ### Item Use Modifiers Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/ItemReference/Examples/ItemComponents/minecraft_use_modifiers.md Configures an item to start using immediately, with a duration of 1.6 seconds, and a movement speed modifier of 0.35. ```json "minecraft:use_modifiers": { "start_using": "always", "use_duration": 1.6, "movement_modifier": 0.35 } ``` -------------------------------- ### Activate Tutorial Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/BuiltInUIManager.md Activates the tutorial overlay for the player. This method returns void. ```typescript activateTutorial(): void ``` -------------------------------- ### Execute /clone command examples Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/CommandsReference/Examples/Commands/clone.md Demonstrates various ways to use the /clone command, including basic region copying, replacing blocks, masking air, and moving structures. ```Minecraft Command /clone 0 64 0 10 70 10 20 64 0 /clone ~-5 ~ ~-5 ~5 ~10 ~5 ~10 ~ ~ replace /clone ~-5 ~ ~-5 ~5 ~10 ~5 ~10 ~ ~ masked /clone 0 64 0 10 70 10 20 64 0 replace move ``` -------------------------------- ### Entity Timer Flag 3 Behavior Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/EntityGoals/minecraftBehavior_timer_flag_3.md This JSON snippet configures the minecraft:behavior.timer_flag_3 component for an entity. It sets the priority, cooldown, duration, and defines events to trigger when the behavior starts and ends. ```json "minecraft:behavior.timer_flag_3": { "priority": 5, "cooldown_range": { "min": 0, "max": 0 }, "duration_range": { "min": 2, "max": 5 }, "on_end": { "event": "on_feeling_happy_end", "target": "self" } } ``` -------------------------------- ### Play Music and Sound Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/World.md Demonstrates playing a music track with options, a world sound, and a player sound. Requires importing necessary modules from '@minecraft/server'. ```typescript import { world, MusicOptions, WorldSoundOptions, PlayerSoundOptions, DimensionLocation } from '@minecraft/server'; function playMusicAndSound(targetLocation: DimensionLocation) { const players = world.getPlayers(); const musicOptions: MusicOptions = { fade: 0.5, loop: true, volume: 1.0, }; world.playMusic('music.menu', musicOptions); const worldSoundOptions: WorldSoundOptions = { pitch: 0.5, volume: 4.0, }; world.playSound('ambient.weather.thunder', targetLocation, worldSoundOptions); const playerSoundOptions: PlayerSoundOptions = { pitch: 1.0, volume: 1.0, }; players[0].playSound('bucket.fill_water', playerSoundOptions); } ``` -------------------------------- ### Define Full Block Culling Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/BlockReference/Examples/Definitions/BlockCulling.md Provides an example of a full block culling setup where all six faces are defined for culling checks. This is typically used for blocks that should be culled completely when surrounded by other opaque blocks. ```json { "format_version": "1.20.60", "minecraft:block_culling_rules": { "description": { "identifier": "demo:my_glass_block" }, "rules": [ { "geometry_part": { "bone": "block", "cube": 0, "face": "north" }, "direction": "north" }, { "geometry_part": { "bone": "block", "cube": 0, "face": "south" }, "direction": "south" }, { "geometry_part": { "bone": "block", "cube": 0, "face": "east" }, "direction": "east" }, { "geometry_part": { "bone": "block", "cube": 0, "face": "west" }, "direction": "west" }, { "geometry_part": { "bone": "block", "cube": 0, "face": "up" }, "direction": "up" }, { "geometry_part": { "bone": "block", "cube": 0, "face": "down" }, "direction": "down" } ] } } ``` -------------------------------- ### Registering a Custom Command Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/scripting/custom-commands.md Demonstrates how to register a custom command using the system startup event. It defines the command name, description, permission level, and optional parameters. ```typescript system.beforeEvents.startup.subscribe((init: StartupEvent) => { const helloCommand: CustomCommand = { name: "creator:hellocustomcommand", description: "Celebration size", permissionLevel: CustomCommandPermissionLevel.Admin, optionalParameters: [{ type: CustomCommandParamType.Integer, name: "celebrationSize" }], }; init.customCommandRegistry.registerCommand(helloCommand, helloCustomCommand); } ``` -------------------------------- ### Sniffer Entity Timer Flag 1 Behavior Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/EntityGoals/minecraftBehavior_timer_flag_1.md This JSON configuration sets up the timer flag behavior for a Sniffer entity. It defines the priority, control flags, cooldown, duration, and events to trigger on start and end. ```json "minecraft:behavior.timer_flag_1": { "priority": 6, "control_flags": [ "move", "look" ], "cooldown_range": { "min": 400, "max": 500 }, "duration_range": { "min": 2, "max": 2 }, "on_end": { "event": "on_scenting_success", "target": "self" } } ``` -------------------------------- ### Implement Basic Color Grading Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/VibrantVisuals/ColorGradingToneMappingCustomization.md A sample configuration file demonstrating the basic setup for color grading, including midtone adjustments and a specific tone mapping operator. ```json { "format_version": "1.21.40", "minecraft:color_grading_settings": { "description": { "identifier": "my_pack:default_color_grading" }, "color_grading": { "midtones": { "contrast": [1.3, 1.3, 1.3], "gain": [1.0, 1.0, 1.0], "gamma": [2.2, 2.2, 2.2], "offset": [0.0, 0.0, 0.0], "saturation": [1.05, 1.05, 1.05] } }, "tone_mapping": { "operator": "reinhard_luminance" } } } ``` -------------------------------- ### get Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/StructureManager.md Gets a Structure that is saved to memory or the world. ```APIDOC ## get ### Description Gets a Structure that is saved to memory or the world. ### Method `get(identifier: string): Structure | undefined` ### Parameters #### Path Parameters - **identifier** (string) - Required - The name of the structure to get. ### Returns - **Structure | undefined** - Returns a Structure if it exists, otherwise undefined. ### Notes - This function can't be called in restricted-execution mode. ``` -------------------------------- ### beginPainting Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/BrushShapeManager.md Starts a painting operation with a completion callback. ```APIDOC ## beginPainting ### Description Initiates a painting session. This function cannot be called in restricted-execution mode and may throw errors. ### Method void ### Parameters #### Request Body - **onComplete** (PaintCompletionState) - Required - Callback function executed when painting is finished. ### Response - **void** - Returns nothing. ``` -------------------------------- ### EntityEquippableComponent Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/EntityEquippableComponent.md Example of how to give a player Elytra using the setEquipment method. ```APIDOC ## EntityEquippableComponent Example ### givePlayerElytra.ts ```typescript // Gives the player Elytra import { EquipmentSlot, ItemStack, Player, EntityComponentTypes } from '@minecraft/server'; import { MinecraftItemTypes } from '@minecraft/vanilla-data'; function giveEquipment(player: Player) { const equipmentCompPlayer = player.getComponent(EntityComponentTypes.Equippable); if (equipmentCompPlayer) { equipmentCompPlayer.setEquipment(EquipmentSlot.Chest, new ItemStack(MinecraftItemTypes.Elytra)); } } ``` (preview) Work with this sample on the [MCTools.dev](https://mctools.dev/?open=gp/givePlayerElytra.ts) code sandbox. ``` -------------------------------- ### Start Bedrock Server on Windows Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/BedrockServer/getting-started.md Executes the Bedrock Dedicated Server on Windows from a command prompt or PowerShell. Ensure you are in the server's directory. ```bash cd C:\MinecraftServer bedrock_server ``` -------------------------------- ### showBasicMessageForm.ts Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-ui/MessageFormData.md An example demonstrating how to create and display a basic message form using MessageFormData. ```APIDOC #### Examples ##### ***showBasicMessageForm.ts*** ```typescript import { world, DimensionLocation } from '@minecraft/server'; import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui'; function showBasicMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) { const players = world.getPlayers(); const messageForm = new MessageFormData() .title('Message Form Example') .body('This shows a simple example using §o§7MessageFormData§r.') .button1('Button 1') .button2('Button 2'); messageForm .show(players[0]) .then((formData: MessageFormResponse) => { // player canceled the form, or another dialog was up and open. if (formData.canceled || formData.selection === undefined) { return; } log(`You selected ${formData.selection === 0 ? 'Button 1' : 'Button 2'}`); }) .catch((error: Error) => { log('Failed to show form: ' + error); return -1; }); } ``` (preview) Work with this sample on the [MCTools.dev](https://mctools.dev/?open=gp/showBasicMessageForm.ts) code sandbox. ``` -------------------------------- ### Navigate to Samples Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/BuiltInUIManager.md Navigates the player to the samples site on GitHub. This method returns void. ```typescript navigateToSamples(): void ``` -------------------------------- ### navigateToSamples Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/BuiltInUIManager.md Navigates the player to the github-samples site. ```APIDOC ## navigateToSamples ### Description Navigates to the github-samples site. ### Method `navigateToSamples(): void` ### Returns * void ``` -------------------------------- ### Example Minecraft Cave Carver Feature Configuration Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/FeaturesReference/Examples/Features/minecraftCave_carver_feature.md An example JSON configuration for the minecraft:cave_carver_feature, demonstrating how to set basic parameters for carving caves. This example sets the fill block to air and defines a skip carve chance. ```json { "format_version": "1.13.0", "minecraft:cave_carver_feature": { "description": { "identifier": "example:underground_cave_carver_feature" }, "fill_with": "minecraft:air", "width_modifier": 0.0, "skip_carve_chance": 15 } } ``` -------------------------------- ### Subscribe to Button Push Events Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/ButtonPushAfterEventSignal.md This example demonstrates how to set up a button and subscribe to its push events. It logs a message to the console when the specified button is pushed. Ensure the necessary blocks are present at the target location. ```typescript import { world, system, BlockPermutation, ButtonPushAfterEvent, DimensionLocation } from '@minecraft/server'; import { MinecraftBlockTypes } from '@minecraft/vanilla-data'; function buttonPushEvent(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) { // set up a button on cobblestone const cobblestone = targetLocation.dimension.getBlock(targetLocation); const button = targetLocation.dimension.getBlock({ x: targetLocation.x, y: targetLocation.y + 1, z: targetLocation.z, }); if (cobblestone === undefined || button === undefined) { log('Could not find block at location.'); return -1; } cobblestone.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.Cobblestone)); button.setPermutation(BlockPermutation.resolve(MinecraftBlockTypes.AcaciaButton).withState('facing_direction', 1)); world.afterEvents.buttonPush.subscribe((buttonPushEvent: ButtonPushAfterEvent) => { const eventLoc = buttonPushEvent.block.location; if (eventLoc.x === targetLocation.x && eventLoc.y === targetLocation.y + 1 && eventLoc.z === targetLocation.z) { log('Button push event at tick ' + system.currentTick); } }); } ``` -------------------------------- ### joinExperience Command Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/deep-links.md Launches the Minecraft client directly into a specified Experience, Gathering, or Event using its unique ID. ```APIDOC ## GET /minecraft://joinExperience ### Description Launches the Minecraft client directly into a specific Experience (like a custom world or map), Gathering, or Event. It requires the Experience ID and can optionally take a world ID or friend ID. ### Method GET ### Endpoint minecraft://joinExperience?experienceId=UUID[&worldId=UUID][&friendID=ID] ### Query Parameters - **experienceId** (UUID) - Required - The unique identifier for the Experience, Gathering, or Event. - **worldId** (UUID) - Optional - The ID of a specific world to join within the Experience. - **friendID** (string) - Optional - The ID of a friend to join with. ### Request Example ```json { "example": "minecraft://joinExperience?experienceId=8c0495bf-aaf0-483e-b488-1b37e8c74745&worldId=abcdef12-3456-7890-abcd-ef1234567890" } ``` ### Response #### Success Response (200) - **None**: This handler initiates the game client to load the specified experience. #### Response Example ```json { "example": "(No response body, launches game to Experience)" } ``` ``` -------------------------------- ### Shaped Recipe Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/RecipeReference/Examples/RecipeDefinitions/minecraftRecipe_Shaped.md An example of a shaped recipe for an acacia boat, demonstrating the use of pattern, key, and result. ```APIDOC ## POST /recipes/shaped (Example) ### Description An example of a shaped recipe for an acacia boat, demonstrating the use of pattern, key, and result. ### Method POST ### Endpoint /recipes/shaped ### Request Example ```json { "format_version": "1.17", "minecraft:recipe_shaped": { "description": { "identifier": "minecraft:acacia_boat" }, "tags": [ "crafting_table" ], "pattern": [ "#P#", "###" ], "key": { "P": { "item": "minecraft:wooden_shovel" }, "#": { "item": "minecraft:planks", "data": 4 } }, "result": { "item": "minecraft:boat", "data": 4 } } } ``` ### Response #### Success Response (200) - **status** (string) - Indicates successful recipe creation. - **message** (string) - Confirmation message. ``` -------------------------------- ### Client Biome JSON Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/ClientBiomesReference/Examples/ClientBiomesOverview.md This example demonstrates a complete client biome JSON file, showing how to define the format version, identifier, and various client-side components like sky color, fog, and water appearance. ```APIDOC ## Example ```json { "format_version": "1.21.40", "minecraft:client_biome": { "description": { "identifier": "the_end" }, "components": { "minecraft:sky_color": { "sky_color": "#000000" }, "minecraft:fog_appearance": { "fog_identifier": "minecraft:fog_the_end" }, "minecraft:water_appearance": { "surface_color": "#62529e" } } } } ``` ``` -------------------------------- ### Weather at Position - Full Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/Filters/weather_at_position.md This example explicitly defines the test, subject, operator, and value for the weather_at_position filter. ```json { "test": "weather_at_position", "subject": "self", "operator": "equals", "value": "player" } ``` -------------------------------- ### Main Game Loop Initialization and Tick Handling (TypeScript) Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Casual/build-tower-defense.md This script sets up the main game loop using system.run(), initializing the GrayWaveManager at 100 ticks and processing its tick method thereafter. It includes basic error handling for the tick process. This is the entry point for game logic. ```typescript import { world, system } from "@minecraft/server"; import GrayWaveManager from "./GrayWaveManager"; const g_gwmn = new GrayWaveManager(); let tickIndex = 0; function mainTick() { tickIndex++; if (tickIndex === 100) { g_gwmn.init(); } else if (tickIndex > 100) { try { g_gwmn.tick(tickIndex); } catch (e) { console.warn(e); } } system.run(mainTick); } system.run(mainTick); ``` -------------------------------- ### Llama Variant Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/EntityComponents/minecraftComponent_variant.md Sets the variant for a llama entity. This example defines a specific variant for a gray llama. ```json "minecraft:variant": { "value": 3 } ``` -------------------------------- ### POST /player/addExperience Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/Update1.20.40.md Manages player experience points and leveling system. ```APIDOC ## POST /player/addExperience ### Description Adds a specified amount of experience points to the player's current total. ### Method POST ### Endpoint /player/addExperience ### Request Body - **amount** (integer) - Required - The amount of experience points to add ### Request Example { "amount": 50 } ### Response #### Success Response (200) - **newTotalXp** (integer) - The updated total experience points for the player ``` -------------------------------- ### Minecraft Spawn Rules Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/ClientEntityDocumentation/DataDrivenSpawning.md An example of how to define spawn rules for a zombie entity using various components. ```APIDOC ## Minecraft Spawn Rules Example ### Description This example demonstrates the structure for defining spawn rules for a specific entity, in this case, a zombie. It utilizes various components to control where, when, and under what conditions the entity can spawn. ### Method N/A (Configuration File) ### Endpoint N/A (Configuration File) ### Parameters This section describes the components used within the `minecraft:spawn_rules` structure. #### Components - **minecraft:biome_filter** (object) - Allows players to specify which biomes the mob spawns in. It uses biome tags for filtering. - **minecraft:brightness_filter** (object) - Allows players to set the light level range that causes the mob to spawn. Includes `min`, `max`, and `adjust_for_weather` options. - **minecraft:difficulty_filter** (object) - Allows creators to set which mobs spawn depending on difficulty level. Accepts `min` and `max` difficulty levels. - **minecraft:density_limit** (object) - Allows players to specify the amount of mobs to spawn in certain locations. - **minecraft:disallow_spawns_in_bubble** (object) - Allows creators to keep entities from spawning in bubbles. - **minecraft:distance_filter** (object) - Allows players to set specific distances for entities to spawn. - **minecraft:entity_types** (object) - Encapsulates entity data for use in behaviors and components. - **minecraft:height_filter** (object) - Allows players to set mob spawning within specific heights of the map. - **minecraft:herd** (object) - Allows players to determine the herd size of animals. Includes `min_size` and `max_size`. - **minecraft:mob_event_filter** (object) - Allows players to spawn mobs on specific mob events. - **minecraft:operator** (object) - Defines arithmetic operators for comparing data points. - **minecraft:permute_type** (array) - Allows players to specify the permutations of a mob that will spawn. Each permutation has a `weight` and optionally an `entity_type`. - **minecraft:player_in_village_filter** (object) - Filters spawns based on player proximity to a village. - **minecraft:spawn_event** (object) - Event related to the spawning of an entity. - **minecraft:spawns_lava** (object) - Determines if an entity spawns on lava. - **minecraft:spawns_on_block_filter** (object) - Allows an entity to spawn on a particular block. - **minecraft:spawns_on_block_prevented_filter** (object) - Prevents an entity from spawning on a particular block. - **minecraft:spawns_on_surface** (object) - Allows an entity to spawn on the surface. - **minecraft:spawns_underground** (object) - Allows an entity to spawn underground. - **minecraft:spawns_underwater** (object) - Allows the mob to spawn underwater. - **minecraft:weight** (object) - Allows players to set a priority for how often that mob should spawn. Includes a `default` weight. - **minecraft:world_age_filter** (object) - Allows players to set mob spawns after a specified amount of time has passed within a world. ### Request Example ```json { "format_version": "1.8.0", "minecraft:spawn_rules": { "description": { "identifier": "minecraft:zombie", "population_control": "monster" }, "conditions": [ { "minecraft:spawns_on_surface": {}, "minecraft:spawns_underground": {}, "minecraft:brightness_filter": { "min": 0, "max": 7, "adjust_for_weather": true }, "minecraft:difficulty_filter": { "min": "easy", "max": "hard" }, "minecraft:weight": { "default": 100 }, "minecraft:herd": { "min_size": 2, "max_size": 4 }, "minecraft:permute_type": [ { "weight": 95 }, { "weight": 5, "entity_type": "minecraft:zombie_villager_v2" } ], "minecraft:biome_filter": { "test": "has_biome_tag", "operator": "==", "value": "monster" } } ] } } ``` ### Response N/A (Configuration File) #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### showTranslatedMessageForm.ts Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-ui/MessageFormResponse.md This example shows how to use MessageFormData with translated strings for the title and body, and logs the player's selection. ```APIDOC ## POST /minecraft/server-ui/showTranslatedMessageForm ### Description Displays a message form with translated text to a player and processes their button selection. ### Method POST ### Endpoint /minecraft/server-ui/showTranslatedMessageForm ### Request Body - **player** (Player) - The player to show the form to. - **log** (function) - A function to log messages. ### Request Example ```json { "player": "@minecraft/server.Player", "log": "function" } ``` ### Response #### Success Response (200) - **selection** (number) - The index of the selected button (0 or 1), or undefined if canceled. - **canceled** (boolean) - True if the form was canceled. #### Response Example ```json { "selection": 1, "canceled": false } ``` ``` -------------------------------- ### Implement block placement using system.runJob Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/scripting/system-run-guide.md This example demonstrates how to use a generator function to place a 10x10x10 cube of blocks incrementally. By yielding after each block placement, the job system can manage the workload based on available frame time. ```javascript import { system, world, BlockPermutation } from "@minecraft/server"; function* blockPlacingGenerator(size, startX, startY, startZ) { const overworld = world.getDimension('overworld'); const perm = BlockPermutation.resolve("minecraft:planks"); for (let x = startX; x < startX + size; x++) { for (let y = startY; y < startY + size; y++) { for (let z = startZ; z < startZ + size; z++) { const block = overworld.getBlock({ x: x, y: y, z: z }); if (block) { block.setPermutation(perm); } yield; } } } } system.runJob(blockPlacingGenerator(10, -2, -60, 1)); ``` -------------------------------- ### Navigate to Documentation Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/BuiltInUIManager.md Navigates the player to the documentation site. This method returns void. ```typescript navigateToDocumentation(): void ``` -------------------------------- ### Minecraft: is_target Entity Filter Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/Filters/is_target.md This JSON snippet demonstrates the usage of the 'minecraft:is_target' entity filter. The first example shows a full configuration with explicit 'subject', 'operator', and 'value'. The second example shows a concise version utilizing default values. ```json { "test": "is_target", "subject": "self", "operator": "equals", "value": "true" } ``` ```json { "test": "is_target" } ``` -------------------------------- ### Get Help with Commands Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Documents/CommandsPopularCommands.md Use the /help command to list all available commands or to get detailed usage information for a specific command. ```minecraft-commands /help /help [command: CommandName] ``` -------------------------------- ### Using ActionFormResponse - showFavoriteMonth Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-ui/ActionFormResponse.md Another example illustrating how to use ActionFormResponse to determine a player's favorite month selection. ```APIDOC ## Example: showFavoriteMonth.ts ### Description This example demonstrates displaying a list of months in an action form and checking the player's selected month using the ActionFormResponse. ### Method `form.show(player)` returns a Promise that resolves with an `ActionFormResponse` object. ### Response Handling - **canceled** (boolean) - True if the player canceled the form. - **selection** (number) - The index of the selected button (month). For example, if the player selects 'April', `response.selection` would be 3. ### Request Example ```typescript import { world } from '@minecraft/server'; import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui'; // ... inside a function const player = world.getPlayers()[0]; const form = new ActionFormData() .title('Months') .body('Choose your favorite month!') .button('January') .button('February') .button('March') .button('April') .button('May'); form.show(player).then((response: ActionFormResponse) => { if (response.selection === 3) { console.log('Player likes April!'); } }); ``` ``` -------------------------------- ### Is Snow Covered Filter - Full Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/Filters/is_snow_covered.md This example shows the full syntax for the is_snow_covered filter, including subject, operator, and value. ```json { "test": "is_snow_covered", "subject": "self", "operator": "equals", "value": "true" } ``` -------------------------------- ### Example: Placing Oak Tree then Apples - JSON Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/FeaturesReference/Examples/Features/minecraftSequence_feature.md An example demonstrating the use of 'minecraft:sequence_feature' to first place an oak tree and then scatter apples within its canopy. This illustrates how to chain features together for a desired outcome. ```json { "format_version": 1.13.0, "minecraft:sequence_feature": { "description": { "identifier": "example:oak_tree_then_apples_feature" }, "features": [ "example:oak_tree_feature", "example:scatter_apples_feature" ] } } ``` -------------------------------- ### Example: Setting and Extinguishing Fire on an Entity Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server/EntityOnFireComponent.md Demonstrates how to use the setOnFire and extinguishFire methods on an entity, and how to access the onFireTicksRemaining property of the EntityOnFireComponent. ```APIDOC ## Example: setOnFire.ts ### Description This example shows how to spawn a skeleton, set it on fire for a duration, log the remaining fire ticks, and then extinguish the fire. ### Method This is a TypeScript example using the @minecraft/server API. ### Endpoint N/A (Client-side script example) ### Request Example ```typescript import { system, EntityOnFireComponent, EntityComponentTypes, DimensionLocation } from '@minecraft/server'; import { MinecraftEntityTypes } from '@minecraft/vanilla-data'; function setOnFire(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) { const skelly = targetLocation.dimension.spawnEntity(MinecraftEntityTypes.Skeleton, targetLocation); skelly.setOnFire(20, true); system.runTimeout(() => { const onfire = skelly.getComponent(EntityComponentTypes.OnFire) as EntityOnFireComponent; log(onfire?.onFireTicksRemaining + ' fire ticks remaining.'); skelly.extinguishFire(true); log('Never mind. Fire extinguished.'); }, 20); } ``` ### Response N/A (This is a client-side script example) ### Further Information Work with this sample on the [MCTools.dev](https://mctools.dev/?open=gp/setOnFire.ts) code sandbox. ``` -------------------------------- ### Pig Transformation Example Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/EntityReference/Examples/EntityComponents/minecraftComponent_transformation.md This example shows a pig transforming into a zombie piglin. It specifies the target entity, a transformation sound, and a delay. ```json "minecraft:transformation": { "into": "minecraft:pig_zombie", "transformation_sound": "mob.pig.death", "delay": 0.5 } ``` -------------------------------- ### createIntroductionPane Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/ScriptAPI/minecraft/server-editor/IPaneManager.md Create a pane to be shown on the introduction window. ```APIDOC ## createIntroductionPane ### Description Create a pane to be shown on the introduction window. ### Method Signature `createIntroductionPane(options: IIntroductionPaneOptions): IIntroductionPane` ### Parameters #### Path Parameters - **options** (IIntroductionPaneOptions) - Required - Options for the introduction pane. ### Returns - **IIntroductionPane** - The created introduction pane. ``` -------------------------------- ### Join Experience Source: https://github.com/microsoftdocs/minecraft-creator/blob/main/creator/Reference/Content/deep-links.md Launches the client into a specific Experience using a UUID. Optional parameters include worldId and friendID. ```text minecraft://joinExperience?experienceId=8c0495bf-aaf0-483e-b488-1b37e8c74745 ```