WHERE'S MY BRAIN (WMB)
一款轻量级、与加载器无关的 Minecraft 1.20.1 优化模组,专注于更智能的生物 AI 调度、距离感知的限流以及自适应自动调优。在保持玩家附近游戏体验的同时,减少远处或闲置生物浪费的 CPU 资源。
通过 Architectury 同时支持 Forge 和 Fabric。
Features
-
异步实体追踪 (Async Entity Tracking)
- 将每个玩家的实体可见性/追踪决策移至后台线程执行,以减少主线程的工作量。
- 提供全局或按维度划分的线程池,并具备自适应背压机制(队列感知调度)。
- 尊重
asyncTracker.updateInterval、cacheDuration 和 maxTrackingDistance 配置。
- 与 AutoTuner 集成,以在负载较高时调整调度策略。
- 超时机制和优雅的降级处理确保主线程的安全。
-
区域/区块级 TPS 管理器 (R‑TPS)
- 将每个维度划分为方形区域(默认:
regionalTPS.regionSize = 4 个区块每边),并持续测量各区域的负载。
- 跟踪各区域的指标:平均 AI 时间(毫秒)、平均内存占用(MB)、玩家存在情况、红石更新、方块实体/计划刻数以及活动时效性。
- 使用命名等级(例如
normal=1、warning=2、critical=4)对各区域应用可扩展的刻数乘数。
- 迟滞机制 (
regionalTPS.hysteresisPct,默认 0.15) 防止负载在阈值附近徘徊时出现状态翻转。
- 静态覆盖功能允许将特定区域锁定到某个等级。
- 安全性:全局 TPS 基于滑动窗口计算,紧急触发器受预热和冷却期限制,以避免误报。
- 门控机制整合了区块随机/计划刻,在压力较大的区域减少工作量,同时在玩家附近保持不可见。
-
基于距离的 AI 分桶 (DAB)
- 根据每个生物距离最近玩家的距离动态限制 AI 刻数。
- 支持按维度和按实体的覆盖设置。
- 迟滞死区以防止在阈值附近频繁抖动。
- 合理的豁免规则(拴绳绑定、命名、拥有/驯服、持久化以及可配置的 Boss 豁免)。
-
邻近快照服务 (Proximity Snapshot Service)
- 集中化最近玩家距离的计算至周期性快照,减少冗余工作。
- 将生物侧缓存缩减为 2 个刻,以便以极小的开销进行响应式的 DAB 更新。
-
寻路优化 (Pathfinding Optimizations)
- 每个生物的最小路径重算间隔和分组窗口。
- 可选的实验性路径共享功能。
- 带 TTL 的缓存机制以避免重复求解路径。
-
自动调优 (Auto-Tuning, PID)
- 目标为所需的平均刻时间(毫秒),并温和地调整路径重算间隔。
- PID 控制器(kp/ki/kd),带有积分钳位和步长限制,以实现平滑收敛。
- 如果 PID 增益为零,则透明地回退到简单的步进控制器。
-
可选 AI 剔除 (Conservative Culling)
- 在多重安全门控下,跳过远处、闲置且未互动的生物的 AI 处理。
-
可选可见性剔除 (Conservative Visibility Culling)
- 跳过完全超出任何玩家区块范围的生物的 AI,同样具备相同的安全门控。
-
指标与命令 (Metrics and Command)
- 用于
/wmb stats 的轻量级内部计数器。
- 查看 DAB 阈值、邻近设置、寻路参数和调优器状态。
How It Works
- DAB 持续将每个生物相对于最近玩家放置在距离分桶中(近/中/远/极远),并为每个分桶分配一个刻数乘数。
- 异步实体追踪在后台线程计算每个玩家追踪的实体集,并在刻后应用更新;间隔通过调优器和背压机制自适应调整。
- 邻近服务每隔 N 个刻(可配置)对玩家位置进行快照,以分摊距离查询的成本。
- 寻路和 AI 重算受到速率限制,具有每个生物的最小间隔和可选的分组机制。
- 自动调优器读取窗口内的平均刻时间,并调整
pathfinding.minRecalcInterval,引导服务器向 tuning.targetTickMs 靠拢。
- 剔除和可见性功能添加了可选的保守门控,在安全时跳过 AI 处理。
Diagrams
Async Entity Tracking: Flow
[Server Tick]
├─ PreTick
│ ├─ shouldSchedulePlayer?(interval + tuner + backpressure)
│ ├─ Snapshot(Player)
│ ├─ CollectEntitySnapshots (AABB around player)
│ └─ Submit Task → Executor
│ └─ [Off-thread]
│ ├─ Filter by distance ≤ maxTrackingDistance (2D)
│ ├─ Diff with current tracked set → {toAdd, toRemove}
│ └─ Enqueue TrackingResult
└─ PostTick
├─ Drain completed results (batched)
├─ Apply adds/removes to tracking sets
├─ Update metrics (durations, queue size, counts)
└─ Periodic maintenance (cleanup/disconnects)
Threading Model: Global vs Per-Dimension Pools
Option A: Global Pool
[AsyncTracker Executor (N threads)]
↑ tasks from all dimensions
Option B: Per-Dimension Pools
[Overworld Executor (M)] [Nether Executor (M)] [End Executor (M)]
↑ OW tasks ↑ Nether tasks ↑ End tasks
Backpressure: bounded queues + CallerRunsPolicy; scheduling slows when queues grow.
Auto‑Tuner: Control Loop
tickNanos → EMA → window(avg)
│
▼
Controller (PID or Simple)
│
┌───────┴─────────────────────────────┐
│ │
pathfinding.minRecalcInterval += step trackerIntervalAddend = clamp(-step)
│ │
cooldown ticks prevent rapid toggling additive scheduling shift for tracker
DAB Bucketing and Hysteresis
distance (blocks) → 0 ── d0 ── d1 ── d2 ──▶
bucket NEAR MID FAR DISTANT
multiplier x1 x2 x4 x8 (defaults; configurable)
hysteresisBlocks (±h) creates a deadband around d0/d1/d2 to reduce bucket flipping.
Regional TPS: Decision Pipeline
[服务器刻]
├─ 前置刻 (PreTick)
│ ├─ 全局 TPS 采样 ← 5+ 次采样后趋于稳定;限制在 [0..20] 范围内;紧急检查前需经过预热(≥200 刻)
│ └─ 更新玩家→区块组映射关系
├─ 后置刻 (PostTick,按区块组执行)
│ ├─ 累计 AI 纳秒、方块实体与计划刻、红石更新、内存、玩家数量
│ ├─ 窗口平均值计算 (regionalTPS.windowTicks)
│ ├─ 使用阈值和滞回机制决定目标等级
│ ├─ 平滑调整区块组乘数向目标值靠近(每刻 ±1)
│ └─ 应用门控钩子(例如:区块随机刻/计划刻)
└─ 全局
├─ 若满足以下条件则触发紧急模式:已通过预热 ∧ 采样数≥20 ∧ TPS<15 且处于冷却期
└─ 定期日志记录并淘汰过期区块组
热力图:客户端流程与交互
/wmb heatmap [半径] → 服务器构建以玩家为中心的窗口区域
↓
发送热力图至客户端
↓
HeatmapScreen(按 H 键重新打开上次视图)
↓
交互操作:
- 鼠标滚轮:缩放
- 右键拖拽:平移
- 左键点击标题栏:切换模式(AI 毫秒数、内存 MB、玩家数、优先级)
- 点击 LOD:切换合并视图与分区块组视图
- 悬停:显示提示框(合并数据 + 区块组详情)
- 侧边栏:详细面板(紧急状态、目标乘数、良好/糟糕连续次数等)
- 全局 TPS 显示在标题栏中
安装
- Minecraft:1.20.1
- 加载器:Fabric 或 Forge(Architectury)
- 将模组 jar 文件放入
mods/ 文件夹。
- 启动游戏一次,以生成带有内联注释的
wmb.toml 配置文件。
按加载器划分的配置位置:
- Fabric:
.minecraft/config/wmb.toml
- Forge:
<实例>/config/wmb.toml
命令
按键绑定
配置参考
所有选项均在生成的 wmb.toml 中有内联文档。以下是结构化概览。
基于距离的 AI 分桶(DAB)
-
dab.enabled (bool)
-
dab.d0, dab.d1, dab.d2 (double, blocks)
-
dab.multipliers.near|mid|far|distant (int)
- 每个分桶的 AI 刻间隔。
1 表示每刻执行(无节流),数值越高表示 AI 更新频率越低。
-
dab.hysteresisBlocks (double, blocks)
-
dab.perEntity["namespace:id"]
- 针对实体的覆盖与豁免设置。
- 键:
exempt (bool)、highPriority (bool)、near、mid、far、distant (ints)。
- 如果
exempt 或 highPriority 为 true,则对该实体类型禁用 DAB。
-
dab.perDimension["namespace:dimension"]
- 针对维度的覆盖设置,用于
d0/d1/d2 及嵌套的 multipliers.near|mid|far|distant。
注意:
- 一些高重要性实体(例如 Boss)默认在代码中或通过实体级覆盖被豁免于 DAB。
- 拴绳、命名、拥有/驯服以及持久化实体不受节流限制。
proximity(邻近度)
proximity.updateIntervalTicks (int)
- 玩家位置快照的频率。数值越大 = CPU 占用越低,但 DAB 响应速度越慢。典型值:3–10。
寻路
-
pathfinding.enabled (bool)
-
pathfinding.minRecalcInterval (int, ticks)
- 每个生物重新计算之间的最小刻数。这是由调节器调整的致动器。
-
pathfinding.groupWindowTicks (int, ticks)
- 在小窗口内分组/交错重新计算,以分散 CPU 峰值。
-
pathfinding.cacheTtlTicks (int, ticks)
-
pathfinding.experimentalShareEnabled (bool)
-
pathfinding.shareTtlTicks (int, ticks)
- 如果启用了共享,共享路径条目的 TTL(生存时间)。
自动调节
-
tuning.enabled (bool)
- 启用对
pathfinding.minRecalcInterval 的闭环调节,使其趋向目标刻持续时间。
-
tuning.targetTickMs (double, ms)
- 期望的平均刻持续时间(50.0 ms = 20 TPS)。
-
tuning.windowTicks (int)
-
tuning.cooldownTicks (int)
-
tuning.minRecalcMin / tuning.minRecalcMax (int)
-
tuning.kp, tuning.ki, tuning.kd (double)
- PID 增益。如果全部为零,调谐器将回退到基于简单阶跃的控制器。
-
tuning.maxStepPerWindow (int)
-
tuning.integralMaxAbs (double)
- 积分项的绝对上限,以防止积分饱和(windup)。
检查 (Checks)
checks.suffocationInterval (int, ticks)
- 原版窒息检查的调整参数。数值越高,CPU 占用越低,但检测速度会略微变慢。
异步生成 (Async Spawn)
异步实体追踪器 (Async Entity Tracker)
-
asyncTracker.enabled (bool)
-
asyncTracker.threadPoolSize (int)
- 当
perDimensionPools = false 时,全局追踪器执行器使用的线程数。
-
asyncTracker.updateInterval (int, ticks)
-
asyncTracker.cacheDuration (int, ticks)
- 在强制重新计算之前,重用上次可见性结果的时间长度。
-
asyncTracker.perDimensionPools (bool)
- 如果为 true,则按维度使用独立的执行器以隔离负载。
-
asyncTracker.threadPoolSizePerDim (int)
- 当
perDimensionPools = true 时,每个按维度划分的执行器的核心线程数。
-
asyncTracker.maxTrackingDistance (double, blocks)
剔除 (Culling)(可选)
-
culling.enabled (bool)
- 对远处且闲置的生物实施保守的 AI 跳过策略,并设有多个安全门控条件。
-
culling.minDistance (double, blocks)
-
culling.requireNoTarget / requireNoPath / requireLowMotion (bool)
- 确保我们仅在生物处于闲置、未参与状态时才跳过 AI 的安全门控条件。
-
culling.lowMotionSpeed (double, blocks/tick)
-
culling.allowEveryNTicks (int, ticks)
- 即使符合条件,也允许每 N 刻进行一次完整 AI 计算,以避免饥饿现象。
-
culling.exemptNamed|Leashed|Owned|Persistent (bool)
可见性 (Visibility)(可选)
-
visibility.enabled (bool)
- 将类似的跳过规则应用于位于任何玩家区块范围之外的远处生物。
-
visibility.playerChunkRange (int, chunks)
- 围绕玩家被视为“活跃”状态的切比雪夫区块距离。超出此范围的生物可能会在满足门控条件时被跳过。
-
visibility.requireNoTarget / requireNoPath / requireLowMotion (bool)
-
visibility.lowMotionSpeed (double, blocks/tick)
-
visibility.allowEveryNTicks (int, ticks)
- 即使符合条件,也允许每 N 刻进行一次完整 AI 计算,以避免饥饿现象。
-
visibility.exemptNamed|Leashed|Owned|Persistent (bool)
区域 TPS (Regional TPS)
-
regionalTPS.enabled (bool)
-
regionalTPS.regionSize (int, chunks)
-
regionalTPS.windowTicks (int, ticks)
-
regionalTPS.thresholds.maxTickMs (double, ms)
-
regionalTPS.thresholds.maxEntities (int)
-
regionalTPS.thresholds.maxBlockEntities (int)
-
regionalTPS.hysteresisPct (double, 0.0–0.45)
- 应用于阈值周围的百分比死区,以防止等级频繁翻转。默认值:0.15 (15%)。
-
regionalTPS.scaling.levels.<name> (int)
- 命名等级到刻乘数的映射,例如
normal=1、warning=2、critical=4。
-
regionalTPS.staticRegions["dim:rx,rz"] = "levelName"
- 将特定区域(通过维度和区域坐标指定)固定到所选等级。
配置版本控制与自动合并
- 配置文件包含
configVersion。截至 v1.2‑SNAPSHOT,架构版本为 5。
- 加载时,WMB 会自动合并任何缺失的键并使用安全默认值,同时将
configVersion 向前递增。
- 现有用户值将被保留。键不会自动删除。
- 生成的
wmb.toml 为每个选项包含内联注释。
调整指南
- 从
tuning.enabled = false 开始。通过 /wmb stats 观察基线情况。
- 根据你的硬件和整合包设置一个合理的
tuning.targetTickMs。50.0 ms 对应 20 TPS;目标值应略低于你的典型平均负载。
- 从简单的控制器开始:
kp > 0,ki = 0,kd = 0。建议值:kp = 0.25。
- 如果你看到稳态误差,请轻轻引入
ki(例如 0.01–0.05)。
- 如果出现超调或振荡,请添加
kd(例如 0.05–0.2)。
- 保持
maxStepPerWindow 较小(1–2)以确保平滑性。通过 integralMaxAbs 限制积分项。
- 始终使用
minRecalcMin/minRecalcMax 对执行器进行边界限制。
- 追踪器集成:调节器也会以累加方式调整追踪器调度;保持
asyncTracker.updateInterval 适中,让调节器平滑负载。
兼容性
- 旨在对游戏关键 AI 保持保守和安全。
- Boss、命名生物、拴绳生物、拥有/驯服生物以及持久化生物默认受到保护。
- 应具有广泛的兼容性;实验性功能(如路径共享)为可选启用。
常见问题 (FAQ)
更新日志
1.2 (2025-09-04)
许可证
请参阅仓库中的 LICENSE.txt 文件。
WHERE'S MY BRAIN (WMB)
A lightweight, loader-agnostic Minecraft 1.20.1 optimization mod focused on smarter mob AI scheduling, distance-aware throttling, and adaptive auto-tuning. Keep gameplay feel near players while cutting wasted CPU on far-away or idle mobs.
Works on both Forge and Fabric via Architectury.
Features
-
Async Entity Tracking
- Off-thread per-player entity visibility/tracking decisions to reduce main thread work.
- Global or per-dimension thread pools with adaptive backpressure (queue-aware scheduling).
- Respects
asyncTracker.updateInterval, cacheDuration, and maxTrackingDistance.
- Integrates with AutoTuner to adjust scheduling under load.
- Timeouts and graceful fallbacks keep the main thread safe.
-
Regional/Chunk-based TPS Manager (R‑TPS)
- Divides each dimension into square regions (default:
regionalTPS.regionSize = 4 chunks per side) and continuously measures load per region.
- Tracks per-region metrics: average AI time (ms), average memory (MB), player presence, redstone updates, BE/scheduled tick counts, and activity recency.
- Applies scalable tick multipliers per region using named levels (e.g.,
normal=1, warning=2, critical=4).
- Hysteresis (
regionalTPS.hysteresisPct, default 0.15) prevents flip‑flops when load hovers near thresholds.
- Static overrides let you pin specific regions to a level.
- Safety: global TPS is computed over a sliding window and emergency triggers are gated by warm‑up and cooldown to avoid false alarms.
- Gating integrates with chunk random/scheduled ticks to cut work in stressed regions while remaining invisible near players.
-
Distance-based AI Bucketing (DAB)
- Dynamically throttles AI ticks based on each mob’s nearest-player distance.
- Per-dimension and per-entity overrides.
- Hysteresis deadband to prevent thrashing near thresholds.
- Sensible exemptions (leashed, named, owned/tamed, persistent, and configurable boss exemptions).
-
Proximity Snapshot Service
- Centralizes nearest-player computations to a periodic snapshot, reducing redundant work.
- Mob-side cache reduced to 2 ticks for responsive DAB updates with minimal overhead.
-
Pathfinding Optimizations
- Minimum per-mob path recalculation interval and grouping window.
- Optional experimental path sharing.
- Caching with TTL to avoid repeated path solves.
-
Auto-Tuning (PID)
- Targets a desired average tick time (ms) and gently adjusts pathfinding recalc interval.
- PID controller (kp/ki/kd) with integral clamping and step-limits for smooth convergence.
- Transparently falls back to a simple step controller if PID gains are zero.
-
Optional AI Culling (Conservative)
- Skip AI processing for far, idle, and unengaged mobs behind multiple safety gates.
-
Optional Visibility Culling (Conservative)
- Skip AI for mobs far outside any player’s chunk range, with the same safety gates.
-
Metrics and Command
- Lightweight internal counters for
/wmb stats.
- See DAB thresholds, proximity settings, pathfinding parameters, and tuner state.
How It Works
- DAB continuously places each mob into a distance bucket (near/mid/far/distant) relative to the nearest player and assigns a tick interval multiplier per bucket.
- Async Entity Tracking computes per-player tracked entity sets off-thread and applies updates post-tick; intervals adapt via tuner and backpressure.
- The proximity service snapshots player positions every N ticks (configurable) to amortize distance queries.
- Pathfinding and AI recalculations are rate-limited with per-mob minimum intervals and optional grouping.
- The Auto Tuner reads average tick time over a window and adjusts
pathfinding.minRecalcInterval to steer the server towards tuning.targetTickMs.
- Culling and visibility features add optional, conservative gates to skip AI when it’s safe to do so.
Diagrams
Async Entity Tracking: Flow
[Server Tick]
├─ PreTick
│ ├─ shouldSchedulePlayer?(interval + tuner + backpressure)
│ ├─ Snapshot(Player)
│ ├─ CollectEntitySnapshots (AABB around player)
│ └─ Submit Task → Executor
│ └─ [Off-thread]
│ ├─ Filter by distance ≤ maxTrackingDistance (2D)
│ ├─ Diff with current tracked set → {toAdd, toRemove}
│ └─ Enqueue TrackingResult
└─ PostTick
├─ Drain completed results (batched)
├─ Apply adds/removes to tracking sets
├─ Update metrics (durations, queue size, counts)
└─ Periodic maintenance (cleanup/disconnects)
Threading Model: Global vs Per-Dimension Pools
Option A: Global Pool
[AsyncTracker Executor (N threads)]
↑ tasks from all dimensions
Option B: Per-Dimension Pools
[Overworld Executor (M)] [Nether Executor (M)] [End Executor (M)]
↑ OW tasks ↑ Nether tasks ↑ End tasks
Backpressure: bounded queues + CallerRunsPolicy; scheduling slows when queues grow.
Auto‑Tuner: Control Loop
tickNanos → EMA → window(avg)
│
▼
Controller (PID or Simple)
│
┌───────┴─────────────────────────────┐
│ │
pathfinding.minRecalcInterval += step trackerIntervalAddend = clamp(-step)
│ │
cooldown ticks prevent rapid toggling additive scheduling shift for tracker
DAB Bucketing and Hysteresis
distance (blocks) → 0 ── d0 ── d1 ── d2 ──▶
bucket NEAR MID FAR DISTANT
multiplier x1 x2 x4 x8 (defaults; configurable)
hysteresisBlocks (±h) creates a deadband around d0/d1/d2 to reduce bucket flipping.
Regional TPS: Decision Pipeline
[Server Tick]
├─ PreTick
│ ├─ Global TPS sample ← steady after 5+ samples; clamped [0..20]; warm‑up (≥200 ticks) before emergency checks
│ └─ Update player→region mapping
├─ PostTick (per region)
│ ├─ Accumulate AI nanos, BE & scheduled ticks, redstone updates, memory, players
│ ├─ Windowed averages (regionalTPS.windowTicks)
│ ├─ Decide target level using thresholds + hysteresis
│ ├─ Smoothly adjust region multiplier toward target (±1 per tick)
│ └─ Apply gating hooks (e.g., chunk random/scheduled ticks)
└─ Global
├─ Emergency trigger if: warm‑up passed ∧ samples≥20 ∧ TPS<15 with cooldown
└─ Periodic logging & eviction of stale regions
Heatmap: Client Flow & Interactions
/wmb heatmap [radius] → server builds window around player
↓
send Heatmap to client
↓
HeatmapScreen (press H to reopen last)
↓
Interactions:
- Mouse wheel: zoom
- Right‑drag: pan
- Left‑click on header: toggle Mode (AI ms, Mem MB, Players, Priority)
- Click LOD: toggle merged vs per‑region view
- Hover: tooltips (merged + region details)
- Sidebar: detailed panel (emergency, target multiplier, good/bad streaks, etc.)
- Global TPS shown in header
Installation
- Minecraft: 1.20.1
- Loaders: Fabric or Forge (Architectury)
- Drop the mod jar into your
mods/ folder.
- Start the game once to generate the
wmb.toml config with inline comments.
Config location by loader:
- Fabric:
.minecraft/config/wmb.toml
- Forge:
<instance>/config/wmb.toml
Commands
Keybinds
Configuration Reference
All options are documented inline in the generated wmb.toml. Below is a structured overview.
Distance-based AI Bucketing (DAB)
-
dab.enabled (bool)
- Turn distance-aware AI throttling on/off globally.
-
dab.d0, dab.d1, dab.d2 (double, blocks)
- Distance thresholds separating near/mid/far/distant buckets.
-
dab.multipliers.near|mid|far|distant (int)
- AI tick interval per bucket.
1 means every tick (no throttle), higher means less frequent AI updates.
-
dab.hysteresisBlocks (double, blocks)
- Deadband around the thresholds to avoid rapid bucket flipping near the boundary.
-
dab.perEntity["namespace:id"]
- Per-entity overrides and exemptions.
- Keys:
exempt (bool), highPriority (bool), near, mid, far, distant (ints).
- If
exempt or highPriority is true, DAB is disabled for that entity type.
-
dab.perDimension["namespace:dimension"]
- Per-dimension overrides for
d0/d1/d2 and nested multipliers.near|mid|far|distant.
Notes:
- Some high-importance entities (e.g., bosses) can be exempted from DAB by default in code or via per-entity overrides.
- Leashed, named, owned/tamed, and persistent entities are not throttled.
Proximity
proximity.updateIntervalTicks (int)
- How often player positions are snapshotted. Larger = less CPU, slower DAB responsiveness. Typical: 3–10.
Pathfinding
-
pathfinding.enabled (bool)
- Enable optimizations around path recalculations and caching.
-
pathfinding.minRecalcInterval (int, ticks)
- Minimum ticks between recalculations per mob. This is the actuator adjusted by the tuner.
-
pathfinding.groupWindowTicks (int, ticks)
- Group/stagger recalcs within a small window to spread CPU spikes.
-
pathfinding.cacheTtlTicks (int, ticks)
- Keep solved paths for this long before expiring.
-
pathfinding.experimentalShareEnabled (bool)
- Experimental: allow similar mobs to share path results.
-
pathfinding.shareTtlTicks (int, ticks)
- TTL for shared path entries if sharing is enabled.
Auto Tuning
-
tuning.enabled (bool)
- Enable closed-loop tuning of
pathfinding.minRecalcInterval towards a target tick duration.
-
tuning.targetTickMs (double, ms)
- Desired average tick duration (50.0 ms = 20 TPS).
-
tuning.windowTicks (int)
- Number of ticks per averaging window.
-
tuning.cooldownTicks (int)
- Minimum ticks between successive adjustments.
-
tuning.minRecalcMin / tuning.minRecalcMax (int)
- Clamp the actuator (min recalc interval) within this range.
-
tuning.kp, tuning.ki, tuning.kd (double)
- PID gains. If all are zero, the tuner falls back to a simple, step-based controller.
-
tuning.maxStepPerWindow (int)
- Maximum absolute change to the actuator per window.
-
tuning.integralMaxAbs (double)
- Absolute clamp for integral term to avoid windup.
Checks
checks.suffocationInterval (int, ticks)
- Tuning of vanilla suffocation checks. Higher = less CPU, slightly slower detection.
Async Spawn
Async Entity Tracker
-
asyncTracker.enabled (bool)
- Enable asynchronous per-player entity tracking.
-
asyncTracker.threadPoolSize (int)
- Worker threads for the global tracker executor when
perDimensionPools = false.
-
asyncTracker.updateInterval (int, ticks)
- Minimum ticks between recalculations per player before cache reuse.
-
asyncTracker.cacheDuration (int, ticks)
- How long to reuse the last visibility result before forcing a recalculation.
-
asyncTracker.perDimensionPools (bool)
- If true, use one executor per dimension to isolate load.
-
asyncTracker.threadPoolSizePerDim (int)
- Core threads for each per-dimension executor when
perDimensionPools = true.
-
asyncTracker.maxTrackingDistance (double, blocks)
- Maximum 2D horizontal distance from the player for an entity to be considered tracked.
Culling (Optional)
-
culling.enabled (bool)
- Conservative AI skipping for far, idle mobs with multiple safety gates.
-
culling.minDistance (double, blocks)
- Only consider mobs at least this far from the nearest player.
-
culling.requireNoTarget / requireNoPath / requireLowMotion (bool)
- Safety gates to ensure we skip AI only for idle, unengaged mobs.
-
culling.lowMotionSpeed (double, blocks/tick)
- Threshold used by
requireLowMotion.
-
culling.allowEveryNTicks (int, ticks)
- Even when eligible, allow full AI every N ticks to avoid starvation.
-
culling.exemptNamed|Leashed|Owned|Persistent (bool)
- Protective exemptions to never skip important mobs.
Visibility (Optional)
-
visibility.enabled (bool)
- Apply similar skipping rules to mobs far outside any player’s chunk range.
-
visibility.playerChunkRange (int, chunks)
- Chebyshev chunk distance around players considered "active". Outside this range, mobs may be skipped subject to gates.
-
visibility.requireNoTarget / requireNoPath / requireLowMotion (bool)
- Same safety gates as culling.
-
visibility.lowMotionSpeed (double, blocks/tick)
- Threshold used by
requireLowMotion.
-
visibility.allowEveryNTicks (int, ticks)
- Even when eligible, allow full AI every N ticks to avoid starvation.
-
visibility.exemptNamed|Leashed|Owned|Persistent (bool)
- Protective exemptions to never skip important mobs.
Regional TPS
-
regionalTPS.enabled (bool)
- Master switch for the chunk‑based TPS system.
-
regionalTPS.regionSize (int, chunks)
- Side length of a square region in chunks. Default: 4.
-
regionalTPS.windowTicks (int, ticks)
- Averaging window for per‑region metrics and decisions.
-
regionalTPS.thresholds.maxTickMs (double, ms)
- Soft ceiling for average AI time in a region before increasing level.
-
regionalTPS.thresholds.maxEntities (int)
- Heuristic cap for entity counts within the region window.
-
regionalTPS.thresholds.maxBlockEntities (int)
- Heuristic cap for block entities within the region window.
-
regionalTPS.hysteresisPct (double, 0.0–0.45)
- Percentage deadband applied around thresholds to prevent rapid level flip‑flopping. Default: 0.15 (15%).
-
regionalTPS.scaling.levels.<name> (int)
- Map of named levels to tick multipliers, e.g.,
normal=1, warning=2, critical=4.
-
regionalTPS.staticRegions["dim:rx,rz"] = "levelName"
- Pin specific regions (by dimension and region coords) to a chosen level.
Config Versioning and Auto‑Merge
- The config file includes
configVersion. As of v1.2‑SNAPSHOT, the schema version is 5.
- On load, WMB auto‑merges any missing keys with safe defaults and bumps
configVersion forward.
- Existing user values are preserved. Keys are not removed automatically.
- The generated
wmb.toml includes inline comments for every option.
Tuning Guide
- Start with
tuning.enabled = false. Observe baseline with /wmb stats.
- Set a realistic
tuning.targetTickMs for your hardware and modpack. 50.0 ms is 20 TPS; aim slightly below your typical average load.
- Begin with a simple controller:
kp > 0, ki = 0, kd = 0. Suggested: kp = 0.25.
- If you see steady-state error, gently introduce
ki (e.g., 0.01–0.05).
- If you overshoot or oscillate, add
kd (e.g., 0.05–0.2).
- Keep
maxStepPerWindow small (1–2) for smoothness. Clamp integral via integralMaxAbs.
- Always bound the actuator with
minRecalcMin/minRecalcMax.
- Tracker integration: the tuner also adjusts tracker scheduling additively; leave
asyncTracker.updateInterval moderate and let the tuner smooth load.
Compatibility
- Designed to be conservative and safe around gameplay-critical AI.
- Bosses, named, leashed, owned/tamed, and persistent mobs are protected by default.
- Should be broadly compatible; experimental features (like path sharing) are opt-in.
FAQ
-
Does DAB change combat behavior near the player?
- No. The
near bucket usually uses a multiplier of 1, keeping AI behavior responsive up close.
-
Does async tracking cause entity pop‑in or desync?
- No. Tracking sets are computed off‑thread but applied safely on the main thread each tick. Timeouts fall back gracefully.
-
What if my server has multiple heavy dimensions?
- Enable
asyncTracker.perDimensionPools to isolate tracker load by dimension and size threadPoolSizePerDim accordingly.
-
Will auto-tuning fight my manual settings?
- The tuner only adjusts
pathfinding.minRecalcInterval. Everything else remains exactly as configured.
-
What if I don’t want any culling?
- Both culling systems are disabled by default. They’re strictly opt-in and conservative.
-
Is this a magic TPS booster?
- No. It’s a set of intelligent trade-offs to save CPU in situations where it doesn’t affect gameplay feel.
Changelog
1.2 (2025-09-04)
-
New — Regional/Chunk-based TPS Manager (R‑TPS)
- Per‑region load tracking (avg AI ms, memory MB, players, redstone updates, BE/scheduled ticks, activity).
- Named scaling levels (e.g., normal=1, warning=2, critical=4) applied as tick multipliers per region.
- Hysteresis via
regionalTPS.hysteresisPct (default 0.15) to stabilize level transitions.
- Static region overrides to pin hotspots to specific levels.
- Integrates with chunk random/scheduled tick gating; invisible near players.
-
New — Heatmap UI for Regional TPS
- Request with
/wmb heatmap [radius]; reopen last heatmap with the H key.
- Mouse wheel zoom; right‑click drag to pan; live window requests while panning/zooming.
- Modes: AI ms, Mem MB, Players, Priority; LOD toggle (merged vs per‑region tiles).
- Tooltips and a detailed side panel (emergency state, target multiplier, consecutive good/bad ticks, histories).
- Global TPS display in the header.
-
Improvements — Global TPS measurement and safety
- Lazy‑init tick timing; compute TPS only after 5+ samples; clamp to [0..20].
- Gate emergency triggers until warm‑up (≥200 ticks) and require ≥20 samples; add cooldown to avoid log spam.
-
Improvements — Regional decisions and sampling
- Applied hysteresis to regional scaling decisions; introduced
levelIndex to track transitions.
- Normalized Y sampling for region gating to
level.getMinBuildHeight() + 1.
-
Networking & Client
- Updated heatmap/detail serialization to include memory, player counts, priority, global TPS, target multiplier, and histories.
- Client can refresh the existing screen (
setHeatmap) without reopening; remembers last heatmap for the H key.
-
Fixes
- Heatmap tooltip compile error fixed by initializing local variables.
- Eliminated false global TPS emergencies at startup or sporadic spikes; reduced warning spam.
-
Config
- Config schema bumped to 5; added
regionalTPS.* keys including hysteresisPct.
- Defaults and inline comments updated in
wmb.toml.
-
Migration Notes
- Existing configs auto‑merge new keys and bump
configVersion safely. Review regionalTPS.thresholds and regionalTPS.scaling.levels for your pack.
License
See LICENSE.txt in the repository.
评论 0
登录后参与评分
还没有评论,来抢沙发吧