Mmc秒杀圈百科 

EntitySelector:查看版本 v1

由 朝武芳乃 于 2026-10-04 01:00 保存 · 1378 字节
''本条基于 Minecraft 1.20.1 + Forge,Mojang 映射名。'' '''EntitySelector'''(<code>net.minecraft.commands.arguments.selector.EntitySelector</code>)是 <code>@e</code>、<code>@a</code>、<code>@p</code> 等目标选择器解析后的对象,<code>findEntities()</code> 负责到世界里查找实体。 == say @e 链路 == <code>SayCommand</code> → <code>MessageArgument</code> 解析消息里的选择器 → <code>EntitySelector.findEntities(source)</code> → 把实体名拼进消息。 == 与实体储存的关系 == * <code>@e</code> 默认:不限维度、不限数量、过滤条件为 <code>Entity::isAlive</code>。 * 指定 UUID:逐个维度调用 <code>ServerLevel.getEntity(UUID)</code>,最终查 [[EntityLookup]] 的 UUID [[Map]]。 * 不带范围:<code>ServerLevel.getEntities(EntityTypeTest, Predicate, List, int)</code> → [[LevelEntityGetterAdapter]] → 遍历 [[EntityLookup]] 的 [[Int2ObjectMap]]。 * 带 <code>dx/dy/dz</code> 或 <code>distance</code>:先算出 <code>AABB</code>,改走 <code>EntitySectionStorage</code> 按区块段查询,且只查执行者所在维度。 * 不限维度时遍历 <code>server.getAllLevels()</code> 中的每个 [[ServerLevel]]。 == 备注 == 它不读 [[EntityTickList]]:停止 tick 的实体只要还在 [[EntityLookup]] 里且 <code>isAlive()</code> 为真,仍会被 @e 选中。

其他版本