MUYUTwilighter / saplanting_fabric

A fabric mod that automatically plant sapling drops in minecraft games.
MIT License
6 stars 0 forks source link

NullPointerException logged while flying around `"generator" is null` #12

Closed magneticflux- closed 1 year ago

magneticflux- commented 1 year ago
[14:30:53] [Server thread/INFO]: Launching Saplanting core thread.
[14:30:53] [SaplantingCoreThread/INFO]: Saplanting core thread exited unexpectedly!
[14:30:53] [SaplantingCoreThread/INFO]: [STDERR]: java.lang.NullPointerException: Cannot invoke "cool.muyucloud.saplanting.mixin.SaplingGeneratorAccessor.getTreeFeature(net.minecraft.class_5819, boolean)" because "generator" is null
[14:30:53] [SaplantingCoreThread/INFO]: [STDERR]:   at net.minecraft.class_1542.plant(class_1542.java:1217)
[14:30:53] [SaplantingCoreThread/INFO]: [STDERR]:   at net.minecraft.class_1542.run(class_1542.java:1249)
[14:30:53] [SaplantingCoreThread/INFO]: [STDERR]:   at net.minecraft.class_1542.multiThreadRun(class_1542.java:1276)
[14:30:53] [SaplantingCoreThread/INFO]: [STDERR]:   at java.base/java.lang.Thread.run(Thread.java:1589)

Full logs (includes several unrelated errors): https://mclo.gs/RKE95rs

MUYUTwilighter commented 1 year ago

Probably it has something to do with unimplemented block definition(for example, a modder added a sapling block but fail to achieve a corresponding tree generator, then fill the member with NULL to avoid compilation-errors). And as you can see in the log you've submitted, many mods (like ecologics, byg, etc.) may well add varieties of saplings into Minecraft, so it's hard for me to say which one exactly caused the error (not mentioned in the log). So here's the thing, there are two ways in general you may let us know more useful information about this issue. Do a back-up of your save first

  1. Turn off property "multiThread", then do something similar where you see this error last time. If the error happens, the game would crash (that's why back-up), and submit the log and crash report that will contain which sapling block has the problem I mention above.
  2. Try to recall where you were you last saw this error message, like biome, structure. Since saplings and trees usually appear in specific biomes, this information will help us to find out.
magneticflux- commented 1 year ago

BYG doesn't set a SaplingGenerator here, instead it uses GrowingPatterns. Could you check for null and skip trying to plant as a temporary workaround for missing generators?

MUYUTwilighter commented 1 year ago

I've tested and learned what AOCAWOL had done in BYG. Usually we should created a generator-class and get it extended from SaplingGenerator.class if we want to define some specific features, but apparently the author is not doing so. To avoid spam errors, I've done several detect. Now the plant-operation will be quoted with try-catch. If errors occur, saplanting will only show one message for one item entity, then this entity will be tagged as "contain-error", and will not participate in check-and-tick operation.