Posted July 9, 201411 yr I followed the tutorial in the minecraftforge wiki and it crashes my game with a NullPointerException... Crash ---- Minecraft Crash Report ---- // Surprise! Haha. Well, this is awkward. Time: 09/07/14 19.06 Description: Unexpected error java.lang.NullPointerException: Unexpected error at com.gjkf.key.KeyInputHandler.onKeyInput(KeyInputHandler.java:12) at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_KeyInputHandler_onKeyInput_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:539) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1931) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:997) at net.minecraft.client.Minecraft.run(Minecraft.java:912) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.gjkf.key.KeyInputHandler.onKeyInput(KeyInputHandler.java:14) at cpw.mods.fml.common.eventhandler.ASMEventHandler_5_KeyInputHandler_onKeyInput_KeyInputEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:51) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:122) at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:539) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['Player77'/359, l='MpServer', x=206,50, y=64,62, z=16,50]] Chunk stats: MultiplayerChunkCache: 225, 225 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (204,64,, Chunk: (at 12,4,8 in 12,0; contains blocks 192,0,0 to 207,255,15), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Level time: 693 game time, 693 day time Level dimension: 0 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 Forced entities: 118 total; [EntitySheep['Sheep'/275, l='MpServer', x=268,50, y=84,00, z=-20,50], EntitySheep['Sheep'/279, l='MpServer', x=263,50, y=67,00, z=28,50], EntitySheep['Sheep'/278, l='MpServer', x=263,50, y=72,00, z=31,50], EntitySheep['Sheep'/277, l='MpServer', x=269,78, y=84,00, z=-0,53], EntitySheep['Sheep'/276, l='MpServer', x=270,50, y=87,00, z=-17,50], EntitySheep['Sheep'/282, l='MpServer', x=260,78, y=67,00, z=94,69], EntitySheep['Sheep'/281, l='MpServer', x=257,56, y=64,00, z=33,44], EntitySheep['Sheep'/280, l='MpServer', x=261,50, y=65,00, z=29,50], EntitySheep['Sheep'/258, l='MpServer', x=243,16, y=85,00, z=-58,03], EntitySheep['Sheep'/259, l='MpServer', x=240,50, y=81,00, z=-61,50], EntitySheep['Sheep'/256, l='MpServer', x=241,53, y=78,00, z=-53,58], EntitySheep['Sheep'/257, l='MpServer', x=241,16, y=85,00, z=-57,31], EntitySheep['Sheep'/260, l='MpServer', x=247,69, y=68,00, z=85,73], EntitySheep['Sheep'/261, l='MpServer', x=249,06, y=66,00, z=91,06], EntityBat['Bat'/304, l='MpServer', x=281,43, y=25,00, z=37,59], EntitySheep['Sheep'/292, l='MpServer', x=274,50, y=87,00, z=-16,50], EntitySheep['Sheep'/293, l='MpServer', x=273,50, y=84,00, z=-19,50], EntitySheep['Sheep'/295, l='MpServer', x=286,38, y=80,00, z=-19,53], EntitySheep['Sheep'/296, l='MpServer', x=282,78, y=81,00, z=-24,28], EntitySheep['Sheep'/297, l='MpServer', x=279,47, y=81,00, z=-24,22], EntitySheep['Sheep'/298, l='MpServer', x=279,16, y=82,00, z=-30,31], EntitySheep['Sheep'/299, l='MpServer', x=272,50, y=83,00, z=-0,50], EntitySheep['Sheep'/300, l='MpServer', x=278,47, y=90,00, z=-6,70], EntitySheep['Sheep'/301, l='MpServer', x=274,50, y=87,00, z=2,50], EntitySheep['Sheep'/302, l='MpServer', x=272,81, y=80,00, z=5,47], EntityCreeper['Creeper'/303, l='MpServer', x=286,97, y=47,00, z=23,50], EntityVillager['Villager'/85, l='MpServer', x=136,25, y=73,00, z=20,97], EntityVillager['Villager'/84, l='MpServer', x=142,31, y=72,00, z=21,31], EntityVillager['Villager'/87, l='MpServer', x=130,38, y=74,00, z=21,16], EntityVillager['Villager'/86, l='MpServer', x=129,41, y=74,00, z=16,26], EntityVillager['Villager'/81, l='MpServer', x=140,71, y=73,00, z=-2,47], EntityVillager['Villager'/80, l='MpServer', x=131,99, y=72,00, z=-5,80], EntityVillager['Villager'/83, l='MpServer', x=134,94, y=74,50, z=15,50], EntityVillager['Villager'/82, l='MpServer', x=141,76, y=73,00, z=-1,50], EntityChicken['Chicken'/92, l='MpServer', x=143,50, y=71,00, z=64,50], EntityZombie['Zombie'/89, l='MpServer', x=133,56, y=30,00, z=37,00], EntityVillager['Villager'/88, l='MpServer', x=133,63, y=74,00, z=16,22], EntityBat['Bat'/91, l='MpServer', x=145,40, y=45,87, z=71,44], EntityChicken['Chicken'/90, l='MpServer', x=141,56, y=71,00, z=61,42], EntityVillager['Villager'/110, l='MpServer', x=144,50, y=73,00, z=2,25], EntityVillager['Villager'/111, l='MpServer', x=144,24, y=73,00, z=-0,69], EntityVillager['Villager'/108, l='MpServer', x=154,72, y=73,00, z=6,44], EntityVillager['Villager'/109, l='MpServer', x=146,10, y=72,00, z=5,92], EntityItem['item.item.seeds'/106, l='MpServer', x=156,97, y=74,13, z=-2,22], EntityVillager['Villager'/107, l='MpServer', x=153,34, y=73,00, z=4,47], EntityBat['Bat'/105, l='MpServer', x=159,47, y=21,75, z=-11,03], EntityCreeper['Creeper'/119, l='MpServer', x=152,34, y=35,00, z=60,25], EntityZombie['Zombie'/118, l='MpServer', x=146,50, y=40,00, z=55,50], EntityItem['item.item.seeds'/117, l='MpServer', x=145,13, y=31,13, z=41,16], EntityVillager['Villager'/116, l='MpServer', x=159,69, y=72,00, z=31,66], EntityVillager['Villager'/115, l='MpServer', x=158,63, y=72,00, z=31,22], EntityVillager['Villager'/114, l='MpServer', x=153,88, y=72,00, z=28,91], EntityVillager['Villager'/113, l='MpServer', x=152,94, y=72,00, z=27,94], EntityVillager['Villager'/112, l='MpServer', x=159,75, y=72,00, z=30,41], EntityChicken['Chicken'/123, l='MpServer', x=144,56, y=71,00, z=63,56], EntityClientPlayerMP['Player77'/359, l='MpServer', x=206,50, y=64,62, z=16,50], EntityChicken['Chicken'/122, l='MpServer', x=146,63, y=71,00, z=58,88], EntityCreeper['Creeper'/121, l='MpServer', x=145,28, y=50,00, z=59,31], EntityBat['Bat'/120, l='MpServer', x=151,50, y=37,62, z=60,50], EntitySpider['Spider'/137, l='MpServer', x=163,59, y=46,00, z=-40,38], EntityZombie['Zombie'/136, l='MpServer', x=165,63, y=45,47, z=-40,53], EntityChicken['Chicken'/139, l='MpServer', x=166,41, y=76,00, z=21,44], EntityChicken['Chicken'/138, l='MpServer', x=165,75, y=76,00, z=21,89], EntityChicken['Chicken'/141, l='MpServer', x=174,03, y=72,00, z=28,94], EntityChicken['Chicken'/140, l='MpServer', x=163,53, y=76,00, z=22,47], EntityVillager['Villager'/143, l='MpServer', x=159,93, y=72,00, z=27,50], EntityChicken['Chicken'/142, l='MpServer', x=171,44, y=71,00, z=25,66], EntityBat['Bat'/135, l='MpServer', x=175,32, y=12,02, z=-52,65], EntitySkeleton['Skeleton'/144, l='MpServer', x=166,50, y=7,00, z=64,50], EntitySheep['Sheep'/148, l='MpServer', x=167,94, y=63,00, z=95,97], EntityItem['item.item.seeds'/171, l='MpServer', x=187,09, y=63,13, z=26,38], EntityBat['Bat'/170, l='MpServer', x=189,28, y=27,00, z=24,37], EntitySkeleton['Skeleton'/169, l='MpServer', x=178,88, y=29,00, z=24,50], EntitySkeleton['Skeleton'/168, l='MpServer', x=190,38, y=27,00, z=24,84], EntityChicken['Chicken'/174, l='MpServer', x=175,53, y=71,00, z=34,70], EntityChicken['Chicken'/173, l='MpServer', x=179,74, y=66,00, z=23,60], EntityChicken['Chicken'/172, l='MpServer', x=188,84, y=63,31, z=25,56], EntitySkeleton['Skeleton'/167, l='MpServer', x=191,44, y=27,00, z=25,57], EntitySkeleton['Skeleton'/166, l='MpServer', x=183,16, y=31,00, z=-26,56], EntitySheep['Sheep'/190, l='MpServer', x=196,50, y=75,00, z=-21,50], EntitySheep['Sheep'/191, l='MpServer', x=196,53, y=78,00, z=-27,41], EntityCreeper['Creeper'/188, l='MpServer', x=194,50, y=53,00, z=-58,50], EntitySheep['Sheep'/189, l='MpServer', x=194,47, y=73,00, z=-17,53], EntitySkeleton['Skeleton'/197, l='MpServer', x=199,53, y=27,00, z=22,94], EntityChicken['Chicken'/196, l='MpServer', x=195,41, y=73,00, z=-15,44], EntityCreeper['Creeper'/199, l='MpServer', x=206,50, y=11,00, z=55,50], EntitySkeleton['Skeleton'/198, l='MpServer', x=201,47, y=27,00, z=28,50], EntityChicken['Chicken'/193, l='MpServer', x=195,34, y=72,00, z=-10,34], EntitySheep['Sheep'/192, l='MpServer', x=192,56, y=75,00, z=-22,53], EntityChicken['Chicken'/195, l='MpServer', x=196,25, y=72,00, z=-11,31], EntityChicken['Chicken'/194, l='MpServer', x=199,47, y=72,00, z=-2,53], EntitySheep['Sheep'/220, l='MpServer', x=219,22, y=71,00, z=-6,50], EntitySheep['Sheep'/221, l='MpServer', x=216,50, y=80,00, z=-12,50], EntityZombie['Zombie'/222, l='MpServer', x=214,06, y=12,00, z=27,56], EntityPig['Pig'/223, l='MpServer', x=217,16, y=63,00, z=31,25], EntitySkeleton['Skeleton'/216, l='MpServer', x=222,50, y=52,00, z=-51,50], EntityBat['Bat'/217, l='MpServer', x=228,34, y=48,68, z=-39,62], EntitySheep['Sheep'/218, l='MpServer', x=222,50, y=72,00, z=-14,50], EntitySheep['Sheep'/219, l='MpServer', x=218,50, y=72,00, z=-13,50], EntityCreeper['Creeper'/212, l='MpServer', x=209,50, y=27,00, z=-60,50], EntityZombie['Zombie'/213, l='MpServer', x=219,44, y=53,00, z=-63,63], EntityZombie['Zombie'/214, l='MpServer', x=208,53, y=56,00, z=-57,31], EntitySpider['Spider'/215, l='MpServer', x=219,28, y=52,00, z=-56,44], EntitySkeleton['Skeleton'/239, l='MpServer', x=225,50, y=49,00, z=-41,50], EntityCreeper['Creeper'/238, l='MpServer', x=226,28, y=51,00, z=-59,06], EntityZombie['Zombie'/228, l='MpServer', x=210,50, y=12,00, z=63,09], EntityPig['Pig'/227, l='MpServer', x=222,96, y=64,00, z=32,82], EntityChicken['Chicken'/226, l='MpServer', x=219,84, y=62,42, z=38,78], EntityPig['Pig'/225, l='MpServer', x=218,53, y=63,00, z=32,57], EntityPig['Pig'/224, l='MpServer', x=214,53, y=65,00, z=24,44], EntityBat['Bat'/255, l='MpServer', x=243,39, y=34,77, z=-50,79], EntityChicken['Chicken'/246, l='MpServer', x=226,41, y=65,00, z=34,38], EntityChicken['Chicken'/244, l='MpServer', x=227,81, y=68,00, z=32,97], EntityChicken['Chicken'/245, l='MpServer', x=239,53, y=70,00, z=37,53], EntityItem['item.item.arrow'/242, l='MpServer', x=228,88, y=23,13, z=24,13], EntityItem['item.item.bone'/243, l='MpServer', x=226,13, y=24,13, z=24,13], EntitySkeleton['Skeleton'/240, l='MpServer', x=233,09, y=48,00, z=-38,59], EntityEnderman['Enderman'/241, l='MpServer', x=234,00, y=48,00, z=-41,69]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:412) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2524) at net.minecraft.client.Minecraft.run(Minecraft.java:941) at net.minecraft.client.main.Main.main(Main.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) -- System Details -- Details: Minecraft Version: 1.7.2 Operating System: Mac OS X (x86_64) version 10.7.5 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 799422528 bytes (762 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 14803 (828968 bytes; 0 MB) allocated, 2 (112 bytes; 0 MB) used IntCache: cache: 13, tcache: 0, allocated: 13, tallocated: 95 FML: MCP v9.03 FML v7.2.217.1147 Minecraft Forge 10.12.2.1147 4 mods loaded, 4 mods active mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{7.2.217.1147} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.2.1147.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{10.12.2.1147} [Minecraft Forge] (forgeSrc-1.7.2-10.12.2.1147.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available VSHS{0.3} [Vertical Slabs & Horizontal Stairs] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Launched Version: 1.6 LWJGL: 2.9.1 OpenGL: NVIDIA GeForce 9400M OpenGL Engine GL version 2.1 NVIDIA-7.32.12, NVIDIA Corporation Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) Vec3 Pool Size: 1117 (62552 bytes; 0 MB) allocated, 20 (1120 bytes; 0 MB) used Anisotropic Filtering: Off (1) KeyBind Class package com.gjkf.key; import org.lwjgl.input.Keyboard; import cpw.mods.fml.client.registry.ClientRegistry; import net.minecraft.client.settings.KeyBinding; public class KeyBind { public static KeyBinding rotate; public static void init(){ rotate = new KeyBinding("rotate", Keyboard.KEY_LMETA, "key.categories.inventory"); ClientRegistry.registerKeyBinding(rotate); } } KeyInputHandler Class package com.gjkf.key; import org.lwjgl.input.Keyboard; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent; public class KeyInputHandler { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event){ if(KeyBind.rotate.isPressed()){ System.err.println("Test"); } } } "I an atom in the universe, a universe of atoms"-- Richard P. Feynman
July 9, 201411 yr Author Where should I do that? I have in the init() method of my Main Class this "FMLCommonHandler.instance().bus().register(new KeyInputHandler());" otherwise I don't think I never call it anywhere. "I an atom in the universe, a universe of atoms"-- Richard P. Feynman
July 9, 201411 yr It's in your main mod class @EventHandler public void load(FMLInitializationEvent event) { KeyBind.init(); }
July 9, 201411 yr Author Thank you very much, now it's working smoothly. Didn't know that you needed to call that method. Thanks again. "I an atom in the universe, a universe of atoms"-- Richard P. Feynman
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.