Jump to content

Recommended Posts

Posted

Whenever I press a key in minecraft I get "Exception caught during firing event cpw.mods.fml.common.gameevent.InputEvent$KeyInputEvent@c92d089:

java.lang.NullPointerException"

 

My KeyBindings class:

public class KeyBindings extends ClientRegistry
{
public static KeyBinding GunSound;
public Minecraft mc = Minecraft.getMinecraft();

public static void init()
{
	GunSound = new KeyBinding("key.playerDeath", Keyboard.KEY_DOWN, "key.categories.playerDeath");

	ClientRegistry.registerKeyBinding(GunSound);
}

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event)
{
		if(GunSound.isPressed()){
			EntityPlayer player = mc.thePlayer;

			soundHandler.onEntityPlay("gun", mc.thePlayer.worldObj, mc.thePlayer, 1, 1);
					}
	}

}

Posted

Try this, worked for me!

 

Keybindings Class:

 

package com.deb.debmodularships;

import net.minecraft.client.settings.KeyBinding;

import org.lwjgl.input.Keyboard;

import cpw.mods.fml.client.registry.ClientRegistry;

public class ModularshipsKEYBINDS {
public static KeyBinding SpeedUp;

    public static void init() {
    	SpeedUp = new KeyBinding("key.SpeedUp", 201, "DEB.modularships.SpeedUp");//pg_up

        ClientRegistry.registerKeyBinding(SpeedUp);
    }
}

 

Key Event

 

package com.deb.debmodularships;

import net.minecraft.client.Minecraft;

import com.deb.debmodularships.entities.EntityShipSeat;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;

public class ModularshipsINPUT {

@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {

}
}

 

Call Keybind init method and "FMLCommonHandler.instance().bus().register(new ModularshipsINPUT());"

from ClientProxy

 

I basically just copied these from my mod, change all the names to whatever you want!

 

P.S. the Event triggers for all keys, make sure to check for the one you want!

Posted

still keeps crashing!

 

my main class:

@Mod(modid = Main.MODID, version = Main.VERSION)
public class Main
{
    public static final String MODID = "kickback";
    public static final String VERSION = "1.0";
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {    	
        Configuration config = new Configuration(event.getSuggestedConfigurationFile());
        config.load();
        Property automated = config.get(Configuration.CATEGORY_GENERAL, "automated", false, "false = manual, true = when someone dies");
        config.save();
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event){
    	MinecraftForge.EVENT_BUS.register(new playerDeath());
    	FMLCommonHandler.instance().bus().register(new KeyBindings()); 
}
    

    
}

 

 

My keybindings class:

public class KeyBindings {
public static KeyBinding gunSound;

public Minecraft mc = Minecraft.getMinecraft();
EntityPlayer player = mc.thePlayer;

    public static void init() {
        gunSound = new KeyBinding("key.gunSound", Keyboard.KEY_DOWN, "key.categories.misc");

        ClientRegistry.registerKeyBinding(gunSound);
    }
    
    @SubscribeEvent
    public void onKeyInput(InputEvent.KeyInputEvent event) {
        if(KeyBindings.gunSound.isPressed())
            System.out.println("ping");
    }
}

Posted

Crash Report:

 

 

---- Minecraft Crash Report ----

// I bet Cylons wouldn't have this problem.

 

Time: 11/15/14 9:34 PM

Description: Unexpected error

 

java.lang.NullPointerException: Unexpected error

at tiffit.kickbackmod.KeyBindings.onKeyInput(KeyBindings.java:30)

at cpw.mods.fml.common.eventhandler.ASMEventHandler_7_KeyBindings_onKeyInput_KeyInputEvent.invoke(.dynamic)

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)

at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1953)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1028)

at net.minecraft.client.Minecraft.run(Minecraft.java:951)

at net.minecraft.client.main.Main.main(Main.java:164)

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:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78)

at GradleStart.main(GradleStart.java:45)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at tiffit.kickbackmod.KeyBindings.onKeyInput(KeyBindings.java:30)

at cpw.mods.fml.common.eventhandler.ASMEventHandler_7_KeyBindings_onKeyInput_KeyInputEvent.invoke(.dynamic)

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)

at cpw.mods.fml.common.FMLCommonHandler.fireKeyInput(FMLCommonHandler.java:540)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityClientPlayerMP['Player17'/368, l='MpServer', x=-160.25, y=72.62, z=270.55]]

Chunk stats: MultiplayerChunkCache: 210, 210

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: World: (-131,64,254), Chunk: (at 13,4,14 in -9,15; contains blocks -144,0,240 to -129,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 18601 game time, 5772 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: 112 total; [EntityCow['Cow'/275, l='MpServer', x=-90.47, y=67.00, z=344.53], EntityCow['Cow'/274, l='MpServer', x=-91.50, y=69.00, z=346.56], EntityCow['Cow'/273, l='MpServer', x=-93.31, y=66.00, z=341.44], EntityCow['Cow'/272, l='MpServer', x=-92.28, y=63.00, z=331.28], EntityCow['Cow'/258, l='MpServer', x=-85.88, y=68.00, z=210.06], EntityBat['Bat'/259, l='MpServer', x=-99.92, y=51.04, z=235.33], EntityZombie['Zombie'/262, l='MpServer', x=-91.50, y=27.00, z=278.38], EntityZombie['Zombie'/263, l='MpServer', x=-87.16, y=25.00, z=272.82], EntityCow['Cow'/260, l='MpServer', x=-86.47, y=64.00, z=245.88], EntityChicken['Chicken'/261, l='MpServer', x=-95.59, y=68.45, z=266.16], EntityChicken['Chicken'/266, l='MpServer', x=-82.56, y=71.00, z=294.41], EntityZombie['Zombie'/267, l='MpServer', x=-90.69, y=19.00, z=305.53], EntityCreeper['Creeper'/264, l='MpServer', x=-84.47, y=26.00, z=272.03], EntitySkeleton['Skeleton'/265, l='MpServer', x=-81.50, y=34.00, z=299.50], EntityZombie['Zombie'/270, l='MpServer', x=-83.00, y=35.00, z=305.56], EntityZombie['Zombie'/268, l='MpServer', x=-83.06, y=17.00, z=310.41], EntitySlime['Slime'/269, l='MpServer', x=-95.56, y=20.00, z=304.63], EntityZombie['Zombie'/66, l='MpServer', x=-240.22, y=38.00, z=253.63], EntitySkeleton['Skeleton'/85, l='MpServer', x=-227.78, y=59.00, z=216.25], EntityZombie['Zombie'/84, l='MpServer', x=-224.31, y=33.77, z=212.87], EntitySkeleton['Skeleton'/87, l='MpServer', x=-233.13, y=59.00, z=223.34], EntitySheep['Sheep'/86, l='MpServer', x=-229.25, y=63.00, z=215.81], EntitySkeleton['Skeleton'/83, l='MpServer', x=-231.50, y=28.00, z=201.50], EntitySheep['Sheep'/89, l='MpServer', x=-227.56, y=66.00, z=346.91], EntitySheep['Sheep'/88, l='MpServer', x=-226.84, y=66.00, z=349.78], EntitySheep['Sheep'/102, l='MpServer', x=-217.06, y=63.00, z=206.13], EntityEnderman['Enderman'/103, l='MpServer', x=-210.56, y=23.00, z=210.63], EntityCreeper['Creeper'/101, l='MpServer', x=-209.56, y=17.00, z=193.56], EntitySheep['Sheep'/110, l='MpServer', x=-217.63, y=65.00, z=239.81], EntitySheep['Sheep'/111, l='MpServer', x=-215.47, y=70.00, z=344.47], EntityCreeper['Creeper'/108, l='MpServer', x=-209.09, y=30.00, z=224.84], EntitySkeleton['Skeleton'/109, l='MpServer', x=-214.72, y=34.00, z=228.13], EntitySkeleton['Skeleton'/106, l='MpServer', x=-220.44, y=29.00, z=228.94], EntitySkeleton['Skeleton'/107, l='MpServer', x=-215.78, y=29.00, z=232.47], EntityBat['Bat'/104, l='MpServer', x=-211.50, y=26.10, z=222.69], EntityCreeper['Creeper'/105, l='MpServer', x=-210.47, y=33.00, z=221.53], EntitySheep['Sheep'/112, l='MpServer', x=-211.47, y=70.00, z=349.41], EntitySkeleton['Skeleton'/127, l='MpServer', x=-195.50, y=26.00, z=267.69], EntitySkeleton['Skeleton'/126, l='MpServer', x=-201.30, y=27.00, z=267.68], EntitySheep['Sheep'/125, l='MpServer', x=-194.09, y=64.00, z=237.13], EntitySheep['Sheep'/124, l='MpServer', x=-198.19, y=64.00, z=227.94], EntitySheep['Sheep'/123, l='MpServer', x=-194.72, y=63.00, z=198.44], EntityCreeper['Creeper'/122, l='MpServer', x=-194.47, y=17.00, z=195.31], EntityCreeper['Creeper'/121, l='MpServer', x=-192.41, y=17.00, z=195.91], EntityZombie['Zombie'/137, l='MpServer', x=-189.34, y=26.00, z=261.37], EntitySheep['Sheep'/136, l='MpServer', x=-186.13, y=70.00, z=244.91], EntityZombie['Zombie'/139, l='MpServer', x=-191.50, y=27.00, z=311.69], EntitySkeleton['Skeleton'/138, l='MpServer', x=-183.22, y=12.00, z=295.84], EntityCreeper['Creeper'/141, l='MpServer', x=-183.47, y=29.00, z=321.41], EntityZombie['Zombie'/140, l='MpServer', x=-184.28, y=13.00, z=323.88], EntityZombie['Zombie'/142, l='MpServer', x=-188.41, y=32.00, z=331.16], EntitySheep['Sheep'/135, l='MpServer', x=-191.47, y=64.00, z=238.03], EntityBat['Bat'/154, l='MpServer', x=-174.44, y=20.00, z=198.08], EntityBat['Bat'/155, l='MpServer', x=-171.36, y=24.14, z=202.65], EntityClientPlayerMP['Player17'/368, l='MpServer', x=-160.25, y=72.62, z=270.55], EntityZombie['Zombie'/156, l='MpServer', x=-172.78, y=25.00, z=194.72], EntityCreeper['Creeper'/157, l='MpServer', x=-162.59, y=19.00, z=210.97], EntitySheep['Sheep'/158, l='MpServer', x=-172.06, y=63.00, z=217.38], EntitySheep['Sheep'/159, l='MpServer', x=-162.09, y=70.00, z=213.75], EntityCreeper['Creeper'/171, l='MpServer', x=-164.69, y=30.00, z=318.53], EntityCreeper['Creeper'/170, l='MpServer', x=-160.66, y=64.00, z=298.00], EntityCreeper['Creeper'/169, l='MpServer', x=-160.38, y=65.00, z=297.03], EntityCreeper['Creeper'/168, l='MpServer', x=-165.63, y=64.00, z=297.63], EntityCreeper['Creeper'/175, l='MpServer', x=-162.53, y=32.00, z=315.31], EntityZombie['Zombie'/174, l='MpServer', x=-167.41, y=34.00, z=314.00], EntityCreeper['Creeper'/173, l='MpServer', x=-165.22, y=33.00, z=316.53], EntityCreeper['Creeper'/172, l='MpServer', x=-166.50, y=34.00, z=317.50], EntitySheep['Sheep'/163, l='MpServer', x=-175.47, y=70.00, z=240.63], EntitySheep['Sheep'/162, l='MpServer', x=-162.47, y=71.00, z=225.56], EntitySheep['Sheep'/161, l='MpServer', x=-171.72, y=72.00, z=232.50], EntitySheep['Sheep'/160, l='MpServer', x=-174.91, y=63.00, z=224.06], EntityBat['Bat'/167, l='MpServer', x=-161.54, y=17.76, z=275.33], EntityEnderman['Enderman'/166, l='MpServer', x=-167.63, y=16.00, z=278.53], EntitySkeleton['Skeleton'/165, l='MpServer', x=-169.00, y=17.00, z=278.59], EntitySkeleton['Skeleton'/164, l='MpServer', x=-170.35, y=19.00, z=280.12], EntityBat['Bat'/186, l='MpServer', x=-147.40, y=17.71, z=266.17], EntityBat['Bat'/187, l='MpServer', x=-144.81, y=19.00, z=263.68], EntitySheep['Sheep'/184, l='MpServer', x=-159.78, y=63.00, z=209.38], EntityCow['Cow'/185, l='MpServer', x=-159.05, y=75.00, z=229.06], EntityZombie['Zombie'/190, l='MpServer', x=-146.01, y=57.00, z=293.81], EntityCreeper['Creeper'/191, l='MpServer', x=-158.53, y=36.00, z=310.41], EntityBat['Bat'/188, l='MpServer', x=-142.86, y=20.12, z=264.32], EntityZombie['Zombie'/189, l='MpServer', x=-146.46, y=57.00, z=289.37], EntitySheep['Sheep'/176, l='MpServer', x=-160.53, y=72.00, z=344.88], EntityZombie['Zombie'/199, l='MpServer', x=-133.31, y=25.00, z=321.28], EntityCow['Cow'/198, l='MpServer', x=-131.53, y=70.00, z=241.38], EntitySheep['Sheep'/193, l='MpServer', x=-154.69, y=67.00, z=345.84], EntitySheep['Sheep'/192, l='MpServer', x=-153.03, y=75.00, z=309.97], EntitySheep['Sheep'/194, l='MpServer', x=-155.50, y=76.00, z=337.53], EntityCreeper['Creeper'/220, l='MpServer', x=-115.03, y=14.00, z=311.34], EntityCreeper['Creeper'/221, l='MpServer', x=-118.56, y=13.00, z=306.38], EntityZombie['Zombie'/222, l='MpServer', x=-115.78, y=12.00, z=309.53], EntitySkeleton['Skeleton'/223, l='MpServer', x=-115.69, y=11.00, z=306.31], EntityBat['Bat'/216, l='MpServer', x=-119.50, y=44.10, z=260.00], EntitySkeleton['Skeleton'/217, l='MpServer', x=-126.69, y=44.00, z=269.78], EntityCreeper['Creeper'/218, l='MpServer', x=-117.59, y=43.00, z=265.75], EntityCreeper['Creeper'/219, l='MpServer', x=-124.06, y=13.00, z=302.97], EntityCow['Cow'/212, l='MpServer', x=-115.47, y=80.00, z=210.41], EntityCow['Cow'/213, l='MpServer', x=-125.19, y=75.00, z=224.69], EntityBat['Bat'/214, l='MpServer', x=-120.06, y=45.10, z=261.25], EntityBat['Bat'/215, l='MpServer', x=-119.44, y=45.10, z=256.75], EntityCow['Cow'/227, l='MpServer', x=-117.61, y=70.00, z=345.84], EntityBat['Bat'/226, l='MpServer', x=-125.91, y=34.10, z=311.59], EntityBat['Bat'/225, l='MpServer', x=-125.69, y=26.10, z=312.25], EntitySkeleton['Skeleton'/224, l='MpServer', x=-116.50, y=11.00, z=304.13], EntityCow['Cow'/248, l='MpServer', x=-108.25, y=68.00, z=288.31], EntityCow['Cow'/249, l='MpServer', x=-96.78, y=68.00, z=340.28], EntityBat['Bat'/246, l='MpServer', x=-104.39, y=14.03, z=288.02], EntitySkeleton['Skeleton'/247, l='MpServer', x=-110.63, y=41.00, z=273.16], EntityBat['Bat'/244, l='MpServer', x=-109.67, y=15.47, z=278.48], EntityBat['Bat'/245, l='MpServer', x=-108.77, y=19.46, z=276.51], EntityBat['Bat'/243, l='MpServer', x=-96.28, y=52.10, z=235.91]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2555)

at net.minecraft.client.Minecraft.run(Minecraft.java:980)

at net.minecraft.client.main.Main.main(Main.java:164)

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:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78)

at GradleStart.main(GradleStart.java:45)

 

-- System Details --

Details:

Minecraft Version: 1.7.10

Operating System: Mac OS X (x86_64) version 10.10

Java Version: 1.7.0_45, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 703425072 bytes (670 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95

FML: MCP v9.05 FML v7.10.85.1230 Minecraft Forge 10.13.2.1230 4 mods loaded, 4 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

FML{7.10.85.1230} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Forge{10.13.2.1230} [Minecraft Forge] (forgeSrc-1.7.10-10.13.2.1230.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

kickback{1.0} [kickback] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available

Launched Version: 1.7.10

LWJGL: 2.9.1

OpenGL: Intel HD Graphics 4000 OpenGL Engine GL version 2.1 INTEL-10.0.86, Intel Inc.

GL Caps: Using GL 1.3 multitexturing.

Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported.

Anisotropic filtering is supported and maximum anisotropy is 16.

Shaders are available because OpenGL 2.1 is supported.

 

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: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

Anisotropic Filtering: Off (1)

 

 

Posted

Follow these steps:

 

Put the event in its own class

Delete "FMLCommonHandler.instance().bus().register(new KeyBindings());"

Set up proxies: http://www.minecraftforge.net/wiki/Proxies (Old but looks like mine)

Make a method in both proxy classes called KeyBindings (exactly same name and inputs if any)

Put "FMLCommonHandler.instance().bus().register(new NameOfEventClass());" and "KeyBindings.init();" into the method in the CLIENT proxy

 

If it doesn't work, make sure to send all classes and the crash report.

Posted

I nowhere see you calling your init() method in KeyBindings, if you don't call this method, GunSound will not be initialisated and null.

So if you use gunsound.isPressedd(), gunsound is null, so you will cause a NullPointerException.

Posted

ok, all of that works, but just

"        soundHandler.onEntityPlay("gun", mc.thePlayer.worldObj, mc.thePlayer, 1, 1);"

won't run, and its not the soundHandler class because I tested this out before.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.