Create 碰撞崩溃修复
针对 Minecraft 1.21.1 (NeoForge) 上 Create 6.0.10 中导致服务器致命崩溃的一个微小、单 Mixin 的热修复补丁。
问题描述
移动的 Create 装置可能导致服务器 Tick 循环硬崩溃:
java.lang.NullPointerException: Cannot read field "x" because "mf.axis" is null
at com.simibubi.create.foundation.collision.ContinuousOBBCollider.collideMany(ContinuousOBBCollider.java:153)
at com.simibubi.create.content.contraptions.ContraptionCollider.collideEntities(ContraptionCollider.java:166)
at com.simibubi.create.content.contraptions.ContraptionHandler.tick(ContraptionHandler.java:54)
Description: Exception in server tick loop
一旦发生,世界通常在加载时进入崩溃循环,因为该故障装置在每个 Tick 都会触发相同的崩溃。
触发条件: 移动装置的碰撞检测遇到了一个退化的零距离情况——实体的包围盒中心在每一个轴上都与装置方块的中心完全重合。最常见的实际触发场景是绳索滑轮 + 钻探矿场(例如,滑轮位于中心列的钻头阵列),但旋转轴承、带有锯木机的树木农场以及类似设置也可能触发此问题。
这是上游 Create 的 Bug,仅存在于 6.0.10 版本中(6.0.9 不受影响)。官方修复为 Create PR #10301,已标记至 6.0.11 版本,但该版本尚未发布。对于大多数整合包而言,降级到 6.0.9 并不可行,因为许多 Create 插件要求 create >= 6.0.10。
相关上游报告
- Issue #10218 (追踪) —
- Issue #10278 — 当实体 AABB 中心与装置方块中心重合时,
mf.axis 为空 —
- Issue #10344 —
- Issue #10353 —
- Issue #10378 — 装置碰撞 NPE 边缘情况 —
- Issue #10479 — 树木农场加载时导致服务器崩溃 —
- 上游修复:PR #10301 —
修复方案 — 变更内容与原理
在 Create 的 ContinuousSeparationManifold#separate 方法内部,分离轴 (axis 和 normalAxis) 仅在测试距离非零时被记录:
if (distance != 0.0 && -diff <= Math.abs(this.separation)) {
this.axis = axis; // 在退化、中心重合的情况下永远不会执行
this.separation = separation;
}
在完全重叠且中心重合的情况下,每次分离测试都以 distance == 0 运行,因此 axis / normalAxis 保持为 null。随后 collideMany 尝试解引用它们 (mf.axis.x),导致服务器崩溃。
本模组使用空值检查包裹了 collideMany 中的两个字段读取操作(使用 MixinExtras @WrapOperation)。当记录的轴为空时,它返回 Vec3.ZERO,从而使这次退化碰撞在该 Tick 内贡献零推力而不是崩溃。下一个 Tick 实体发生了亚体素位移,存在有效的分离轴,碰撞将正常解决——不会出现实体卡住或穿模。
@WrapOperation(
method = "collideMany",
at = @At(value = "FIELD",
target = "L.../ContinuousOBBCollider$ContinuousSeparationManifold;axis:Lnet/minecraft/world/phys/Vec3;",
opcode = Opcodes.GETFIELD),
remap = false)
private static Vec3 guardAxis(@Coerce Object manifold, Operation<Vec3> original) {
Vec3 value = original.call(manifold);
return value == null ? Vec3.ZERO : value; // normalAxis 同理
}
为什么专门使用 Vec3.ZERO,以及为何它是安全的:
- 当
axis 为 null 时,配对的 separation 标量值为 Double.MAX_VALUE。如果使用非零的备用轴,会计算 axis * MAX_VALUE 并将实体抛向无穷远。而 0 * MAX_VALUE == 0 可以干净地抵消这种影响——不会产生 NaN,也不会导致瞬移。
axis 和 normalAxis 是 collideMany 中唯一可能为空的 Vec3 读取操作(stepSeparationAxis 是 final 且非空;collision* 字段是原始类型 double),因此这覆盖了该方法中所有的空指针解引用点。
- 该检查仅在空值/退化路径下激活。所有正常碰撞的字节级表现保持不变。
此修复旨在镜像上游 PR #10301 的意图;它被刻意设计得极具针对性,以确保不会影响非退化的物理效果。
兼容性
- Minecraft 1.21.1 · NeoForge 21.1.x
- 仅限 Create 6.0.10。 本模组硬绑定到
create [6.0.10]。在任何其他 Create 版本上,它将拒绝加载并显示清晰的 requires create [6.0.10] 消息——这是在提醒你,一旦 Create 6.0.11(包含官方修复)发布,请移除本模组。
- 需在客户端和服务器端都安装(版本必须匹配)。
- 不混入任何插件类的 Mixin —— 它仅保护 Create 核心内部的两个字段读取操作,因此可与对
ContraptionCollider 进行 Mixin 的插件共存(如 Create Big Cannons、Aeronautics、Sable 等)。
许可证
MIT。不包含任何 Create 代码——仅提供一个 Mixin 和元数据。
Create Collision Crashfix
A tiny, single-mixin hotfix for a server-fatal crash in Create 6.0.10 on Minecraft 1.21.1 (NeoForge).
The problem
A moving Create contraption can hard-crash the server tick loop:
java.lang.NullPointerException: Cannot read field "x" because "mf.axis" is null
at com.simibubi.create.foundation.collision.ContinuousOBBCollider.collideMany(ContinuousOBBCollider.java:153)
at com.simibubi.create.content.contraptions.ContraptionCollider.collideEntities(ContraptionCollider.java:166)
at com.simibubi.create.content.contraptions.ContraptionHandler.tick(ContraptionHandler.java:54)
Description: Exception in server tick loop
Once it happens the world usually crash-loops on load, because the offending contraption fires the same crash every tick.
When it triggers: a moving contraption's collision check hits a degenerate, zero-distance case — an entity's bounding-box center lands exactly on a contraption block's center on every axis. The most common real-world trigger is a rope pulley + drill quarry (e.g. a drill array with the pulley in the center column), but rotating bearings, tree farms with a saw, and similar setups can also hit it.
This is an upstream Create bug, present only in 6.0.10 (6.0.9 is unaffected). The official fix is Create PR #10301, milestoned for 6.0.11, which is not released yet. Downgrading to 6.0.9 is not an option for most packs because many Create addons require create >= 6.0.10.
Related upstream reports
- Issue #10218 (tracking) —
- Issue #10278 —
mf.axis is null when entity AABB center coincides with contraption block center —
- Issue #10344 —
- Issue #10353 —
- Issue #10378 — contraption collision NPE edge cases —
- Issue #10479 — tree farm crashes server when loaded —
- Upstream fix: PR #10301 —
The fix — what changed and why it works
Inside Create's ContinuousSeparationManifold#separate, the separation axis (and normalAxis) are recorded only when the tested distance is non-zero:
if (distance != 0.0 && -diff <= Math.abs(this.separation)) {
this.axis = axis; // never runs in the degenerate, coincident-center case
this.separation = separation;
}
In a perfectly coincident overlap every separation test runs with distance == 0, so axis/normalAxis stay null. collideMany then dereferences them (mf.axis.x) and the server dies.
This mod wraps the two field reads in collideMany with a null guard (MixinExtras @WrapOperation). When the recorded axis is null, it returns Vec3.ZERO, so the degenerate collision contributes zero push for that tick instead of crashing. The next tick the entity has moved sub-voxel, a valid separation axis exists, and collision resolves normally — no stuck entities, no clipping.
@WrapOperation(
method = "collideMany",
at = @At(value = "FIELD",
target = "L.../ContinuousOBBCollider$ContinuousSeparationManifold;axis:Lnet/minecraft/world/phys/Vec3;",
opcode = Opcodes.GETFIELD),
remap = false)
private static Vec3 guardAxis(@Coerce Object manifold, Operation<Vec3> original) {
Vec3 value = original.call(manifold);
return value == null ? Vec3.ZERO : value; // same for normalAxis
}
Why Vec3.ZERO specifically, and why it's safe:
- When
axis is null, the paired separation scalar is Double.MAX_VALUE. A non-zero fallback axis would compute axis * MAX_VALUE and fling the entity to infinity. 0 * MAX_VALUE == 0 neutralizes it cleanly — no NaN, no teleport.
axis and normalAxis are the only nullable Vec3 reads in collideMany (stepSeparationAxis is final and non-null; the collision* fields are primitive double), so this covers every null-deref site in the method.
- The guard activates only on the null/degenerate path. Every normal collision is byte-for-byte unchanged.
The fix mirrors the intent of upstream PR #10301; it is deliberately surgical so it cannot affect non-degenerate physics.
Compatibility
- Minecraft 1.21.1 · NeoForge 21.1.x
- Create 6.0.10 only. The mod is hard-pinned to
create [6.0.10]. On any other Create version it refuses to load with a clear requires create [6.0.10] message — which is your reminder to remove it once Create 6.0.11 (with the official fix) is out.
- Install on both client and server (versions must match).
- No mixin into addon classes — it only guards two field reads inside Create core, so it coexists with addons that mixin
ContraptionCollider (Create Big Cannons, Aeronautics, Sable, etc.).
License
MIT. Ships no Create code — just a mixin and metadata.
评论 0
登录后参与评分
还没有评论,来抢沙发吧