andrepascoa Posted February 23, 2020 Share Posted February 23, 2020 Hi! I'm building a simple sword where it should count to 5 once every hit and once it hits five starts a cooldown! that logic is still not implemented because I'm having problems saving data inside the ItemStack of the sword in the form of a capability! here's my code, All it does is give me this error Execution failed for task ':runClient', but if I remove the initCapability function inside DickSword.java it doesn't give any error! https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/DickMod.java https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/ForgeEventSubscriber.java https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/objects/items/DickSword.java https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/capabilities/CoolDownCapability.java https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/capabilities/interfaces/ICoolDown.java https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/capabilities/instances/CoolDown.java Quote Link to comment Share on other sites More sharing options...
loordgek Posted February 23, 2020 Share Posted February 23, 2020 https://github.com/MisterProgrammer/DickMod/blob/master/src/main/java/com/example/DickMod/ForgeEventSubscriber.java#L17 you never add you cap to anything 3 hours ago, andrepascoa said: All it does is give me this error Execution failed for task ':runClient', but if I remove the initCapability function inside DickSword.java it doesn't give any error can you post that error Quote Link to comment Share on other sites More sharing options...
andrepascoa Posted February 24, 2020 Author Share Posted February 24, 2020 Okay so I deleted the ForgeEventSubscriber method and added the initCapabilities Override in my Sword, since that's where the error was at, here it is, it's a nullPointerExceptio in the instance part [14:47:35] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:109]: ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 24/02/20 14:47 Description: Initializing game java.lang.NullPointerException: Initializing game at com.example.DickMod.capabilities.CoolDownCapability.<init>(CoolDownCapability.java:19) ~[main/:?] {re:classloading,pl:capability_inject_definalize:A} at com.example.DickMod.objects.items.DickSword.initCapabilities(DickSword.java:75) ~[main/:?] {re:classloading} at net.minecraft.item.ItemStack.forgeInit(ItemStack.java:1072) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.item.ItemStack.<init>(ItemStack.java:109) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.item.ItemStack.<init>(ItemStack.java:98) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.item.ItemStack.<init>(ItemStack.java:95) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading} at net.minecraft.item.Item.fillItemGroup(Item.java:403) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B} at net.minecraft.client.Minecraft.populateSearchTreeManager(Minecraft.java:600) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.<init>(Minecraft.java:435) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:141) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_221] {} at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_221] {} at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_221] {} at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_221] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:55) ~[forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:81) [modlauncher-5.0.0-milestone.4.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:65) [modlauncher-5.0.0-milestone.4.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:102) [forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Render thread Stacktrace: at com.example.DickMod.capabilities.CoolDownCapability.<init>(CoolDownCapability.java:19) at com.example.DickMod.objects.items.DickSword.initCapabilities(DickSword.java:75) at net.minecraft.item.ItemStack.forgeInit(ItemStack.java:1072) at net.minecraft.item.ItemStack.<init>(ItemStack.java:109) at net.minecraft.item.ItemStack.<init>(ItemStack.java:98) at net.minecraft.item.ItemStack.<init>(ItemStack.java:95) at net.minecraft.item.Item.fillItemGroup(Item.java:403) at net.minecraft.client.Minecraft.populateSearchTreeManager(Minecraft.java:600) at net.minecraft.client.Minecraft.<init>(Minecraft.java:435) -- Initialization -- Details: Stacktrace: at net.minecraft.client.main.Main.main(Main.java:141) 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:498) 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:102) -- 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_221, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 393818280 bytes (375 MB) / 964165632 bytes (919 MB) up to 1420820480 bytes (1355 MB) CPUs: 8 JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump ModLauncher: 5.0.0-milestone.4+67+b1a340b ModLauncher launch target: fmluserdevclient ModLauncher naming: mcp ModLauncher services: /eventbus-2.0.0-milestone.1-service.jar eventbus PLUGINSERVICE /forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-launcher.jar object_holder_definalize PLUGINSERVICE /forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-launcher.jar runtime_enum_extender PLUGINSERVICE /accesstransformers-2.0.0-milestone.1-shadowed.jar accesstransformer PLUGINSERVICE /forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-launcher.jar capability_inject_definalize PLUGINSERVICE /forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-launcher.jar runtimedistcleaner PLUGINSERVICE /forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-launcher.jar fml TRANSFORMATIONSERVICE FML: 31.1 Forge: net.minecraftforge:31.1.14 FML Language Providers: javafml@31.1 minecraft@1 Mod List: client-extra.jar Minecraft {minecraft@1.15.2 COMMON_SETUP} main Dick Mod {dick_mod@1.0.0 COMMON_SETUP} forge-1.15.2-31.1.14_mapped_snapshot_20190719-1.14.3-recomp.jar Forge {forge@31.1.14 COMMON_SETUP} Launched Version: MOD_DEV Backend library: LWJGL version 3.2.2 build 10 Backend API: AMD Radeon(TM) Vega 8 Graphics GL version 4.5.13541 Compatibility Profile Context 25.20.14146.3004, ATI Technologies Inc. GL Caps: Using framebuffer using OpenGL 3.0 Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'forge' Type: Client (map_client.txt) CPU: 8x AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx [14:47:35] [Render thread/INFO] [STDOUT/]: [net.minecraft.util.registry.Bootstrap:printToSYSOUT:109]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\andrepascoa\Google Drive\DickMod\run\.\crash-reports\crash-2020-02-24_14.47.35-client.txt > Task :runClient FAILED Execution failed for task ':runClient'. > Process 'command 'C:\Program Files\Java\jdk1.8.0_221\bin\java.exe'' finished with non-zero exit value -1 Quote Link to comment Share on other sites More sharing options...
andrepascoa Posted February 24, 2020 Author Share Posted February 24, 2020 I have now managed to remove the error with a simple null check, although it's probably not the right solution, the capability is now present based on the isPresent() method, but whenever I try changing it with the following code it doesn't do anything! if (CoolDownCapability.CAPABILITY_COOLDOWN != null) { stack.getCapability(CoolDownCapability.CAPABILITY_COOLDOWN).ifPresent(cap -> { if (cap.getCount() >= 5) { DickMod.LOGGER.debug("ReachedLimit!"); } else { cap.setCount(cap.getCount() + 1); DickMod.LOGGER.debug("Adding to count" + cap.getCount()); } }); } Quote Link to comment Share on other sites More sharing options...
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.