Awsome Posted August 13, 2020 Posted August 13, 2020 I'm trying to make a custom capability wrapper for an item that stores a fluid and my game crashes when writing the capability data to NBT. Crash Report: ---- Minecraft Crash Report ---- // My bad. Time: 8/12/20 6:49 PM Description: mouseClicked event handler java.lang.NullPointerException: mouseClicked event handler at net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack.getFluid(FluidHandlerItemStack.java:76) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at awsome.techmod.capability.MoldCapabilityWrapper.serializeNBT(MoldCapabilityWrapper.java:39) ~[main/:?] {re:classloading} at awsome.techmod.capability.MoldCapabilityWrapper.serializeNBT(MoldCapabilityWrapper.java:1) ~[main/:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityDispatcher.serializeNBT(CapabilityDispatcher.java:127) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraftforge.common.capabilities.CapabilityProvider.serializeCaps(CapabilityProvider.java:86) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraft.item.ItemStack.copy(ItemStack.java:375) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading} at net.minecraft.client.gui.screen.inventory.CreativeScreen.handleMouseClick(CreativeScreen.java:191) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseClicked(ContainerScreen.java:341) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.inventory.CreativeScreen.mouseClicked(CreativeScreen.java:443) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:87) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:446) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:85) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:173) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:172) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {} at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {} at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:85) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.MainWindow.flipFrame(MainWindow.java:296) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:983) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:558) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:177) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_162] {} at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_162] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_162] {} at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_162] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.1.2.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.1.2.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.1.2.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.1.2.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.1.2.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack.getFluid(FluidHandlerItemStack.java:76) at awsome.techmod.capability.MoldCapabilityWrapper.serializeNBT(MoldCapabilityWrapper.java:39) at awsome.techmod.capability.MoldCapabilityWrapper.serializeNBT(MoldCapabilityWrapper.java:1) at net.minecraftforge.common.capabilities.CapabilityDispatcher.serializeNBT(CapabilityDispatcher.java:127) at net.minecraftforge.common.capabilities.CapabilityProvider.serializeCaps(CapabilityProvider.java:86) at net.minecraft.item.ItemStack.copy(ItemStack.java:375) at net.minecraft.client.gui.screen.inventory.CreativeScreen.handleMouseClick(CreativeScreen.java:191) at net.minecraft.client.gui.screen.inventory.ContainerScreen.mouseClicked(ContainerScreen.java:341) at net.minecraft.client.gui.screen.inventory.CreativeScreen.mouseClicked(CreativeScreen.java:443) at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:87) -- Affected screen -- Details: Screen name: net.minecraft.client.gui.screen.inventory.CreativeScreen Stacktrace: at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:446) at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:85) at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:173) at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:172) at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) at org.lwjgl.system.JNI.invokeV(Native Method) at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:85) -- Affected level -- Details: All players: 1 total; [ClientPlayerEntity['Awsomekeldeo'/34, l='MpServer', x=-989.35, y=69.00, z=-29.36]] Chunk stats: Client Chunk Cache: 841, 447 Level dimension: DimensionType{minecraft:overworld} Level name: MpServer Level seed: 322288368513725192 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: {} Level spawn location: World: (256,72,144), Chunk: (at 0,4,0 in 16,9; contains blocks 256,0,144 to 271,255,159), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 96693 game time, 30187 day time Known server brands: Level was modded: false Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Server brand: forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.world.ClientWorld.fillCrashReport(ClientWorld.java:457) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:1839) at net.minecraft.client.Minecraft.run(Minecraft.java:572) at net.minecraft.client.main.Main.main(Main.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) -- System Details -- Details: Minecraft Version: 1.15.2 Minecraft Version ID: 1.15.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_162, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 455283944 bytes (434 MB) / 1143472128 bytes (1090 MB) up to 1908932608 bytes (1820 MB) CPUs: 2 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 5.1.2+70+master.2845bb9 ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /eventbus-2.2.0-service.jar eventbus PLUGINSERVICE /forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.1.3-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-launcher.jar runtimedistcleaner PLUGINSERVICE /forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-launcher.jar fml TRANSFORMATIONSERVICE FML: 31.2 Forge: net.minecraftforge:31.2.31 FML Language Providers: [email protected] minecraft@1 Mod List: client-extra.jar Minecraft {[email protected] DONE} forge-1.15.2-31.2.31_mapped_snapshot_20200514-1.15.1-recomp.jar Forge {[email protected] DONE} main Untitled Tech Mod {[email protected] DONE} Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: GeForce GTX 1050/PCIe/SSE2 GL version 4.6.0 NVIDIA 451.67, NVIDIA Corporation GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) Resource Packs: vanilla, mod_resources, file/§9[§5§lTMoTF§9] §f- §eResource Pack§2 v1.03 (incompatible) Current Language: English (US) CPU: 2x Pentium(R) Dual-Core CPU E5700 @ 3.00GHz Source: Item Capability Wrapper: https://github.com/Awsomekeldeo/TechMod/blob/test/src/main/java/awsome/techmod/capability/MoldCapabilityWrapper.java Item Class: https://github.com/Awsomekeldeo/TechMod/blob/test/src/main/java/awsome/techmod/items/CeramicMoldItem.java Quote
Draco18s Posted August 13, 2020 Posted August 13, 2020 (edited) By the way this line will never be false: https://github.com/Awsomekeldeo/TechMod/blob/test/src/main/java/awsome/techmod/capability/MoldCapabilityWrapper.java#L38 Because fluidHandler always has a value: https://github.com/Awsomekeldeo/TechMod/blob/test/src/main/java/awsome/techmod/capability/MoldCapabilityWrapper.java#L19 Never return null from getCapability https://github.com/Awsomekeldeo/TechMod/blob/test/src/main/java/awsome/techmod/capability/MoldCapabilityWrapper.java#L32 Use LazyOptional.empty Edited August 13, 2020 by Draco18s Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
ChampionAsh5357 Posted August 13, 2020 Posted August 13, 2020 Yes, global initializers always go so well, especially when passing in uninitialized variables. Same thing goes for here too. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.