@ascentbv/ts-common - v1.0.123
    Preparing search index...

    Class DPUtilAbstract

    Index

    Constructors

    Methods

    • Register (or extend) the known property defaults for this project. Call once during startup after your project’s DPRegistry augmentation is loaded.

      Parameters

      Returns void

      import { Properties } from "./Properties";
      DPUtil.registerProperties(Properties);
      • Values here act as fallbacks for get when the dynamic property isn’t set yet.
      • Types are enforced by the merged DPRegistry.
      • Calling this multiple times merges new keys/values into the existing defaults.
    • Read a dynamic property from an Entity or the World. Returns the stored value if present; otherwise returns the registered default. Result is cached for subsequent reads.

      Type Parameters

      Parameters

      Returns RegistrySchema[K]

      The typed value for the given key.

      const hasBook = DPUtil.get(player, "HasBook"); // boolean
      const ver = DPUtil.get(world, "currentVersion"); // string (from Core)
      • Uses DebugTimerUtil profiling with label DP.get:<key>.
      • Caches values separately for the world and per-entity by id.
      • If the value is not stored yet, the registered default is written via DPUtil.set so subsequent reads avoid default resolution.
    • Write a dynamic property to an Entity or the World. Also updates the in-memory cache. Passing undefined removes the property.

      Type Parameters

      Parameters

      Returns void

      DPUtil.set(player, "HasBook", true);
      DPUtil.set(world, "currentVersion", "1.2.3");

      // Remove a value so future reads fall back to the registered default
      DPUtil.set(player, "HasBook", undefined);
      • Uses DebugTimerUtil profiling with label DP.set:<key>.
      • Under the hood, Minecraft dynamic properties accept only string | number | boolean | Vector3 | undefined.
      • For entities, an empty per-entity cache is removed to keep memory tidy.