Jump to content

Recommended Posts

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

 

Posted (edited)

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
Posted

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.

Announcements



×
×
  • Create New...

Important Information

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