路点信标渲染

基本信息

属性 值
事件处理器 journeymap.client.forge.event.WaypointBeaconHandler(WaypointBeaconHandler.java:27)
渲染实现 journeymap.client.render.ingame.RenderWaypointBeacon(RenderWaypointBeacon.java:35)
事件 RenderWorldLastEvent(WaypointBeaconHandler.java:43)
事件总线 MinecraftForgeBus(:36-39)
光柱贴图 textures/entity/beacon_beam.png(RenderWaypointBeacon.java:36,复用原版末地传送门信标贴图)
控制配置 WaypointProperties 的 12 项(见 路点选项)

功能

"信标"是路点在三维世界中的可视化:把路点位置渲染成一根从地面射向天空的光柱,远处也能看到,从而替代 F3 坐标来导航。与二维地图上的路点图标不同,信标参与深度测试,会被地形遮挡。

触发链

RenderWorldLastEvent
  → WaypointBeaconHandler.onRenderWorldLastEvent()      WaypointBeaconHandler.java:43
      条件:mc.thePlayer != null                        :45
           && waypointProperties.beaconEnabled          :45
           && !mc.gameSettings.hideGUI (F1)             :47
  → mc.mcProfiler.startSection("journeymap")            :49
  → mc.mcProfiler.startSection("beacons")               :50
  → RenderWaypointBeacon.renderAll(partialTicks)        :51
  → 双层 endSection                                    :52-53

Profiler 用两层嵌套段(journeymap → beacons),在 F3 性能图中会显示为两级。beaconEnabled 是总开关,关闭时整段逻辑被跳过。

按 F1(hideGUI)也会跳过渲染——与常规 HUD 行为一致。

逐路点筛选

RenderWaypointBeacon.renderAll(float partialTicks)(:59-):

  1. 取 JourneymapClient.getWaypointProperties()(:64)
  2. 从 WaypointStore.instance().getAll() 取全部路点(:66)
  3. 取玩家所在维度 mc.thePlayer.dimension(:68)
  4. 对每个路点判断 wp.isEnable() && wp.getDimensions().contains(playerDim)(:71)——只有当前维度存在对应路点时才渲染

单个路点渲染失败(doRender 抛异常)只记 error 并继续下一个(:73-78);整体异常由外层 catch (Throwable) 兜住(:80-84),保证信标渲染永不影响游戏。

距离淡出

RenderWaypointBeacon 实现了基于距离的 alpha 淡出(:125-130):

配置项 字段 默认
淡出起始距离 beaconFadeStart 40
完全淡出距离 beaconFadeEnd 5
最大显示距离 maxDistance 0(不限)

getFadeAlpha(distance, fadeStart, fadeEnd)(:457-)的分段逻辑:

条件 返回
fadeStart <= fadeEnd 或 fadeStart <= 0 不淡出(视为关闭淡出)
distance <= fadeEnd 0(完全透明)
distance >= fadeStart 1(完全不透明)
介于两者之间 线性插值 (distance - fadeEnd) / (fadeStart - fadeEnd)

因为默认 fadeStart(40) > fadeEnd(5),效果是越近越透明(近处已在身边,不需要光柱;40 格外完全显现)。

fadeAlpha <= MIN_VISIBLE_ALPHA(0.01F,:46)时直接跳过该路点(:130)。maxDistance > 0 && actualDistance > maxDistance 时同样跳过(:135-136)。

分层 alpha

光柱的不同组成部分按不同基准透明度叠加(:212-214),再乘以 fadeAlpha:

组成部分 基准 alpha 源码
深度阴影(depthShadowAlpha) 150 :212
正面阴影(frontShadowAlpha) 100 :213
文字标签(textAlpha) 255 :214

三者都过 clampAlpha(Math.round(...)) 夹取到 0–255。静态光柱与旋转光柱由 showStaticBeam / showRotatingBeam 分别控制(:162)。

距离标签的格式串为 Constants.getString("jm.waypoint.distance_meters", "%1.0f")(:44)——一个 %1.0f 占位符,即距离以整数米显示。

数值

数值名 值
@SubscribeEvent 数 1
Profiler 嵌套层数 2(journeymap → beacons)
淡出阈值 MIN_VISIBLE_ALPHA = 0.01F
淡出区间默认值 40 → 5 方块(近处透明)
淡出插值方式 线性
阴影/文字基准 alpha 150 / 100 / 255
最大显示距离默认值 0(不限制),非 0 时上限 10000
距离标签格式 %1.0f(整数米)
光柱贴图 复用 textures/entity/beacon_beam.png
渲染跳过条件 玩家为 null、信标关闭、按 F1

交互

触发 行为
每帧世界渲染末 遍历 WaypointStore 全部路点,渲染当前维度中已启用的那些
按 F1 隐藏 GUI 信标一并隐藏
调整 beaconFadeStart / beaconFadeEnd 立即影响淡出曲线(配置为 AtomicInteger 热更新)
调整 maxDistance 超距离路点直接不渲染
删除路点 WaypointStore.remove() 后不再出现在 getAll()
切换维度 只渲染该维度内的路点

死代码

RenderWaypointBeacon 中两个 StatTimer 性能计时的声明与全部调用全部被注释掉:

  • 字段注释:// static StatTimer timer = StatTimer.get("WaypointBeacon.doRender", 100); 与 allTimer(:37-38)
  • resetStatTimers() 方法体为空(:48-52),两个 reset() 调用均被注释
  • renderAll() 中的 //allTimer.start() / //allTimer.cancel() / //allTimer.stop()(:67、:82、:86)

该方法保留但无任何调用方,属死代码。

相关条目