Debugging, performance, tools
Debugging methods at a glance
The approaches summarized in the official documentation are as follows (Source: ms-learn, creator/Documents/scripting/debugging-scripts.md).
| Method | Suitable for | Difficulty |
|---|---|---|
| Console log | Quick checks, simple problems | Easy |
| Content log | JSON errors, pack loading problems | Easy |
| VS Code debugger | Complex logic, variable inspection | Medium |
| User tools | Variable changes over time | Medium |
| Visual debug tools | Spatial problems, entity tracking | Hard |
| Script profiler | Performance problems | Hard |
Content log and console
Turn on the content log under Content Log Settings in the Creator section of the settings. Content Log File writes to a file and Content Log GUI shows it on screen in real time, and the GUI Log Level is Verbose (everything), Info (console output and warnings and errors), or Warn (only warnings and errors). The log file is in %APPDATA%\Minecraft Bedrock\logs\ for GDK builds (1.21.120 and above) and %APPDATA%\Minecraft Bedrock Preview\logs\ for the Preview. console.warn() is always visible regardless of log level, and console.log() is visible only at Verbose or Info.
import { world, system } from "@minecraft/server";
system.runInterval(() => {
const players = world.getAllPlayers();
console.warn(`Player count: ${players.length}`);
for (const p of players) {
console.warn(`Player ${p.name} at ${p.location.x}, ${p.location.y}, ${p.location.z}`);
}
}, 100);
const DEBUG_MODE = true;
function debugLog(category, msg) {
if (DEBUG_MODE) console.warn(`[${category.toUpperCase()}] ${msg}`);
}
VS Code debugger
Install Mojang's extension "Minecraft Bedrock Edition Debugger" (mojang-studios.minecraft-debugger) and open VS Code at the development_behavior_packs folder. The project's .vscode/launch.json is as follows, and the default port is 19144. For TypeScript, use sourceMapRoot (the source map folder) and generatedSourceRoot (the generated js folder) instead of localRoot (Source: ms-learn, creator/Documents/scripting/vscode-debugger.md).
{
"version": "0.3.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Debug with Minecraft",
"mode": "connect",
"targetModuleUuid": "<script module UUID>",
"localRoot": "${workspaceFolder}/",
"port": 19144
}
]
}
Start debugging with F5 to leave VS Code waiting, and run /script debugger connect in the game to get "Debugger connected to host". The Windows client needs a loopback exemption (CheckNetIsolation.exe LoopbackExempt -a -p=<package SID>) set once with administrator rights. For BDS it is the reverse: the server waits for the debug connection, and you turn on the script debugging allowance in server.properties. You can use breakpoints, conditional breakpoints, watch expressions and the debug console, and to see client diagnostics, turn on Enable Client Diagnostics in the creator debug settings.
Profiler
/script profiler start
... (play as usual for a few minutes)
/script profiler stop
When stopped, a timestamped .cpuprofile is created in the log folder, and you open it with VS Code. The result shows function name, Self time (its own code), Total time (including what it called) and call count, and since 1.19.10 it also covers core API calls. Look for functions with a large total time, functions called more often than expected, and unexpected API calls (Source: ms-learn, creator/Documents/scripting/script-performance.md).
Performance principles
- Native calls are expensive, so keep a value you got once (dimension, player list) in a variable and reuse it.
- Do not process large data in one tick; split it with
runJob. - Use events instead of polling every tick. For lookups, pass filter options (
type: "minecraft:zombie"and so on) to the API. - Do not summon too many entities, and keep ticking areas only as large as needed.
// slow: gets the dimension again every tick
system.runInterval(() => {
world.getDimension("overworld").spawnEntity("minecraft:experience_orb", { x: 0, y: 10, z: 0 });
}, 1);
// better: get it once outside
const overworld = world.getDimension("overworld");
system.runInterval(() => {
overworld.spawnEntity("minecraft:experience_orb", { x: 0, y: 10, z: 0 });
}, 1);
Types and external diagnostics
With the types installed by npm i @minecraft/server, VS Code shows autocomplete and inline documentation. @minecraft/debug-utilities provides debug shapes and runtime statistics, and @minecraft/diagnostics provides Sentry integration (sentry.initialize, captureException). The starter in the official sample repository minecraft-scripting-samples comes with this tooling preconfigured (Source: ms-learn, developer-tools.md).
Community notes
Below are the log, /reload and debugger troubleshooting, performance tips, and the list of tools and libraries gathered from the community research.
Verification level marks follow the legend on the wiki home page. The basis of this page is community reports, and they may differ from the official Mojang documentation.
Debugging and logs
- Content log: Settings > Creator (creator settings) > Content Log GUI/file. The file is in
AppData/Roaming/Minecraft Bedrock/logs. A case where a log piled up to 30 GB was the cause of 5~15 FPS. For the "discovered package with uuid" noise, set the GUI log level to Info/Warn. console.logvsconsole.warn: The log level must include info forconsole.logto show. At warn, onlyconsole.warn/errorshow.console.login a hot path causes CPU spikes, and logging 300 times in one tick ends the world through the watchdog.- The message "At least one of your resource or behavior packs failed to load" can be ignored if the pack works.
/reloadvs/reload all:/reloadis scripts only and/reload allis everything (a case where a manifest change needed a game restart). Stale context errors such asNative class [ItemStack] not registered for JSClassIDafter/reloadare fixed with/reload allor rejoining./reloadhot-reloads packs indevelopment_behavior_packsor the world folder, and packs added as .mcpack are copied into the world.- Mojang VS Code debugger (
https://github.com/Mojang/minecraft-debugger/, extensionmojang-studios.minecraft-debugger):launch.jsontypeminecraft-js, requestattach, modelisten,targetModuleUuid,localRoot,port. In 26.40~1.26.43 attach failed repeatedly/withECONNRESET. Change the request to"listen"and run/script connect localhost 19144(orscript debugger listen 19144) in the game, and Windows needs aCheckNetIsolationloopback exemption. For BDS,allow-outbound-script-debugging/allow-inbound-script-debugginginserver.properties. Attaching at server start makes loading spikes look large. - Profiler: Create a file with
/script profiler start/stopand open it in the VS Code debugger. Self time = its own code, Total = including calls..cpuprofileshows idle as a large self-time, has no call counts and is aggregated, so it may be less reliable. Creator > Enable Client Diagnostics. Documentation:https://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/developer-tools?view=minecraft-bedrock-stable - Tracing memory leaks: Dump
@minecraft/debug-utilitiesruntimeStats(QuickJS counters) over time. - Diagnostic capture:
script diagnostics stopcapturewrites a.mcstatsfile (presumed to be readable by the debugger extension,{unverified}). The debugger extension also shows server and client performance statistics. - JaylyBot in #debug-playground: A ```js code block message > Apps > "Debug Scripts" returns errors and debug.log (not a slash command, usable in DMs too, only valid JS/TS). It publishes
.d.tsper module, and modules without a stable are "not found in stable". The;compilebot is for plain Node JS and is useless for the Script API. The bot's warning about string slot names ('Mainhand') is a false positive but the names are case-sensitive ('mainhand'and'slot.weapon.mainhand'fail)./docs info <module>gives the version list. (One reporter's caveat: a bot channel note, partly inferred)
Performance and memory
- Tick budget: All work of the server (the engine and all add-ons) shares one 50 ms tick. The advice is to keep one add-on usually under about 10 ms and even momentary bursts within 15~30 ms. Common causes of lag are unnecessary command execution and scanning inventories every tick, and spikes are prevented by splitting work across ticks and caching results.
- Reduce native calls: Native getters such as
player.nameare 20~30 times slower than a JS Map lookup. Property access such asentity.locationandsystem.currentTickalso crosses the API boundary, so cache once per tick, cache components in a WeakMap, avoid allocating objects and strings in hot loops (8000 times: 0.38 ms vs 1.65 ms), and keep regexes as constants. Reducing API call count matters more than splitting work, and unused functions cost nothing. runCommandis slower than native APIs (runCommand, then the parser, then the engine). Prefer native methods (player.addItemvs/give,setActionBarvstitle,inputPermissionsvs/inputpermission). Do not call commands in bulk from scripts. Counter example: theeffect clearcommand was faster thanclearEffectper effect. Comparisons of the CPU cost of commands and scripts differ between reports{conflict}. There is also a counterargument that command block lag is due to what each command does and not their count{single report}. Commands return no feedback text, onlysuccessCount.runCommandis a method of Entity/Player/Dimension and is not onworld.- Events > polling: Events such as entitySpawn are better than tick function polling, proximity checks every 5~20 ticks, and equipment detection polling every 5~20 ticks. Instead of repeating
getEntities, maintain a Set/Map withentitySpawn/entityLoad/entityRemove(also a trick of tracking with a harmless effecteffectAddordataDrivenEntityTrigger) and process only N per tick (for example 8) from onerunInterval- a case that kept 217 entities at 20 TPS. An inventory change filter will probably be faster than 200hasitemtag commands per tick (benchmarking recommended). - Block APIs are the bottleneck:
Dimension.fillBlocksandDimension.placeFeatureare very slow in the Script API, and one opinion holds that an mcfunction fill (even block by block) can be faster. Running the same code under Node.js (Endstone) does not help much, because the bottleneck is the Bedrock API itself{single report}. - Entity cost guides:
Dimension.getEntities~0~1 ms. On BDS (Ryzen 9 7950X), about 500 wandering zombies is the 20 TPS limit, tracking/pathfinding is more expensive, and on a cheap VPS TPS drops from 300~350. Script pathfinding lags, so use JSON AI. cannon-es ragdoll physics works without experiments but lags with many mobs (crashcathttps://crashcat.devrecommended, Rapier uses Sable). - Interval hygiene: Do not nest intervals inside other intervals; fewer is better, but in a merged interval one function's failure stops the rest, so use try/catch per job. One shared
runIntervalacross add-ons is cheaper than several. Per-player intervals are fine if cheap. Avoid heavy intervals that scan all dimensions every few seconds, and a singleInvalidEntityErrorcan stop a tick script. - QuickJS micro-optimizations: switch is slower than an object map (no JIT, tag dispatch
FUNC_LISTS[tag]()), a for loop is faster than forEach,.find/filter are better than.map, use Set/Map (O(1)) for big lookups, and generator helpers are lazy and single-pass but slightly slower than raw loops. There are measurements thatvarwas 25~30% faster thanletandawaitslower than.then, but the differences are small so let/const is recommended. For frequent key additions/deletions use a Map (an object had a leak in one case). Weighted random uses the alias method (https://www.keithschwarz.com/darts-dice-coins/) or cumulative weights.import * as mccan increase bundle size. - FPS: Scripts usually do not affect FPS (particles and entities are the cause). Spawning many entities in one tick lags, so spawn once and then teleport, spread across ticks, set a cap. Many Marketplace add-ons are a cause of low TPS, and the player's Memory Tier setting also affects add-on loading.
- Causes of memory leaks: Listeners that are not released, global arrays/Maps that hold entities and items forever, intervals not cleaned up, per-player Maps not deleted.
/reloadkills intervals but old module data remains until GC (a leak where a ticking area is created and not released was reported as MCPE-236954). Using prototype getters as Player keys can leak, so use a WeakMap or clean up on leave. A large DP DB can cause a TPS drop that does not show in the profiler. - Code protection: There is no true JS obfuscation. Obfuscation is easily reversed, causes engine errors and performance loss, and breaks multi-file import/export (bundle first), and eval-based schemes are quickly decoded. esbuild minify + symbol renaming is about what is realistic, and a license (choosealicense.com) is the practical protection. DPs are accessible only from the same script environment, so there is no reason to protect them by obfuscation. JSON cannot be protected, and add-ons cannot be restricted by IP/port.
Tools and references
- API documentation: Microsoft Learn
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/?view=minecraft-bedrock-stable(check names in the experimental?view=minecraft-bedrock-experimental; per event class page examplehttps://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/playerspawnafterevent; documentation examples are sometimes outdated; report errors to the bedrock-samples / MS Learn repository or the feedback channel), JaylyDevhttps://jaylydev.github.io/scriptapi-docs/latest/(rated better than the official by the community, platform differences #platform-differences, privilege explanation /features/script-privileges.html, for LLMshttps://jaylydev.github.io/scriptapi-docs/meta/llms.htmland llms.txt; up to 26.20 as of 2026-06), stirantehttps://stirante.com/script/(per versionhttps://stirante.com/script/server/<version>/classes/<Class>.html, server-ui, server-admin, debug-utilities, server-graphics, version diffhttps://stirante.com/script/diff.html, examplehttps://stirante.com/script/diff.html#%40minecraft%2Fserver/2.1.0/2.7.0; moved to CloudFront/S3; documentation generation repositoryhttps://github.com/stirante/bedrock-script-api-docs). JaylyDev Preview documentationhttps://jaylydev.github.io/scriptapi-docs/preview/. MSsystem.runguidehttps://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/system-run-guide?view=minecraft-bedrock-stable, documentation error reportshttps://github.com/MicrosoftDocs/minecraft-creator/issues(there is feedback that the MS TypeScript introduction article is outdated). - Wiki/guides:
https://wiki.bedrock.dev/scripting/what-is-script, /scripting/scripting-intro , /scripting/api-modules , /scripting/resources , /scripting/typescript , /scripting/privileges , /scripting/custom-commands , /scripting/script-server (running commands, list of unimplemented commands), wiki repositoryhttps://github.com/Bedrock-OSS/bedrock-wiki/tree/wiki; MS documentation: scripting introductionhttps://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/introduction?view=minecraft-bedrock-stable, custom componentshttps://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/custom-components?view=minecraft-bedrock-stable, item custom componentshttps://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server/itemcustomcomponent?view=minecraft-bedrock-stable, the v2 overview, TS next stepshttps://learn.microsoft.com/en-us/minecraft/creator/documents/scripting/next-steps?view=minecraft-bedrock-stable, custom pack settingshttps://learn.microsoft.com/en-us/minecraft/creator/documents/addons/custompacksettings?view=minecraft-bedrock-experimental, block state listhttps://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/intrinsicblockstateslist?view=minecraft-bedrock-stable, block fall onhttps://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/blockcomponents/minecraftblock_entity_fall_on?view=minecraft-bedrock-stable. Custom cropshttps://wiki.bedrock.dev/blocks/custom-crops, block eventshttps://wiki.bedrock.dev/blocks/block-events, team damage (JSON)https://wiki.bedrock.dev/entities/disabling-team-damage.html, invulnerable entitieshttps://wiki.bedrock.dev/entities/invulnerable-entities, runtime identifierhttps://wiki.bedrock.dev/entities/runtime-identifier, custom emojihttps://wiki.bedrock.dev/text/custom-emojis. - Types/metadata: npm
@minecraft/server,@minecraft/server-ui,@minecraft/server-net,@minecraft/server-admin,@minecraft/server-gametest,@minecraft/debug-utilities,@minecraft/math,@minecraft/vanilla-data,@bedrock-apis/env-types(https://github.com/bedrock-apis/env-types), Ore UI typesore-ui-types,@ore-ui-types/enums. Vanilla metadatahttps://github.com/bedrock-apis/bds-docs/tree/preview/metadata/vanilladata_modules, Mojang bedrock-sampleshttps://github.com/Mojang/bedrock-samples(recipes, particles, textures/fonts), vanilla RPhttps://github.com/ZtechNetwork/MCBVanillaResourcePack. Finding the minimum version (tsc type checking against all versions)https://waveplayz.github.io/bedrock-api-version-finder/. For AI, having it read the.d.tsis better than human documentation (minecraft_server.d.ts~200K context). - Development tools: Mojang debugger
https://github.com/Mojang/minecraft-debugger/(VS Codemojang-studios.minecraft-debugger), developer tools documentation, theminecraft-scripting-samplests-starter (bundles all modules into one main.js), Regolith (esbuild local filter, Rolldown filterhttps://github.com/azurite-bedrock/regolith-filters/tree/main/dinoscript, comptimehttps://github.com/azurite-bedrock/rolldown-plugins/tree/main/comptime,https://github.com/lukeed/comptime, serdehttps://github.com/arexon/serdeco; the oxc family rolldown/oxlint/oxfmt, tsgo; TypeScript 7.0 (Go port) released 2026-07-08), JaylyBot (#debug-playground), online editorhttps://minato.beyondbedrock.org/web-apps/web-editor.html, command builderhttps://cmd-builder.beyondbedrock.org/, mctools.dev, thebdspackage managerhttps://github.com/PhantomXD-nepal/bds(bds init|list|add), world editinghttps://github.com/8Crafter-Studios/Bedrock-World-Editor,https://bedrocktoolchest.com/download,https://www.chunker.app/. - Libraries: bedrock-boost (
https://github.com/Bedrock-OSS/bedrock-boost; vector/command utilities,PlayerPulseScheduler,EntitySaver,testfor-basedisItem), adk-scriptshttps://github.com/SmokeyStack/adk-scripts, Script-API-Utilitieshttps://github.com/IMvampireXD/Script-API-Utilities(runJob utilities, terrain generation), MCBE-IPC / DirectIPC / @mcbe-mods/ipc / AddonAPIKit / DataExchange / matp, command-wrapper (github.com/Aevarkan/command-wrapper), QIDB / QUICK-ITEM-DATABASE, ShulkerDBhttps://github.com/Duskaraa/shulkerdb, script-api-database, KinetixDB, bedrock-websocket-server, Looky Toolhttps://github.com/abrightmoore/lookytool, CALMhttps://github.com/abrightmoore/calm-add-on, Bedrock-Persona (github.com/Daniel-Ric/Bedrock-Persona), Be.D.D.https://github.com/LiteLDev/BeDD, the JaylyDev script interpreter articlehttps://jaylydev.github.io/posts/script-interpreter/, Paradox AntiCheat (rewrite branch: data-hive.ts, player-cache.ts, event-coordinator.tshttps://github.com/Visual1mpact/Paradox_AntiCheat/blob/rewrite/penrose/classes/core/event-coordinator.ts, criticals.ts, dome.js), UnloadedUtils, ChunkLoader, Jobs.js (priority jobs), Chest-UI (Herobrine643928), Chest-Form (Sprixvy), InvUI for Bedrockhttps://github.com/kaaariyaaa/InvUI-for-Bedrock(a container GUI library modeled on Java InvUI, usable only on Preview versions as of 2026-11-16), Detect-Clickhttps://github.com/mittens4all/Detect-Click(scoresdetect:right_click,detect:left_click), Player-Outline (github.com/JuanLuci/Player-Outline), tree fellinghttps://github.com/whynotoss/chop-chop(Apache 2.0), recursive-crafting (github.com/Efficient123/recursive-crafting), Sweep-N-Slashhttps://github.com/azurite-bedrock/Sweep-N-Slash(and CurseForgehttps://www.curseforge.com/minecraft-bedrock/addons/sweep-n-slash), WebhookAPI, OverTakesJS (conmaster2112, prototype patching), the QuantumBE/Daniye CPS counter, Better Knockback (Agg-dev; repository deleted), JaylyDev/interpreterhttps://github.com/JaylyDev/interpreter, Generic DDA and a block state codec (WavePlayz gist), Native Local & Relative Coordinates utilities, simplified-mojang-apihttps://github.com/HaJuegos/simplified-mojang-API(npmsimplified-mojang-api; a wrapper that cuts@minecraft/serverevent boilerplate), simplified-mojang-JSONshttps://github.com/HaJuegos/simplified-mojang-JSONs(npmsimplified-mojang-jsons; generates pack JSON from TypeScript and overrides only parts of vanilla files). - Physics/others: cannon-es (MajestikButter/Physics-Test), crashcat
https://crashcat.dev, Rapier; a case of running a RISC-V Linux emulator on the Script API (slow). The Chinese edition's ShaderSDKhttps://mc.163.com/dev/mcmanual/mc-dev/mcdocs/4-ShaderSDK/0-%E6%A6%82%E8%BF%B0.html?catalog=1. A spreadsheet summarizing direction conventions (to be reflected in the wiki). - Node/external: Endstone (
scripting-nodejs-releaseV8 bindings, plugins), SerenityJS (a Node-based server), custom BDS software (QuickJS replaced with V8).
| id | Source | License | Commit | Accessed |
|---|---|---|---|---|
private-research | Private research (-) | - | 2026-11-13 | |
ms-learn | Minecraft Creator documentation (Microsoft Learn) | CC BY 4.0 (documentation), MIT (code) | a9fd1c0 | 2026-11-13 |
bedrock-wiki | Bedrock Wiki | CC BY 4.0 (docs/licenses/CC-BY-4.0.md in the repository) | 0930b39 | 2026-11-13 |