DamageSource Is Not Null
ModMIT

DamageSource Is Not Null

An attempt to fix "NullPointerException: LivingDeathEvent.getSource() is null"

44
Downloads
0
Followers
2 months ago
Updated
📦
2
Versions

📖About DamageSource Is Not Null

❌ No More NPE

LivingDeathEvent.getSource() is null

Tired of random crashes caused by broken mods passing null DamageSource into entity death or damage events?

This mod adds a defensive guard to Minecraft’s damage & death pipeline, preventing servers and single-player worlds from crashing due to invalid DamageSource usage by other mods.

Instead of crashing your game, it will:

  • Block the invalid call safely
  • ⚠️ Log a warning or error with stack trace
  • 🔍 Help you identify which mod caused the problem

So you can keep playing, and fix the real issue later.


🛡 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 the NullPointerException
  • Allow the entity to continue behaving normally
  • 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 corrupts worlds 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.
  • ⚠ 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

  • Minecraft: 1.21.1
  • Loader: NeoForge

📜 License

MIT License — free to use in any modpack.