让我们来修复错误

让我们来修复错误

修复Let's Do系列模组在Forge 1.20.1上的Bug。

Bug修复

[Let's Do] 崩溃修复

一个独立的补丁专用 Forge 1.20.1 模组,包含三类修复:

  1. 由多个 [Let's Do] 模组(Meadow、BloomingNature、Vinery 等)在并行阶段的 FMLCommonSetupEvent 中同时写入原版 FireBlock 可燃方块表导致的启动崩溃: java.lang.ArrayIndexOutOfBoundsException: Index 1024 out of bounds for length 513

  2. Create 蓝图打印机 / 蓝图加农炮在加载包含 Vinery 储物架方块实体(StorageBlockEntity)的蓝图时崩溃: java.lang.ClassCastException: SchematicLevel cannot be cast to ServerLevel

  3. Farmer's Delight 的沃土耕地无法识别 Farm & Charm 的洒水器为水源。因此,沃土在洒水器附近无法保持湿润,并会退化为普通泥土。

机制

原版 FireBlock 将方块可燃性几率存储在两个非线程安全的 fastutil 哈希表中。多个 Let's Do 模组会从各自的 FlammableBlockRegistry.init() 中并发调用 FireBlock.registerFlammable(SRG 名称 m_53444_)。当两张表同时被重新哈希和修改时,它们的键值数组长度会失去同步,从而触发越界崩溃。

Vinery 的 StorageBlockEntity.setChanged() 会强制将其 level 转换为 ServerLevel。Create 的蓝图系统使用一个虚拟的 SchematicLevel 假世界;这种强制转换会抛出异常并阻止蓝图加载。

Farmer's Delight 的 RichSoilFarmlandBlock.isNearWater() 仅检查原版水方块。Farm & Charm 的 water_sprinkler 方块应被视为有效水源,但被忽略,导致附近的沃土退化。

本模组应用针对原版的 Mixin 以:

  • 将 FireBlock.m_53444_ 中的两个 Object2IntMap.put 调用包裹在全局锁中,序列化所有可燃物注册写入;
  • 对于 Vinery / Meadow / BloomingNature / Brewery / Farm & Charm / Bakery / doapi 中总共 13 个方块实体类,当实体位于非 ServerLevel 的假世界中时,跳过 setChanged() 的执行;
  • 向 Farmer's Delight 的 RichSoilFarmlandBlock.isNearWater() 注入额外的水源检查,使 Farm & Charm 的 water_sprinkler 方块被视为有效水源。

不修改任何原始模组的文件,也不改变任何游戏存档数据。

使用方法

将 dist/letsdo‑crashfix‑1.0.3‑mc1.20.1‑forge.jar 放入你的 mods 文件夹(无需额外的依赖模组)。

当你在启动日志中看到以下行时,补丁即已生效: [Let's Do] Crash Fix: flammable registration is now serialized via FireBlock mixin.