PrivateconstructorStaticgetThis function can't be called in early-execution mode.
import { EntityTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:getcreepertype` in chat to inspect the creeper entity type.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:getcreepertype" || !(sourceEntity instanceof Player)) return;
const entityType = EntityTypes.get("minecraft:creeper");
if (!entityType) return;
sourceEntity.sendMessage(`Found entity type: ${entityType.id}`);
});
StaticgetThis function can't be called in early-execution mode.
import { EntityTypes, Player, system } from "@minecraft/server";
// Run `/scriptevent example:listentitytypes` in chat to list registered entity type IDs.
system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
if (id !== "example:listentitytypes" || !(sourceEntity instanceof Player)) return;
const entityIds = EntityTypes.getAll().map((entityType) => entityType.id);
sourceEntity.sendMessage(`Entity types (${entityIds.length}): ${entityIds.slice(0, 10).join(", ")}`);
});
Used for accessing all entity types currently available for use within the world.
Source