本条基于 Minecraft 1.20.1 + Forge,Mojang 映射名。
EntityCommand(net.minecraftforge.server.command.EntityCommand)是 Forge 提供的 /forge entity list [过滤器] [维度] 指令实现,用来统计某个维度中各类实体的数量和分布。
/forge entity list 链路
EntityCommand → ServerLevel.getEntities() → LevelEntityGetterAdapter.getAll() → Iterable.forEach → 用 Map 汇总
与实体储存的关系
- 数据来源是
getAll(),即 EntityLookup 的 Int2ObjectMapbyId,只统计当前已加载(可见)的实体。 - 先按实体类型注册名分组,再按
ChunkPos统计每个区块的数量;过滤器支持*、?通配。 - 不读 EntityTickList,所以不 tick 的实体也会被计入;不在
byId里的实体则不会出现。