Skip to main content

Dynamic properties and data storage

Dynamic properties​

A dynamic property is a persistent key-value store attached to the world, entities, players and (non-stackable) ItemStacks. A value is one of boolean, number, string or Vector3, and you write it directly with setDynamicProperty(id, value) with no declaration. Giving the value undefined deletes it. The lookup and management methods are getDynamicProperty, getDynamicPropertyIds, getDynamicPropertyTotalByteCount (for checking total usage), clearDynamicProperties and setDynamicProperties (Source: ms-learn, creator/ScriptAPI/minecraft/server/World.md).

import { world } from "@minecraft/server";

// increment a number (simplified from the official example)
let n = world.getDynamicProperty("samplelibrary:number") ?? 0;
world.setDynamicProperty("samplelibrary:number", n + 1);

// store objects as JSON strings
const raw = world.getDynamicProperty("samplelibrary:longerjson");
const paint = raw ? JSON.parse(raw) : { color: "purple", intensity: 0 };
paint.intensity += 1;
world.setDynamicProperty("samplelibrary:longerjson", JSON.stringify(paint));

The key limits are 32,767 bytes per string and a sandbox per pack UUID (if you change the UUID, the previous data is no longer visible). So when updating, keep the pack UUID and raise only version.

Storage on entities and players​

player.setDynamicProperty("my:score", 10);
const score = player.getDynamicProperty("my:score") ?? 0;
player.setDynamicProperty("my:score", undefined); // delete

Player DPs can be written even during death, which is useful for death handling. You can also write them on an ItemStack, but an ItemStack is a copy, so put it back in the slot after writing.

const item = container.getItem(0);
item.setDynamicProperty("my:owner", player.id);
container.setItem(0, item);

Example: showing a per-player count in a form​

Each time a player uses a compass, the example adds 1 to that player's count in a player dynamic property and shows the value in an ActionFormData form. The second button of the form clears the count. With the code below as is, using the compass showed 1 and 2, and after clearing with the second button the next use showed 1 {measured} (example measurement record, 2026-11-27 Windows 1.26.65).

It relies on these facts from this wiki.

  • A player is written with setDynamicProperty(id, value) without a declaration and read with getDynamicProperty(id) ?? 0, and giving the value undefined deletes it (the two sections above on this page). Properties live in a sandbox per pack UUID, so keep the UUID when updating.
  • show is a world-changing call, so it cannot be called directly from a before event (restricted execution), and when forms overlap it can be canceled with UserBusy (the form summary in server-ui, server-net, server-admin, GameTest). So the form is opened from the after event world.afterEvents.itemUse. Opening a form from itemUse is the same as the shortest example in modal forms.
  • Check r.canceled before using the response, selection is the button number counted from 0, and the Promise of show can reject, so a catch is added (the response section and the ActionFormData section of modal forms).

The manifest dependencies need two modules. The other entries are the same as the minimal example in Script API overview.

"dependencies": [
{ "module_name": "@minecraft/server", "version": "2.7.0" },
{ "module_name": "@minecraft/server-ui", "version": "2.0.0" }
]
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";

const USES_KEY = "wiki:compass_uses";

world.afterEvents.itemUse.subscribe(({ source, itemStack }) => {
if (itemStack.typeId !== "minecraft:compass") return;

const uses = (source.getDynamicProperty(USES_KEY) ?? 0) + 1;
source.setDynamicProperty(USES_KEY, uses);

new ActionFormData()
.title("Compass counter")
.body(`You have used the compass ${uses} times.`)
.button("Close")
.button("Reset count")
.show(source)
.then((r) => {
if (r.canceled) return;
if (r.selection === 1) source.setDynamicProperty(USES_KEY, undefined);
})
.catch((e) => {
console.error(e, e.stack);
});
});

The count is raised before the form opens. So even if the form is canceled with UserBusy because another UI is open, the count still goes up. The retry that the modal forms page describes (an achievement add-on retries every 10 ticks up to 20 times) is not included.

These parts have no example on this wiki and were carried over from the facts above. All of them worked in game with this example {measured}.

  • Reading and writing a player's dynamic property directly on the source of afterEvents.itemUse. The example on this page uses a player variable, and the example on the modal forms page uses source as the form target for the same event.
  • The chained .then(...).catch(...) form. The modal forms page shows the same form as plain code.
  • The manifest dependency pair 2.7.0 and 2.0.0. The example in manifest and the blocks page list the same pair.

Form types and response handling are in Server form API and form types.

Selection criteria​

For script data, it is better to use DPs than scoreboards. Scoreboards are easily cleared or edited by commands, and for large data they need many API calls and have size limits. Tags suit light flags, and large structures are split into several keys in DPs.

Community notes​

Below are block DPs, large-storage and hidden-data patterns 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.

Data storage​

Dynamic Properties​

  • Targets and types: World, all Entities (including projectiles) and Players, and non-stackable (max stack 1) ItemStacks. Values are only string, number, boolean and Vector3 (ItemStack and component objects are impossible, so use JSON.stringify). Write directly with setDynamicProperty(key, value) without a declaration, and an unset key is undefined (do not compare with == false; check with typeof). It cannot be set by commands. Resource packs and JSON UI cannot read DPs (for visuals, mirror it with a client_sync entity property or a title). {community confirmed}
  • Size limit: 32,767 bytes per string ("Maximum string size exceeded (x/32767) bytes"; the key too), cannot be raised, and the number of keys is unlimited, so split large data into several keys (id:i pieces + delete the leftover tail). Apart from the string limit, all World DPs together have a 1 MiB (1,048,576 byte) limit; going over gives Dynamic property size limit exceeded (current/limit) for 'World'. Another kind has a 128 KiB limit, but which owner is unknown {code}. The ~65,535 characters in early reports was wrong. A report that item/block DPs are about 1 KB (this value was not found in the code). Numbers above 9e15 cannot be stored as JSON numbers, so store them as strings.
  • Write volume warning: "X MB of dynamic properties were saved during the last minute, exceeding the 10 MB threshold" (every 30 seconds on BDS) is only a warning but a sign of a leak. Cases: a claim add-on that recorded a DP on every block placement left 434,962 entries (removed by a cleanup script inside the original pack, and the warning persisted after the pack was removed), and a land claim script that cloned instead of overwriting on every save wrote 32 MB per minute. The byte counts (world, console, getDynamicPropertyTotalByteCount) differ from one another. The total cap is not documented.
  • Storage method and performance: DPs are saved to disk in LevelDB. World DPs are bundled in one NBT tag so writing one re-saves everything, and there is a case where autosaving 33~55 KB every 60 seconds caused multi-second lag. Countermeasures: save only dirty data and less often, cache parse results in memory, one key per record (no single giant array), batch save every 20~30 seconds + save on leave. World DPs of a few hundred are no problem. Calling getDynamicProperty/getScore every tick is wasteful, so mirror in a Map. (The report that world DPs "do not cause lag by themselves" and the lag case above differ in data volume)
  • Deletion: setDynamicProperty(key) / (key, undefined) (the documentation says null but the type is undefined; a report that both delete). JSON.parse(undefined) throws, so check existence before parsing. Batch: world.setDynamicProperties({k: v}), iteration: getDynamicPropertyIds().
  • Pack UUID sandbox: A DP is bound to the BP (script module UUID) that made it. Other packs do not collide even if they use the same key, and cannot read it either. If you change the UUID, the data is not erased but only becomes invisible (restored if you go back to the original UUID). The same on Realms, and a Realm rollback rolls back DPs too. There is no way to transfer between worlds. Tags and scoreboards, on the other hand, are shared by the world.
  • Entity DPs vanish with the entity (despawn and death; can be read last in entityRemove). To preserve them, use world.setDynamicProperty(entity.id, ...) or save the entity to a structure. The DPs of an offline player cannot be read or cleared, so keep them in world DPs in the form playerId:key, clean old entries by last join time, and queue offline score changes and apply them on join. World storage is also better for the uninstall flow.
  • ItemStack DP: Only non-stackable items. An ItemStack taken out of a container is a copy, so after changing it you must write it back with container.setItem(slot, item), and it must be set on the stack that is actually placed/created (after spawnItem, on the new stack, not the stack to be replaced). ItemStack.clone() keeps DPs. Writing a DP to an item in use can lock the "in use" state.
  • Block DP: Until 2026-06 blocks had no DP, so data was stored in world DPs with dimension.id:x:y:z (including the dimension) keys (cost of handling explosions and pistons; the DP of a block item is lost on placement, and lore can carry data). In 26.40 there is a per-pack ~1 KB block DP limit, and in 1.26.50+ the block JSON needs "minecraft:block_entity": {"dynamic_properties": true} and format_version 1.26.50, accessed with block.getComponent("dynamic_properties") (.get, .totalByteCount()) (about 1 KB/block, deleted on block type change or break, so read in before-break or playerStartBreakingBlock). To carry it over to a dropped item, use the root function carry_over_block_entity_data ("dynamic_properties": true, 26.40, Upcoming Creator Features), and on the item side block_actor_dynamic_properties/ItemBlockDynamicPropertiesComponent (2.10). In the 27.0.20 Preview, BlockEntityStorageComponent, BlockEntityStorageInfo and ItemBlockEntityStorageComponent are stable in @minecraft/server 2.13.0. Documentation: https://learn.microsoft.com/en-us/minecraft/creator/reference/content/blockreference/examples/blockcomponents/minecraftblock_block_entity?view=minecraft-bedrock-stable
  • Per-chunk data: there is no chunk-level DP API. To keep per-chunk data without looping through every object in the world, store it in world DPs keyed by the chunk location with a namespace prefix.
  • Compact storage techniques: Booleans as bit flags (1<<n; bit operations are truncated to 32 bits, and above 31 bits use BigInt), positions as "x:y:z/" strings (about -50% in hexadecimal), parallel arrays instead of arrays of objects, compact encoding ("zinc_ingot.12.13.13.9") + a lookup table on the script side. There are both the opinion that splitting long strings into several keys is faster than compressing, and the Paradox data-hive approach, which makes it crash safe with LZ/LZW compression (~50~75% savings) + chunks + header + staged writes in the ~tmp namespace (a multi-key setDynamicProperties is not atomic). Compressed records are hard to query, so hide the serialization inside the DB. LEB128 binary serialization was also proposed. About 200 ops/sec (stress test).
  • "First load" flag: A world DP boolean guarantees worldLoad runs once. For one-time spawn flags too, use DPs rather than scoreboards.
  • DB wrapper pattern: Keep the target and key in private fields and do get/set + an isValid check on every access. DP as permanent storage and an in-memory Map as a cache.

Scoreboards and tags​

  • Scoreboard API: world.scoreboard.getObjective(id) ?? world.scoreboard.addObjective(id, displayName) (fails if called too early, so call in system.run/after world load; prevent re-adding), objective.setScore/addScore (addScore returns the new total), getScore, hasParticipant, getParticipants(), setObjectiveAtDisplaySlot(DisplaySlotId.Sidebar, {objective, sortOrder: ObjectiveSortOrder.Descending}).
  • Pitfalls: If there is no participant, getScore/setScore throw with "Failed to resolve identity" and the like, so check hasParticipant or try/catch. If the entity is invalid (unloaded/removed), hasParticipant(entity) is false even if the score entry remains. Comparing entity.scoreboardIdentity (readable even when invalid) with getParticipants() gives an entity presence tracker that distinguishes "unloaded" from "removed" (the ScoreboardIdentity id persists after reload, and isValid is false once removed). Objectives/participants can become invalid at runtime, so check isValid on cached objects. Scores are limited around 2^31 (split big numbers across several objectives). Fake players: getScore with a string participant constant (".Fake.Player"), and define objectives outside the interval.
  • Selection criteria: Prefer DPs for script data (scoreboards are easily cleared or edited by commands, big data needs many API calls and has size limits, and JSON-in-scoreboard cannot scale). Scoreboards suit light numbers, command and rawtext integration, and keeping offline identity (wrapper https://github.com/AutoAsteroid/script-api-database/blob/main/scoreboard.js). Hiding sidebar numbers: display name §h§n. Per-player scoreboard display is impossible (imitate with title/actionbar). A scoreboard stays in the world even if the pack is removed, but holds only integers.
  • Tags: 30-character limit per tag, there is a limit on count, and for boolean use. Reads are ~10% faster than DPs and writes ~2x slower (measured). hasTag takes exactly one tag (tags.some(t => e.hasTag(t)), and for several, call getTags() once). The opinion that tags are enough for per-entity booleans. Molang can see tags (query.all_tags) but not script DPs.

ItemStack and large storage​

  • Lossless ItemStack preservation: DP serialization loses NBT-only data (shulker contents, ominous bottle level, goat horn sound, banner patterns, trims). Recommended: copy into a custom entity inventory and save it with world.structureManager.createFromWorld(id, dim, loc, loc, {includeBlocks:false, includeEntities:true, saveMode: StructureSaveMode.World}) and remove the entity (memory cache + restore from the structure on reload), or a chest structure. Libraries: QIDB (needs real ItemStack storage; Map-like storage, no orphan key GC; moved to TickingAreaManager + a ready Promise on 2026-09-22, fixed storage location (27000,318,27000), needs Beta APIs), Carchi777 QUICK-ITEM-DATABASE (https://github.com/Carchi777/QUICK-ITEM-DATABASE , fork https://github.com/Aevarkan/item-database). Entities themselves also cannot be stored in DPs, so use structures (bedrock-boost EntitySaver: https://github.com/Bedrock-OSS/bedrock-boost/blob/main/src/utils/EntitySaver.ts).
  • QIDB V4 (Quick Item Database, https://github.com/MineCart7/QUICK-ITEM-DATABASE): saves ItemStacks with their NBT without stringifying. Keys may contain -, so player.id works as a key. Saving runs in the background with system.runJob, and the saveTime setting is its ms limit. It has pending, flush(key), unload(key), runtime settings and QIDB.packs, and two add-ons using QIDB in one world detect each other and warn about namespace clashes. License: Marketplace use needs an agreement with the author, and credit is required elsewhere.
  • DB libraries: https://github.com/AutoAsteroid/script-api-database (world.db, player.db, supports external JSON through server-net), KinetixDB (https://github.com/DevelopmentKinetix/KinetixDB , document-style insert/find/upsert), Paradox data-hive.ts. For numeric data of ~5000 players a DP DB is enough, an external DB costs latency and money, and one large JSON risks corruption. Use an external HTTP DB only as cold storage.
  • ShulkerDB (https://github.com/Duskaraa/shulkerdb , v1.2.0 2026-11-19): Map-like storage that bundles several JSON records into one DP (2,000 records in 12 keys) and batch-saves every second. ShulkerVault keeps real ItemStacks in storage entities (the performance claim against QIDB is disputed). A QIDB key holds up to 1024 items, so comparing with "200 keys of one item each" puts QIDB at a disadvantage; with 200 items in one key both performed about the same. A fair benchmark measures both storage layouts, and when timing with the Date.now() difference before and after, run it several times because values vary from run to run.
  • Pitfalls of storage entity DBs (gathered in the ShulkerDB review): when a vault entity is removed, it also deletes entries whose latest copy is elsewhere, a chunk unload is mistaken for entity removal and then it spawns into an unloaded chunk and crashes, leaving an emptied vault entity in the world causes duplication on restart and it picks up the wrong thing, and BigInt values break the setDynamicProperties batch save. Decide the spawn position with the stable dimension.heightRange.max and check dimension.isChunkLoaded(location) before spawning. The claim that entity-based DBs cannot be used on Realms is unverified {unverified}.
  • Very large data (millions of blocks): Items/books are unrealistic. Console log dumps, structure linking, and for BDS a server-net external DB (a case where moving to an external sqlite fixed the TPS drop). There is no file write API. Export data by saving an entity holding DPs as a structure or copying the content log.
  • Hidden data in stackable items: Encode numbers in lore with format codes (§0 sequences) or record an expiry tick (system.currentTick + N) (they do not stack if the values differ). There is also the opinion that lore is fragile for data storage.
  • In-memory state: Module-scope Maps/variables vanish on /reload and shutdown (kept until leaving or reloading the world). A global let is shared by all players (one BP per server). Do not store state on player objects; use a player.id keyed Map (a WeakMap is also possible).
Sources
idSourceLicenseCommitAccessed
private-researchPrivate research (-)-2026-11-13
ms-learnMinecraft Creator documentation (Microsoft Learn)CC BY 4.0 (documentation), MIT (code)a9fd1c02026-11-13