Skip to content

[Bug] 叶子快速腐烂功能会导致崩溃 #7

@VictorModi

Description

@VictorModi

OS Version - 操作系统

Windows

Minecraft Version Details - Minecraft 版本信息

1.21.1

Mod Loader - 模组加载器

Forge

Version Details - 版本信息

0.0.1+build.27

Existing behavior - 现有行为

单人模式下,打开 fastLeafDecay 功能有概率在ESC时崩溃。

https://mclo.gs/ieQcdNE

在经过分析后(非AI)认为是 BlockEventListener.onNotifyNeighbors(...) 中调用了 TimerQueue 去加速叶子腐烂,但在 timerqueue.schedule() 时放入的计划任务无法在世界保存时正确序列化,序列化结果为 null,所以导致 Minecraft 尝试 net.minecraft.world.level.timers.TimerCallback$Serializer.serialize(net.minecraft.nbt.CompoundTag, net.minecraft.world.level.timers.TimerCallback) 时,触发了 java.lang.NullPointerException

  • TimerQueue 设计要求所有任务必须有对应的 TimerCallback.Serializer,这样任务才能在世界保存时序列化进 NBT,并在世界加载时反序列化还原。
  • 但源代码中放入的确是一个 lambda,并没有 serializer()
  • 在世界保存时,TimerQueue.store() 遍历所有任务,然后调用 callback.serializer().serialize(...),结果序列化到本模组的计划任务时,得到了一个 null , 也就造成了 java.lang.NullPointerException

Expected behavior - 预期行为

不再崩溃

To Reproduce - 复现问题

在单人存档里打开 fastLeafDecay 功能,找棵树将其树干采集,在叶子腐烂完全前按下ESC。

This issue is unique - 这个issue是唯一的

  • I have searched the issue tracker and did not find an issue describing my bug. - 我已经搜索问题追踪器并且没有发现相同的 issue。

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions