Posted June 15, 20178 yr Hey, I got a weird java.lang.InstantiationException whenever I register my EventHandler class in the preInit method. The events still get called so everything works fine - there is just the error message in the console every time: Spoiler (3x:) java.lang.InstantiationException [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Constructor.newInstance(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:103) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.eventhandler.EventBus.register(EventBus.java:85) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.mcb.server.MainClass.preInit(MainClass.java:93) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:553) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.post(EventBus.java:275) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.reflect.Method.invoke(Unknown Source) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at com.google.common.eventbus.EventBus.post(EventBus.java:275) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:550) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:88) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:355) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:120) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:500) [01:38:57] [Server thread/INFO] [STDERR]: [java.lang.Throwable$WrappedPrintStream:println:-1]: at java.lang.Thread.run(Unknown Source) Spoiler public MCBEventHandler eventManager = new MCBEventHandler(); @EventHandler public void preInit(FMLPreInitializationEvent event) { MinecraftForge.EVENT_BUS.register(eventManager); FMLCommonHandler.instance().bus().register(eventManager); MinecraftForge.ORE_GEN_BUS.register(eventManager); System.out.println("Event Handler Initialized"); } Also important: I do have an empty constructor for the event handler class. So since everything works that problem is not that bad - it's just annoying having the same error messages every time. Thanks for the help. Edited June 15, 20178 yr by blooditor
June 16, 20178 yr One thing, is that you are registering your event twice, remove the deprecated FMLCommonHandler bus register
June 16, 20178 yr Author 57 minutes ago, diesieben07 said: Post MCBEventHandler. Spoiler public class MCBEventHandler { public MCBEventHandler() { } @SubscribeEvent public void loadChunk(ChunkEvent.Load e){ } @SubscribeEvent public void playerLogin(PlayerEvent.PlayerLoggedInEvent e){ } @SubscribeEvent public void playerLogout(PlayerEvent.PlayerLoggedOutEvent e){ } @SubscribeEvent public void onHit(LivingAttackEvent e){ } @SubscribeEvent public void onHurt(LivingHurtEvent e){ } @SubscribeEvent public void onKill(LivingDeathEvent e){ } @SubscribeEvent public void spawn(EntityJoinWorldEvent e){ } @SubscribeEvent public void onMove(LivingUpdateEvent e){ } @SubscribeEvent public void interact(EntityInteractEvent e){ } @SubscribeEvent public void chat(ServerChatEvent e){ } @SubscribeEvent public void playerLoggedIn(FMLNetworkEvent.ServerConnectionFromClientEvent event) { NetHandlerPlayServer handler = (NetHandlerPlayServer) event.handler; EntityPlayerMP player = handler.playerEntity; } @SubscribeEvent public void attackEntity(AttackEntityEvent e){ } @SubscribeEvent public void tick(ServerTickEvent e){ } @EventHandler public void serverStop(FMLServerStoppingEvent e){ } @SubscribeEvent public void blockInteract(final PlayerInteractEvent e){ } @SubscribeEvent public void playerUseItem(PlayerUseItemEvent e){ } @SubscribeEvent public void explosion(ExplosionEvent e){ } @SubscribeEvent public void detonate(ExplosionEvent.Detonate e){ } @SubscribeEvent public void blockBreak(BlockEvent.BreakEvent e){ } @SubscribeEvent public void blockPlace(BlockEvent.PlaceEvent e){ } @SubscribeEvent public void blockPlace(BlockEvent.MultiPlaceEvent e){ } @SubscribeEvent public void entitySpawn(EntityJoinWorldEvent e){ } @SubscribeEvent public void oreGen(PlayerChangedDimensionEvent e){ } @SubscribeEvent public void ch(PopulateChunkEvent.Pre e){ } @SubscribeEvent public void vehiclePlaced(EntityJoinWorldEvent event) { } @SubscribeEvent public void enderTp(EnderTeleportEvent e){ } @SubscribeEvent public void worldTick(WorldTickEvent e){ } @SubscribeEvent public void command(CommandEvent e){ } Sorry I had to remove the method content for security reasons.
June 16, 20178 yr Author 6 hours ago, draganz said: One thing, is that you are registering your event twice, remove the deprecated FMLCommonHandler bus register But that wouldn't cause an Exception on the other two registrations, right?
June 16, 20178 yr Author 32 minutes ago, diesieben07 said: What Minecraft version are you using? EntityInteractEvent has not existed for a while, please update.# Using MC 1.8. EntityInteractEventworks fine. 33 minutes ago, diesieben07 said: And this is complete bullshit. Nope it isn't. I'm not creating my own server mod for others copying stuff from it.
June 16, 20178 yr Author 3 minutes ago, diesieben07 said: 1.8 is ancient. Update. You cannot subscribe to an abstract event class (PlayerUseItemEvent), choose one of the sub-classes. Oh wow that actually worked. That method was empty anyways. Thanks
June 16, 20178 yr Author 5 hours ago, diesieben07 said: Good. And now please stop using 1.8. For real. Tell that Flan's Mod
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.