Improved Mobs (Fabric)

Improved Mobs (Fabric)

50k Downloads

World crash with message: java.lang.NullPointerException: Capability null. This shouldn't be

deadlymango opened this issue ยท 1 comments

commented

Modloader

Forge

Minecraft version

1.18.1

Modloader version

Forge 39.0.76

Mod version

improvedmobs-1.18.1-1.8.1-forge

TenshiLib version

tenshilib-1.18.1-1.4.0-forge

Description

After the world is finished loading, the server may crash when a zombie attempts to perform an action provided by this mod. It seems that the crash occurs when a zombie tries to "getTileData" when "StealGoal" is invoked.

After some testing, I believe the mod "Lootr" to be the cause of the crash. https://www.curseforge.com/minecraft/mc-mods/lootr Lootr modifies naturally generating chests to be lootable by multiple players. Each player who opens a Lootr chest will see their entirely own set of loot; e.g. I may see only food from this chest, but another player may be luckier and see a Diamond Sword. Thus, there is no single inventory for this chest.

Given the nature of the Lootr mod, I do not know how one would go about resolving this issue. I see two possible methods:

  1. Turn off stealing from chests completely in the config. (it turns out that while this would indeed prevent the game from crashing when a zombie attempts to steal, the player can no longer open any Lootr-modified chests)
  2. Create a configuration option to target certain block entities/chests via whitelist , e.g. allow only "minecraft:chest" and "minecraft:barrel" to be stolen from. Thus only player-created and normally spawning chests can be looted, while modded chests from mods like Lootr are ignored.

From the CurseForge page, I see the line: "If the mob does not have an active target it will search for nearby inventories to loot the items so protect your chest now! However they will not loot inventories which have not been opened by a player (So dungeon loots etc. are safe)"
It is possible that Lootr makes the dungeon-generated chests appear to ImprovedMobs to be a player-created chest. I ponder the feasibility of implementing option 2.

Steps to reproduce

  1. On a dedicated server, create new world with my list of mods installed
  2. wait a bit, or connect to the server and spawn in some zombies using "/summon zombie"
  3. eventually a mob, probably a zombie, will attempt to run the "stealgoal" method.
  4. Crash

Mods that might affect the issue

I first tested using just world gen / biome mods (BO'P, BYG, Terralith, Unearthed, biomemakeover) and Improved Mobs, and did not see the crash.
Then I started adding half of my mods at a time.

I also disabled Zombie Awareness and Angry Mobs, and the crash still appeared, so I can say those are not the cause.

My suspicion is that there is a mod that adds chests and the zombie attempts to target this modded chest, but somehow it fails and ends up as null.


After some more testing, I suspect that the mod "Lootr" is to blame for this. I tested placing a normal chest down, putting in some food items, and spawned in some zombies. They went to the chest and took out the items.
Then I went to a village generated by the Sky Villages mod. Lootr detected the generated chests and replaced them with its own chests. I attempted to open this chest, but I got an error message just like the one in the crash log; however, the game continued to run. It is only when I spawned in a zombie and it targeted the Lootr chest did the server crash.

Logs

server log: https://paste.gg/p/anonymous/6fcaa71673c64969aee761e3e53e7f36
crash log: https://paste.gg/p/anonymous/a1518f1a4c884c5c876b4741d1dc4a4a

commented

they block any capability access on their blockentities which is... concerning

gonna rewrite the stuff on my end anyway to use the forge way though