Mmc秒杀圈百科 

LevelEntityGetterAdapter:查看版本 v1

由 朝武芳乃 于 2026-10-04 00:58 保存 · 1681 字节
''本条基于 Minecraft 1.20.1 + Forge,Mojang 映射名。'' '''LevelEntityGetterAdapter'''(<code>net.minecraft.world.level.entity.LevelEntityGetterAdapter</code>)是 <code>LevelEntityGetter</code> 接口的原版实现,是外部代码查询“世界里有哪些实体”的统一入口。 == 与实体储存的关系 == * 本身不存实体,只持有两个引用:<code>visibleEntities</code>([[EntityLookup]])和 <code>sectionStorage</code>(<code>EntitySectionStorage</code>)。 * [[EntityLookup]] 内部是按 ID 的 [[Int2ObjectMap]] 和按 UUID 的 [[Map]],是实体的主表。 * <code>get(int)</code>、<code>get(UUID)</code>、<code>getAll()</code>、按类型遍历 → 走 <code>visibleEntities</code>。 * 按 <code>AABB</code> 范围查询 → 走 <code>sectionStorage</code>(按 16³ 区块段分组)。 * 服务端由 <code>PersistentEntitySectionManager</code> 创建,客户端由 <code>TransientEntitySectionManager</code> 创建,分别通过 [[ServerLevel]] / <code>ClientLevel</code> 的 <code>getEntities()</code> 暴露。 == 所在链路 == * '''/forge entity list''':[[EntityCommand]] → <code>getEntities().getAll()</code> → [[Iterable.forEach]] * '''say @e''':[[EntitySelector]] → <code>ServerLevel.getEntities(EntityTypeTest, ...)</code> → <code>get(EntityTypeTest, consumer)</code> * '''LevelRenderer''':[[LevelRenderer]] → <code>ClientLevel.entitiesForRendering()</code> → <code>getAll()</code> == 备注 == 三条链路都经过它,所以从 [[EntityLookup]] 中移除的实体,在指令、实体列表和渲染中都会“消失”;但它不管 tick,tick 由 [[EntityTickList]] 单独管理。

其他版本