Silent Gear

Silent Gear

30M Downloads

NullPointerException in CoreMattock.getHarvestLevel

tyra314 opened this issue · 1 comments

commented

Hi, I got a crash-report against my mod ToolProgression (issue here). Basically, I'm calling Item::getHarvestLevel with some null here, which crashes with an NPE here because state and player are null. It's not exactly textbook, but I have no state to pass 🤷‍♂️ While I'm not exactly sure, which behavior is fine, I think your overload should handle null values as the method in Item marked them as @Nullable.

From what I learned about harvest levels, tool classes, and such, it should be enough to check the tool classes there.

And if you're on it, it would be nice, if you could overload the setHarvestLevel method, so my mod can actually overwrite the tools' harvest level :)

Versions

Minecraft: 1.12.2
Forge: 14.23.4.2760
ToolProgression: 1.5.6
Silent Gear: 0.1.3-42
Silent Lib: 3.0.5-152

commented

I can fix the NPE at least. Not sure about setHarvestLevel. I guess I could find a way to allow tool classes to be set, but the number would be meaningless since each tool type must be a single item.