❌ 不再出现 NPE —— LivingDeathEvent.getSource() is null
是否厌倦了模组向 Minecraft 的伤害或死亡流程传递空 DamageSource 而导致的崩溃?
本模组为多个常见的伤害/死亡路径添加了运行时保护,从而在它们导致游戏崩溃之前捕获大量无效的 DamageSource 情况。它还可以记录有用的信息,以帮助识别引发问题的模组。
局限性
DamageSource Is Not Null 是一个防御性缓解模组,而非保证通用的修复方案。
然而,由于模组化 Minecraft 的性质,它无法保证在所有情况下都能提供保护。某些模组可能会绕过受保护的路径、覆盖核心方法,或者在本模组能够拦截之前就发生崩溃。
最好将本模组理解为一种安全层,用于降低崩溃风险并改进诊断——而不是承诺能解决所有此类崩溃。
? 2.0.0 版本
2.0.0+ 版本大幅改进了内部安全保护和调试工具。
主要改进包括:
- ? 改进了命令工具,用于测试和诊断
DamageSource 问题
- ? 修补了原始保护实现中的多个漏洞
这些更改使得保护在大型整合包中更加可靠,并帮助整合包作者更容易地定位有问题的模组。
⚠ 强烈建议升级到 2.0.0。
目前,2.0.0 仅适用于 1.20.1 Forge。2.0.0 引入的改进将在未来逐步移植到其他支持版本(Forge、Fabric 以及其他 Minecraft 版本)。
? 本模组的作用
本模组注入安全检查到以下位置:
LivingEntity#hurt
LivingEntity#die
如果某个模组错误地触发了带有 null DamageSource 的伤害或死亡事件(这绝不应该发生),本模组将会:
- 防止许多常见的 NullPointerException 崩溃
- 将无效的来源替换为备用通用 DamageSource
- 打印详细日志以帮助整合包作者找到罪魁祸首
? 为什么需要这个模组
虽然原版和 NeoForge 期望 DamageSource 永远不为空,
但某些模组仍然错误地触发事件并导致整个游戏崩溃。
通常,这会导致如下错误:
LivingDeathEvent.getSource() is null
这会杀死服务器并中断游戏,且原因完全超出玩家的控制范围。
本模组在此类情况下充当运行时安全网。
⚠ 重要说明
- ❗ 本模组不会修复损坏的模组——它仅防止崩溃。
- ❗ 本模组是防御性缓解模组,而非保证通用的修复方案。
- ⚠ 如果在日志中看到警告,您仍应向模组作者报告。
- ✅ 可在客户端和专用服务器上安全使用。
- ? 设计为轻量级,并与大型整合包兼容。
? 对整合包友好
如果您是整合包作者或服务器管理员,本模组可以帮助:
- 防止意外停机
- 避免世界文件损坏
- 收集有用的崩溃信息而不中断游戏体验
可以将其视为针对糟糕伤害事件的断路器。
? 环境支持
NeoForge
Forge
Fabric
? 许可证
MIT 许可证 — 可自由用于任何整合包。
❌ No More NPE — LivingDeathEvent.getSource() is null
Tired of crashes caused by mods passing a null DamageSource into Minecraft's damage or death pipeline?
It adds runtime guards to several common damage/death paths so that many invalid DamageSource cases can be caught before they crash the game. It can also log useful information to help identify the offending mod.
Limitation
DamageSource Is Not Null is a defensive mitigation mod, not a guaranteed universal fix.
However, due to the nature of modded Minecraft, it cannot guarantee protection in every case. Some mods may bypass the guarded paths, override core methods, or crash earlier than this mod can intercept.
This mod is best understood as a safety layer that reduces crash risk and improves diagnostics — not as a promise that all such crashes are solved.
? Version 2.0.0
Version 2.0.0+ significantly improves the internal safety guard and debugging tools.
Key improvements include:
- ? Improved command tools for testing and diagnosing
DamageSource issues
- ? Multiple loopholes closed in the original guard implementation
These changes make the protection more reliable in large modpacks and help modpack authors locate problematic mods more easily.
⚠ Upgrading to 2.0.0 is strongly recommended.
Currently, 2.0.0 is only on 1.20.1 Forge. The improvements introduced in 2.0.0 will be gradually backported to other supported versions (Forge, Fabric, and additional Minecraft versions) over time.
? What This Mod Does
This mod injects safety checks into:
LivingEntity#hurt
LivingEntity#die
If a mod incorrectly triggers damage or death with a null DamageSource (which should never happen), this mod will:
- Prevent many common NullPointerException crashes
- Replace the invalid source with a fallback generic DamageSource
- Print detailed logs to help modpack authors locate the culprit
? Why This Exists
While vanilla and NeoForge expect DamageSource to never be null,
some mods still trigger events incorrectly and crash the entire game.
Normally, this results in errors like:
LivingDeathEvent.getSource() is null
Which kills servers and interrupt gameplay for reasons outside the player's control.
This mod acts as a runtime safety net for such situations.
⚠ Important Notes
- ❗ This mod does not fix the broken mod — it only prevents crashes.
- ❗ This mod is a defensive mitigation mod, not a guaranteed universal fix.
- ⚠ If you see warnings in logs, you should still report them to the mod author.
- ✅ Safe to use on both client and dedicated servers.
- ? Designed to be lightweight and compatible with large modpacks.
? Modpack Friendly
If you're a modpack author or server owner, this mod can help:
- Prevent unexpected downtime
- Avoid corrupted worlds
- Collect useful crash info without stopping gameplay
Think of it as a circuit breaker for bad damage events.
? Environment
NeoForge
Forge
Fabric
? License
MIT License — free to use in any modpack.
评论 0
登录后参与评分
还没有评论,来抢沙发吧