Light level overlay crash
szikra opened this issue · 10 comments
Enabling Light level overlay (or joining the world/server with it enabled) causes a crash.
Time: 2020.07.12. 12:46
Description: Unexpected error
java.lang.IllegalStateException: Tag minecraft:prevent_mob_spawning_inside used before it was bound
at net.minecraft.class_5120$class_5121.method_26776(class_5120.java:67)
at net.minecraft.class_5120$class_5121.method_15141(class_5120.java:78)
at net.minecraft.class_2248.method_9525(class_2248.java:136)
at net.minecraft.class_4970$class_4971.method_26164(class_4970.java:938)
at net.minecraft.class_1948.method_8662(class_1948.java:420)
at fi.dy.masa.minihud.renderer.OverlayRendererLightLevel.canSpawnAt(OverlayRendererLightLevel.java:366)
at fi.dy.masa.minihud.renderer.OverlayRendererLightLevel.updateLightLevels(OverlayRendererLightLevel.java:336)
at fi.dy.masa.minihud.renderer.OverlayRendererLightLevel.update(OverlayRendererLightLevel.java:74)
at fi.dy.masa.minihud.renderer.RenderContainer.update(RenderContainer.java:91)
at fi.dy.masa.minihud.renderer.RenderContainer.render(RenderContainer.java:72)
at fi.dy.masa.minihud.renderer.OverlayRenderer.renderOverlays(OverlayRenderer.java:43)
at fi.dy.masa.minihud.event.RenderHandler.onRenderWorldLast(RenderHandler.java:175)
at fi.dy.masa.malilib.event.RenderEventHandler.onRenderWorldLast(RenderEventHandler.java:108)
at net.minecraft.class_761.handler$zem000$onRenderWorldLastNormal(class_761.java:3086)
at net.minecraft.class_761.method_22710(class_761.java:1921)
at net.minecraft.class_757.method_3188(class_757.java:1008)
at net.minecraft.class_757.method_3192(class_757.java:688)
at net.minecraft.class_310.method_1523(class_310.java:1021)
at net.minecraft.class_310.method_1514(class_310.java:654)
at net.minecraft.client.main.Main.main(Main.java:215)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192)
at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140)
at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26)
(This happens on some servers but not on another.)
I'm also having the same issue.
I get the error above on a spigot server which houses multiple servers (one of which is 1.12, though I was not attempting to play on that one). Once I turn the light level overlay on, it immediately crashes and subsequent attempts to reconnect also end up crashing me, until I turn it off on a different server (see below) or edit the config file to turn it off. The server is a public SMP, so it's not like I have the power to change anything serverside.
I do not get this issue on a standard MC server (no plugins, no nothing). I can turn it on/off no problem.
I hope this helps.
It seems like the bungee cord network protocol then somehow omits something that vanilla servers in recent versions do. I can fix the crash, but the light level overlay might then not work entirely correctly on such servers as far as the block's spawn suitability is concerned.
Are you using the MultiConnect mod or are some of those servers using BungeeCord and running older MC versions? I'm not sure how and why those tags would not be set otherwise.
The main server I play on accepts 1.12-1.16.1 clients, the server has 1.12 and 1.16 worlds, the lobby is probably 1.12.
I can connect to the server with 1.14.4 client and minihud-forge-1.14.4-0.19.0-dev.20191210.230927.jar and have no no issue, lighting overlay works fine (in the 1.12 worlds, lobby).
I can also connect and use it with 1.12.2 and minihud-forge-1.12.2-0.19.0-dev.20191217.195221.jar, overlay works fine.
I did some further testing:
I can connect to the server with 1.16.1 client with minihud-fabric-1.16.1-0.19.0-dev.20200701.005153.jar, (if the overlay is disabled - I set mod config Generic/enabled to false).
Then I can enter a 1.16 world on the server and enable lighting overlay and it works, but if I go back to lobby (or if I'm put there because of AFK) then the game crashes. The game crashes as well if I enable the overlay in a 1.12 world.
So, yes it seems that 1.16 minihud doesn't handle older (1.12) MC server worlds.
I'm not using MultiConnect and I don't know about BungeeCord.
As far as I can tell server is running PaperMC and ViaVersion. (I can give you the exact servers I tried if you need it.)
I could fall back or just straight up switch over to using a custom check for mob spawnability, which simply omits the one check that breaks the code currently in those dimensions. And the only thing that check does atm in vanilla is check whether or not a mob can spawn inside a block, and this is only used for preventing mob spawning inside rails. So in this context the light level overlay would appear inside rails even though mobs can't spawn there.
So I might just switch to doing that instead. It would mean a few small checks would be duplicated in the mod instead of using the vanilla method for the check, which is not ideal for maintainability, as it would be easy to miss those in some future update and that could then produce faulty spawnability check results due to outdated duplicated code. But then again the light level overlay isn't meant to be fully accurate for spawn checks anyway, it's mostly just for the light level information, and I just chose to use these checks to basically exclude rendering it in places where mobs can't spawn anyway.
I don't know if you want to do this or not, but it could be a feature to be able to enable/disable spawnability checking (or even select method:vanilla/mod/off).
In other words to enable/disable light level overlay on non-spawnable surfaces (in mod config menu).
(Which could answer questions like "Would I need more light if I (re)moved rails?" at glance. Or to check surfaces currently covered by water...)
I added a fix for the crash. I just did it such that if the exception is thrown, then the light level overlay just gets disabled completely inside that dimension. I don't have a server to test this on, so I don't know if it gets reset properly when you switch dimensions.
Fixed build is here: https://masa.dy.fi/mcmods/minihud/minihud-fabric-1.16.1-0.19.0-dev.20200714.233517.jar
It works, it shows overlay in 1.16 worlds, and shows the "This dimension seems ..." message in 1.12 worlds.
Thank you for the fix, ... and thank you for the mod.
I don't know if it's possible to be compatible with older MC servers and show overlays on those worlds from 1.16 client and mod in the future. But now I'm still mostly using 1.14 client anyways ...until they upgrade the server to 1.16, and then it won't matter... so, it works for me :)
Thanks again for the great mod.
I uploaded a new build which just simplifies the checks instead of disabling the light level overlay completely.
https://masa.dy.fi/mcmods/client_mods/?mcver=1.16.1
And yes an option for spawnability checks, and a separate overlay for spawnable spots, will probably be added at some point.