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

With this code in eclipse from one of my private mods:

Spoiler

@SubscribeEvent
    public void AccessEnchant(LivingHurtEvent fEvent, World world)
    {
        if(fEvent.source.damageType != "player" && fEvent.source.damageType != "mob")
            return;
        
       
        
        if(!(fEvent.source.getSourceOfDamage() instanceof EntityLivingBase))
            return;
        
        EntityLivingBase attacker = (EntityLivingBase)fEvent.source.getSourceOfDamage();
        if(attacker == null)
            return;
        
        ItemStack dmgSource = ((EntityLivingBase)fEvent.source.getSourceOfDamage()).getHeldItem();
        if(dmgSource == null)
            return;
        
        if(EnchantmentHelper.getEnchantmentLevel(effectId, dmgSource) <= 0)
            return;
        int levelSunshine = EnchantmentHelper.getEnchantmentLevel(effectId, dmgSource);
        
        
         
        final World w = world;
                long wt = w.provider.getWorldTime();
                long constantTime = w.provider.getWorldTime ();
             
                int timeDay = 0;
                int timeNight = 11999;
                int wt2 = (int) wt;
                
                while(wt2 < 24001){
                    wt2 = wt2 - 24000;
                    
                }
                if((timeNight) > wt2)  {
                 fEvent.ammount = fEvent.ammount * (0.9f + (0.30f * levelSunshine));
                  return;
                }
                  else if(timeDay < wt2)
                  {
                      
                 fEvent.ammount = fEvent.ammount - (0.75f * levelSunshine);
                  }  
                      
                }

    }

I get this crash

 

1.7.10 is no longer supported on this forum, your thread will probably be closed by a mod.

 

That said, the error tells you the problem:

Quote

Method public void [...] has @SubscribeEvent annotation, but requires 2 arguments.  Event handler methods must require a single argument.

You have two arguments in your event handler method, which is an invalid use of @SubscribeEvent. Event handler methods must have just one argument, the Event type.

Edited by Jay Avery

  • Author

Uhm Last Question how do I get to put 2 or more arguements that work properly without any errors. Regardless of the method how can it be done?

If you want it to be an event handler method, you can't have multiple arguments. If you need a World object for your code, get it via the event itself.

  • Guest locked this topic
Guest
This topic is now closed to further replies.

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.