maruohon / tellme

Small informational mod for Minecraft
22 stars 10 forks source link

NPE on dumping creative tabs #14

Closed LemADEC closed 5 years ago

LemADEC commented 5 years ago

As of tellme-1.12.2-0.7.0-dev.20181108.025215, there's an exception thrown when dumping creative tabs:

[21:54:31] [Server thread/WARN] [net.minecraft.command.CommandHandler]: Couldn't process command: tellme dump-csv creativetabs
java.lang.NullPointerException: null
    at fi.dy.masa.tellme.datadump.ItemDump.getStackInfoBasic(ItemDump.java:269) ~[ItemDump.class:?]
    at fi.dy.masa.tellme.proxy.ClientProxy.addCreativeTabData(ClientProxy.java:135) ~[ClientProxy.class:?]
    at fi.dy.masa.tellme.datadump.CreativetabDump.getFormattedCreativetabDump(CreativetabDump.java:13) ~[CreativetabDump.class:?]
    at fi.dy.masa.tellme.command.SubCommandDump.getData(SubCommandDump.java:153) ~[SubCommandDump.class:?]
    at fi.dy.masa.tellme.command.SubCommandDump.outputData(SubCommandDump.java:116) ~[SubCommandDump.class:?]
    at fi.dy.masa.tellme.command.SubCommandDump.execute(SubCommandDump.java:107) ~[SubCommandDump.class:?]
    at fi.dy.masa.tellme.command.CommandTellme.func_184881_a(CommandTellme.java:92) ~[CommandTellme.class:?]
    at net.minecraft.command.CommandHandler.func_175786_a(CommandHandler.java:119) [bj.class:?]
    at net.minecraft.command.CommandHandler.func_71556_a(CommandHandler.java:91) [bj.class:?]
    at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:960) [pa.class:?]
    at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:939) [pa.class:?]
    at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:37) [la.class:?]
    at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:9) [la.class:?]
    at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:20) [hv$1.class:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_181]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_181]
    at net.minecraft.util.Util.func_181617_a(Util.java:47) [h.class:?]
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:723) [MinecraftServer.class:?]
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
    at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:252) [chd.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
[21:54:31] [Client thread/INFO] [net.minecraft.client.gui.GuiNewChat]: [CHAT] An unknown error occurred while attempting to perform this command
maruohon commented 5 years ago

https://github.com/maruohon/tellme/blob/master/src/main/java/fi/dy/masa/tellme/datadump/ItemDump.java#L269

Dammit... some mod still has null ItemStacks since 1.11? nice... :D

LemADEC commented 5 years ago

I wish the crash log would tell me which mod so I can report it to the author

maruohon commented 5 years ago

Yeah I need to add a try-catch in one of the methods to see that (or check for null and change the return value etc. which I don't like for this use case).

maruohon commented 5 years ago

This should now print out some other bits of the tab data as a warning to the console, in case it has null values: https://masa.dy.fi/tmp/minecraft/mods/tellme/tellme-1.12.2-0.7.0-dev.20181219.232652.jar

maruohon commented 5 years ago

Whoops I made a copy paste derp in one of the console messages, fixed version: https://masa.dy.fi/tmp/minecraft/mods/tellme/tellme-1.12.2-0.7.0-dev.20181219.233102.jar

LemADEC commented 5 years ago

Thanks for the quick fix! CreativeTabs are no longer reporting error and console logs are clean. So I guess, TellMe tolerates the null entries now?

maruohon commented 5 years ago

Hmm, it's supposed to print out a one line warning if some of the values for a tab are null, which should be the case in the original crash... But yes it shouldn't crash anymore in the CreativeTabs dump (unless I missed something still).

LemADEC commented 5 years ago

I see the log added:

[23:30:01] [Server thread/WARN] [tellme]: null icon item for tab at index 60 (name: 'tab_matc', translation key: 'itemGroup.tab_matc')
[23:30:01] [Client thread/INFO] [net.minecraft.client.gui.GuiNewChat]: [CHAT] Output written to file creativetabs-csv_2018-12-20_23.30.01.csv

matc being most probably Mystical Agriculture Tiered Crystals, issue reported to the related github.