rhodrainiercursaw-lab

Act as an expert Minecraft Bedrock Add-on developer specializing in modern JavaScript Scripting API (@minecraft/server). I need a complete, error-free Behavior Pack (.mcpack) for Minecraft version 1.21.0+.

The add-on is a "Stealth Survival Flight" tool disguised as a piece of Flint. When a player crouches and right-clicks/long-presses with Flint, it toggles their ability to fly in Survival mode.

Please generate the manifest.json and main.js files based on these exact technical specifications to ensure it works perfectly on mobile:

1. Trigger Requirements

  • Event Hook: Use world.afterEvents.itemUse.subscribe.
  • Item Check: Check if the item used is exactly "minecraft:flint".
  • Condition: Check if player.isSneaking is true. If false, do nothing.

2. Robust Flight Toggle Logic

  • Maintain an in-memory tracking system using a global const flyingPlayers = new Set();.
  • To avoid "Player is not an operator" permission errors in Survival mode, do NOT use player.runCommandAsync. Instead, route the command through the server dimension using:

player.dimension.runCommandAsync(ability "${player.name}" mayfly true/false);

  • Toggle Logic:

- If the player's ID is in the Set: Remove them, turn mayfly to false, and send an action bar message. - If the player's ID is NOT in the Set: Add them, turn mayfly to true, and send an action bar message.

3. Syntax & Encoding Safeguards (Crucial)

  • Text Formatting: Use the Unicode escape character \u00A7 for color codes instead of the raw section symbol (§) to prevent mobile text corruption. (e.g., "\u00A7a[System] Fly Mode: ON").
  • Code Completeness: Ensure all brackets, parentheses, and event subscriptions are completely closed. Include a world.afterEvents.playerLeave listener to clean up disconnecting players from the Set.

Please output the full manifest.json and the complete, uncorrupted main.js script.

Kodari AI
KodariJun 23 at 8:23 am 1

I’ll create this Stealth Survival Flight add-on behavior pack.

StealthFlightFlint
A stealth survival flight toggle add-on for Minecraft Bedrock 1.21.0+. Players crouch and use Flint to toggle creative-style flight in Survival mode. Uses @minecraft/server scripting with dimension-based ability commands to avoid operator errors. Tracks active flyers in memory and cleans up on disconnect. All messages use Unicode color codes for mobile compatibility.

manifest.json:

JSON
{
  "format_version": 2,
  "header": {
    "name": "Stealth Survival Flight",
    "description": "Crouch + use Flint to toggle flight in Survival mode",
    "uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "version": [1, 0, 0],
    "min_engine_version": [1, 21, 0]
  },
  "modules": [
    {
      "type": "script",
      "language": "javascript",
      "uuid": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
      "entry": "scripts/main.js",
      "version": [1, 0, 0]
    }
  ],
  "dependencies": [
    {
      "module_name": "@minecraft/server",
      "version": "1.13.0"
    }
  ],
  "capabilities": ["script_eval"]
}

scripts/main.js:

JavaScript
import { world, system } from "@minecraft/server";

const flyingPlayers = new Set();

world.afterEvents.itemUse.subscribe((event) => {
    const { source: player, itemStack } = event;

    if (!player || !itemStack) return;
    if (itemStack.typeId !== "minecraft:flint") return;
    if (!player.isSneaking) return;

    const playerId = player.id;

    if (flyingPlayers.has(playerId)) {
        flyingPlayers.delete(playerId);
        player.dimension.runCommandAsync(`ability "${player.name}" mayfly false`);
        player.onScreenDisplay.setActionBar("\u00A7c[SSF] Fly: OFF");
    } else {
        flyingPlayers.add(playerId);
        player.dimension.runCommandAsync(`ability "${player.name}" mayfly true`);
        player.onScreenDisplay.setActionBar("\u00A7a[SSF] Fly: ON");
    }
});

world.afterEvents.playerLeave.subscribe((event) => {
    flyingPlayers.delete(event.playerId);
});

Directory structure to assemble:

Plain Text
StealthFlightFlint_BP/
├── manifest.json
└── scripts/
    └── main.js

To build the .mcpack: zip the StealthFlightFlint_BP folder and rename the extension to .mcpack — or zip the folder’s contents directly and rename. Your choice.

Kodari can make mistakes. Review important code before using.
Files

No files in this session

Code