ejektaflex / Bountiful

A Minecraft mod adding bounties for specific items.
https://minecraft.curseforge.com/projects/bountiful
GNU General Public License v3.0
91 stars 32 forks source link

[Bug]: Ticking Entity Crash When Villagers Near Bounty Board #278

Closed alexiswatson closed 5 months ago

alexiswatson commented 5 months ago

What happened?

When staying in a village where villagers are kept near bounty boards, after a time, the game throws and crashes to launcher unexpectedly.

Relevant log snippet:

java.util.NoSuchElementException: No value present
    at java.base/java.util.Optional.get(Optional.java:143)
    at io.ejekta.bountiful.content.villager.WalkToBoardTask.keepRunning(WalkToBoardTask.java:44)
    at io.ejekta.bountiful.content.villager.WalkToBoardTask.method_18924(WalkToBoardTask.java:13)
    ...

Full log follows.

How can we reproduce it?

Create a village in an SP world, with villagers kept in 2x2 cells with beds. Replace two blocks of each cell with a profession block and bounty board, such that the villager can reach both. Where feasible, add decrees to each board aligning with that villager's profession. Wait.

This crash occurs once every few hours, and cannot seem to be reproduced on command, though does not appear to require direct interaction with either the villagers, bounty boards, bounties, or decrees to occur. Notably, the ticking entity (always a villager) differs each time, and does not appear to be isolated to any specific profession.

The crash does not seem to occur when the village chunk is unloaded.

Mod Version

7.0.2

Mod Loader

Fabric

Mod Loader Version

fabric-api-0.97.0+1.20.4

Relevant log output

crash-2024-04-19_18.33.16-server.txt

ejektaflex commented 5 months ago

Ah, this is a fun one.

https://github.com/ejektaflex/Bountiful/blob/25e14dfc7f7c6e86d9cc4408dbfbc26cad597310/common/src/main/java/io/ejekta/bountiful/content/villager/WalkToBoardTask.kt#L44

Seems like the memory module access is failing, due to a villager forgetting where the nearest Board is. I'll have to just make it optional.

ejektaflex commented 5 months ago

This is fixed in 76b307f and will be in a future release for either 1.20.4 or a newer version. Thanks!