Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by blooditor

One thing, is that you are registering your event twice, remove the deprecated FMLCommonHandler bus register

  • 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.

  • 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?

  • 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.

  • 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 ;)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.