Twilight Wraith(幽灵)

事实基准:/Users/evlos/a/mirror/twilightforest(minecraftVersion = 1.7.10)逐行读源码。

基本信息

属性 值 来源
注册实体名 TwilightForest:Twilight Wraith TwilightForestMod.java:487
英文显示名 Twilight Wraith(entity.TwilightForest.Twilight Wraith.name) assets/twilightforest/lang/en_US.lang:574
实体 ID 常量 idMobTwilightWraith = 186 TwilightForestMod.java:1090(声明在 :126)
蛋色 主 0x505050 / 副 0x838383 TwilightForestMod.java:489-490
注册形式 TFCreatures.registerTFCreature → 追踪 80 / 更新 3 entity/TFCreatures.java:23
类 twilightforest.entity.EntityTFWraith(282 行) entity/EntityTFWraith.java:21
父类 net.minecraft.entity.EntityFlying(implements IMob) 同上 :21
体型 本类未覆写 setSize,沿用 EntityFlying 链上的父类默认 —
所属结构 大型空心丘陵(TFFeature.hill3,特性 ID 3、size 3,显示名 “Large Hollow Hill”),权重 2、1~4 只 TFFeature.java:155

🚨 本条目既不属于冰霜高塔,也不属于任何高塔。 幽灵挂在大型空心丘陵的 刷怪表里,是一只丘陵洞穴怪。类名里没有 Tower,本条目被并入本批 是因为同属「此前无独立条目的塔系/塔周边小怪」这一补写批次。 本类不在任何群系刷怪表中。

数值

属性 值 来源
maxHealth 20.0 EntityTFWraith.java:38
movementSpeed 0.5 同上 :39
attackDamage 5.0 同上 :43
攻击距离 2.0 格(近身接触) 同上 :147
攻击间隔 attackTime 20 tick 同上 :150
索敌半径 findPlayerToAttack 16 格,且需 canEntityBeSeen 同上 :187-188
仇恨重扫间隔 aggroCooldown 20 tick 同上 :102-106
追击跟踪距离 64 格 同上 :115-116
游荡幅度 x/y/z 各 ±16 同上 :80-82
航点重选冷却 += rand.nextInt(5) + 2 同上 :85
蓄力时长 attackCounter 到 20 时把航点设为玩家脚下,随后置 -40 同上 :128-133
掉落 getDropItem Items.glowstone_dust 同上 :225-227
experienceValue 源码中未设置(全文检索无命中),沿用 EntityFlying → EntityLivingBase 链上的父类默认 —
存活 / 受伤 / 死亡音 全部为 twilightforest:mob.wraith.wraith(同一音效) 同上 :210-222

AI 行为 / 特殊机制

没有 GoalSet,只有一个手写状态机(updateEntityActionState,:69-144, 方法注释直言 TODO: pathfinding!)——本类不是 EntityMob,没有任务表。

attackDamage 需要手动注册(:41-43):因为继承链是 EntityFlying(非 EntityLivingBase),applyEntityAttributes 里显式 getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage), 源码注释写明「因为我们不是 EntityMob 所以要初始化伤害」。

纯接触近战,没有远程攻击:这是它与 Tower Ghast 最大的区别。 attackEntity(:146-156)要求距离 < 2.0 格且双方包围盒在 y 轴有重叠才造成 attackDamage 伤害。而 attackCounter 归 20 时的动作不是发射投射物, 只是把航点搬到玩家脚下好冲过去(:128-133)。

撞墙就打不到:attackBlockedEntity(targetedEntity, f) 方法体是空的 (:158)——玩家躲在墙后时 canEntityBeSeen 失败,本类不会造成任何伤害。 源码上方注释自称「改编自 ghast 代码」,但省掉了投射物部分。

飞行不寻路:无目标时按 ±16 格随机航点漂移(:80-82), 每 2~6 tick 检查一次航点路径是否无碰撞(isCourseTraversable,:195-207); 路径不通就把航点重置到自身位置并清空目标(:90-97)。

隐身度:非暮色森林维度或未被实体直接伤害时不会被索敌; attackEntityFrom 覆写为「谁打我就锁定谁」(:165-179),但自己打自己除外 (entity != this 判断,:172)。

刷新光照条件(isValidLightLevel,:256-274): 天空光值 > rand.nextInt(32) 则拒绝刷新;方块光值需 ≤ rand.nextInt(8)。 雷暴期间临时把 worldObj.skylightSubtracted 改成 10 再重算方块光值, 让蠹虫在雷雨天更容易刷出(:266-271)。

成就(onDeath,:239-253):暮色森林维度内被玩家击杀触发 twilightHunter; 若死亡点最近特性是 TFFeature.hill3,额外触发 twilightHill3(本类是该成就的主要来源)。

变形:ItemTFTransformPowder 中与原版 EntityBlaze(烈焰人)双向变形 (ItemTFTransformPowder.java:68)。

死代码:

  • onLivingUpdate(:48-52)里的整段「白天在阳光下燃烧」逻辑被注释,方法实际只剩 super.onLivingUpdate();
  • :123-126 蓄力音效 mob.ghast.charge 被注释;
  • :118-119 计算玩家眼睛高度的 d6 被注释(rotationPitch 恒为 0 的原因在 :139)。

相关条目