Jump to content

Registering a listener


Briggybros

Recommended Posts

I know this may sound nooby, but I can't seem to be able to register an event listener without it erroring, I've done it before, but this one doesn't seem to work at all. I'm registering it on the client side as it's a rendering listener. My client proxy methods work fine, this is how I'm registering it:

@Override
public void init() {
	//KeyBindingRegistry.registerKeyBinding(new KeyBindingListener(KeyBindingListener.keyArray, KeyBindingListener.repeatings));

	//TickRegistry.registerTickHandler(new ClientTickHandler(), Side.CLIENT);

	//MinecraftForge.EVENT_BUS.register(new OnScreenGui());
	MinecraftForge.EVENT_BUS.register(new ClientListener()); // This one! It's exactly the same as the one above..
}

 

This is the working listener:

public class OnScreenGui extends Gui {

private Minecraft mc;

public OnScreenGui() {
	super();
	this.mc = Minecraft.getMinecraft();
}

@ForgeSubscribe(priority = EventPriority.NORMAL)
public void onRender(RenderGameOverlayEvent event) {
	// My method for my screen 
}
}

 

And here's the broken one:

public class ClientListener {

@ForgeSubscribe(priority = EventPriority.NORMAL)
public void onItemRendered(RenderPlayerEvent event) {
	// My method again
}

private Object supportingMethod1(Object args) {
	// Supporting method
}

private Object supportingMethod2(Object args) {
	// Supporting method
}

 

the error is as follows:

2013-09-02 23:16:01 [iNFO] [sTDERR] java.lang.InstantiationException
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at java.lang.reflect.Constructor.newInstance(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraftforge.event.EventBus.register(EventBus.java:76)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraftforge.event.EventBus.register(EventBus.java:58)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at mods.SaberMod.client.ClientProxy.init(ClientProxy.java:48)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at mods.SaberMod.SaberMod.load(SaberMod.java:97)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:540)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:267)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:193)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:173)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at com.google.common.eventbus.EventBus.post(EventBus.java:267)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:104)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at cpw.mods.fml.common.Loader.initializeMods(Loader.java:697)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:222)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.startGame(Minecraft.java:506)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraft.client.main.Main.main(Main.java:93)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at java.lang.reflect.Method.invoke(Unknown Source)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)
2013-09-02 23:16:01 [iNFO] [sTDERR] 	at net.minecraft.launchwrapper.Launch.main(Launch.java:18)

Link to comment
Share on other sites

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.