[BUG] Collided with multiple citizens and the game crashed because getCitizenData() returns null. (also crashes on world startup)
PasserbyDeveloper opened this issue ยท 3 comments
Is there an existing issue for this?
- I have searched the existing issues
Are you using the latest MineColonies Verison?
- I am running the latest alpha version of MineColonies for my Minecraft version.
Did you check on the Wiki? or ask on Discord?
- I checked the MineColonies Wiki and made sure my issue is not covered there. Or I was sent from discord to open an issue here.
Minecraft Version
1.18
MineColonies Version
1.18.2-1.0.662-ALPHA
Structurize Version
1.18.2-1.0.389-RELEASE
Related Mods and their Versions
- Forge Version: 40.0.46
- Structurize Version: 1.18.2-1.0.389-RELEASE
- Java Version: "17.0.3" 2022-04-19 LTS 64-bit
I'm using a modpack: Dragoncraft Reborn NEW [Forge 1.18.2]
, but I'm confident that is not related to the problem.
Current Behavior
Game crashes on citizen collision (player touching multiple citizens).
I initially had the crash on 1.18.2-1.0.650-ALPHA
, but I updated to 1.18.2-1.0.662-ALPHA
and the problem persists.
The logs indicate this:
java.lang.NullPointerException: Cannot invoke "com.minecolonies.api.colony.ICitizenData.getJob()" because the return value of "com.minecolonies.api.entity.citizen.AbstractEntityCitizen.getCitizenData()" is null
The problem seems to be at onPlayerCollide when the getCitizenData()
method is called it returns null, and then getJob
fails.
Expected Behavior
No crash is expected.
I believe the null value from getCitizenData() should not crash the game. Also the citizen is not a guard, so I expect that super.onPlayerCollide() will be called after getCitizenData() returns null.
It should be noted I have no idea why getCitizenData is null, it may be setCivilianData
failed because I just teleported quickly from my death and the citizen data is not yet loaded?
Reproduction Steps
(I had been playing for a few hours and had about 8 citizens)
- I died at night, when all villagers were at the main building (no individual houses)
- My bed is where all citizens hide at night (main building)
- Pressed respawn.
- A single frame of me colliding with multiple citizens shows up and the game crashes
- Restarting the world also crashes with the same crashlog.
It seems like I'm colliding with all citizens at once, and one of them is crashing my game.
Logs
Anything else?
I will try to fix this by changing the code and recompiling (not sure if I'll manage it), possibly sending a PR request to fix this.
If I don't manage it I will just teleport my player by external means (changing user data file) to work around it, then I will kill the citizens involved (I will blame natural selection) and hope the new ones don't have this bug.
- Add a thumbs-up to the bug report if you are also affected. This helps the bug report become more visible to the team and doesn't clutter the comments.
- Add a comment if you have any insights or background information that isn't already part of the conversation.
Same here. I used "/mc home" command in a young Colony and game crashed. Savegame is not loadable anymore. I believe, the reason is, the villagers are standing at the same spot.