AbstractStaticsummonThe identifier of the entity to spawn or retrieve.
The Vec3 location to spawn the entity at.
The dimension to spawn the entity in.
Maximum number of retry attempts (default: 5).
Current attempt number (used internally for recursion).
The entity if immediately available or successfully spawned, undefined if chunk loading required (will retry in background).
// Returns entity immediately if available/spawnable, otherwise retries in background
const tutorialBeef = EntityUtil.summonOrGetProtectedEntityAsync(`${Data.NAMESPACE}:tutorial`, location, dimension);
if (tutorialBeef) {
NpcDialogueController.setNameTag(tutorialBeef, `${Data.NAMESPACE}:tutorial.start`);
}
// If undefined, the method will keep retrying in background until successful
// Synchronous version - returns undefined if chunk not loaded
const entity = EntityUtil.summonOrGetProtectedEntity("minecraft:zombie", location, dimension);
if (entity) {
// Entity was spawned or retrieved
} else {
// Chunk not loaded or other error occurred
}
StaticsummonSpawns or retrieves a protected singleton entity with retry logic for chunk loading (synchronous version). If the entity of this type has already been spawned and is tracked, returns that instance instead. This version attempts immediate spawning but falls back gracefully on chunk loading issues.
The spawned or retrieved Entity instance, or undefined if chunk loading fails.
StaticsummonSpawns or retrieves a protected singleton entity (backwards compatibility wrapper). This version will throw errors if chunk loading fails, maintaining old behavior. For safer operation, use the async version or handle undefined returns.
The spawned or retrieved Entity instance.
StaticgetRetrieves a protected/singleton entity by its type.
The type ID of the protected entity.
The entity if it exists and is valid; otherwise undefined.
StatichasChecks whether a protected entity of a given type has already been spawned and tracked.
The type ID to check.
True if a protected entity exists; otherwise false.
StaticspawnStaticspawnSpawns an entity with an initial rotation.
The spawned entity with rotation applied.
StaticgetStaticisChecks if an entity is affected by PvP logic. Currently only checks for player entities.
The entity to check.
True if the entity is a player.
StaticsetStaticgetStaticgetRetrieves all entities owned by the given entity.
The owner entity whose owned entities to find.
Optionaloptions: EntityQueryOptionsOptional query options to filter owned entities (e.g., by type, location, etc.).
An array of entities owned by this entity, or an empty array if none found.
StaticgetGets an entity by its Minecraft unique ID.
The entity's unique ID.
The entity, or undefined if not found.
StatichasChecks whether an entity belongs to one or more type families.
The entity to check.
One or more family strings to test for.
If true, all families must match. If false (default), at least one must match.
True if the entity belongs to the family/families.
StaticgetGets the base name of an entity (without namespace).
The entity to query.
The base name (e.g., "zombie" for "minecraft:zombie").
StaticgetIterate entities in a dimension with an optional query.
false and stopOnFalse is true, iteration stops early.Optionaloptions: EntityQueryOptionsStaticforIterate entities in a dimension with an optional query.
false and stopOnFalse is true, iteration stops early.Optionalopts: { stopOnFalse?: boolean; profileKey?: string }StaticforOptionalextraQuery: Omit<EntityQueryOptions, "families">Statictrigger
Spawns or retrieves a protected singleton entity with async retry logic for chunk loading. If the entity of this type has already been spawned and is tracked, returns that instance instead. If chunk loading fails, will retry with exponential backoff using TimerUtil.