Sharlottes/Informatis

Cannot read field "usage" because "turret.block.consPower" is null

alexNecroJack opened this issue · 3 comments

Reproduction

I installed the mods, I hovered over a built turret, and crash.
It has to do with the "Spear" turret, which I built.
It's from mod ### ?

Crash report log

Mindustry has crashed. How unfortunate.
Version: release build 146
OS: Windows 8.1 x64 (amd64)
Java Version: 16.0.1
Runtime Available Memory: 2024mb
Cores: 4
Mods: additional-content:0.4.1, animalia:java 1.0, betamindy:1.1
[#b59e72]Demo of Chaos Itself[], betamindy-music:1.0, cyber-io:5.1, distributor:1.1, extra-utilities:1.1.5.2, informatis:1.9.1, me:2.3, mi2-utilities-java:1.4.2c, miner-tools:1.7.5, new-horizon:0.4.8, production-mod:A4.4.3, prog-mats:27.3, sapphirium:16.0, trade-it:3.0, trade-terminals:2.0.1, uaw:v0.8.3, unity:0.2-youngcha.3.3

java.lang.NullPointerException: Cannot read field "usage" because "turret.block.consPower" is null
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.lambda$getInfo$88(UnitWindow.java:509)
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.lambda$getInfo$92(UnitWindow.java:516)
	at informatis.ui.components.SBar.<init>(SBar.java:35)
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.lambda$buildContent$22(UnitWindow.java:228)
	at arc.scene.ui.layout.Table.table(Table.java:264)
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.lambda$buildContent$23(UnitWindow.java:227)
	at arc.scene.ui.layout.Table.table(Table.java:264)
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.lambda$buildContent$24(UnitWindow.java:225)
	at arc.scene.ui.layout.Table.<init>(Table.java:70)
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.buildContent(UnitWindow.java:139)
	at informatis.ui.fragments.sidebar.windows.UnitWindow$UnitWindowBody.rebuild(UnitWindow.java:135)
	at informatis.core.VDOM.lambda$new$0(VDOM.java:20)
	at arc.Events.lambda$run$2(Events.java:20)
	at arc.Events.fire(Events.java:36)
	at mindustry.core.Logic.update(Logic.java:406)
	at arc.ApplicationCore.update(ApplicationCore.java:37)
	at mindustry.ClientLauncher.update(ClientLauncher.java:237)
	at arc.backend.sdl.SdlApplication.listen(SdlApplication.java:204)
	at arc.backend.sdl.SdlApplication.loop(SdlApplication.java:192)
	at arc.backend.sdl.SdlApplication.<init>(SdlApplication.java:54)
	at mindustry.desktop.DesktopLauncher.main(DesktopLauncher.java:39)

Addition Context

If you guard your checks,
meaning, if you dont take for granted each turret has for example a "consPower", or usage, or anything you would expect it to have, then your mod will come closer to 100% bug-free.

thanks for your reporting!
I also hope to 100% bug free from NPE, but it's hard to know which one is nullable and which one is not.
but at least in this point, you're right - consPower is Nullable explicitly at the code.
https://github.com/Anuken/Mindustry/blob/fdfb79477b10fbf77dbeb8dbf59b86f6c41c4077/core/src/mindustry/world/Block.java#L358C37-L358C37

    /** The single power consumer, if applicable. */
    public @Nullable ConsumePower consPower;

the why I take for granted the value is not nullable although that's defined Nullable is I was new at programming - and had low insight. I'll find out nullable values as possible as many but it would be hard.

the hotfix will be fixed in a day.

@alexNecroJack can you check latest mod build in this action artifact?https://github.com/Sharlottes/Informatis/actions/runs/7109676431

due to have waited too long time, the issue's closed now.