Cavern2 icon indicating copy to clipboard operation
Cavern2 copied to clipboard

Fix a Crash Problem + Misspelle

Open UID-503058116 opened this issue 11 months ago • 0 comments

Crash Problem:

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Cavern II (cavern) Caused by: java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "name" is null at cavern.block.RandomiteHelper.refreshItems(RandomiteHelper.java:42) at cavern.core.Cavern.onServerStarting(Cavern.java:335) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.lang.reflect.Method.invoke(Method.java:580) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:639) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.lang.reflect.Method.invoke(Method.java:580) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:85) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:142) at com.google.common.eventbus.Subscriber.lambda$dispatchEvent$0(Subscriber.java:71) at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:68) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:111) at com.google.common.eventbus.EventBus.post(EventBus.java:270) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:283) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:261) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.lang.reflect.Method.invoke(Method.java:580) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:85) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:142) at com.google.common.eventbus.Subscriber.lambda$dispatchEvent$0(Subscriber.java:71) at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:68) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:111) at com.google.common.eventbus.EventBus.post(EventBus.java:270) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:197) at net.minecraftforge.fml.common.Loader.serverStarting(Loader.java:802) at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarting(FMLCommonHandler.java:298) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.lang.reflect.Method.invoke(Method.java:580) at net.optifine.reflect.Reflector.callBoolean(Reflector.java:857) at net.minecraft.server.integrated.IntegratedServer.init(IntegratedServer.java:241) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486) at java.lang.Thread.run(Thread.java:1583)

崩溃原因分析 异常发生在cavern.block.RandomiteHelper.refreshItems方法的第42行,尝试调用String.startsWith()时变量name为null。 代码可能试图检查物品注册名(Registry Name)是否以特定前缀(如"cavern:")开头,但未对name进行空值检查。 某个物品的注册名未被正确赋值(item.getRegistryName()返回null),而Cavern II模组未对此情况进行防御性检查,导致空指针异常。需在代码中增加空值检查。

So we did. And another problem:

Snipaste_2025-02-03_05-33-47 错误原因是 IHumidityTile 接口中要求实现 getHumidity 方法,但代码中错误地将方法名拼写为 getHumdiity(多了一个 i)

Fixed.

That's all. Powered by DeepSeek.

UID-503058116 avatar Feb 02 '25 21:02 UID-503058116