1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved Effect duration

Discussion in 'Development' started by Levi, Oct 9, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    ERROR:
    Code:
    [Server thread/CRITICAL]: Could not tick level "world": Effect duration must be in range of 0 - 2147483647
    [23:23:18] [Server thread/CRITICAL]: InvalidArgumentException: "Effect duration must be in range of 0 - 2147483647" (EXCEPTION) in "src/pocketmine/entity/Effect" at line 183
    code:
    PHP:
    $haste Effect::getEffect(Effect::HASTE)->setDuration(1*20)->setAmplifier(9)->setVisible
                
    (false);
    why do i get such error when my duration is above 0?
     
  2. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    You keep posting one or two lines without any context or information about your setup, and hoping for answers... the above code works fine, so at a guess I'd say the code you posted isn't the line causing the error?
     
  3. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    So what was the problem? You are supposed to post the answer even if you solve it yourself, so that other people can learn from your mistake.
     
  4. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Not really show how I fixed it but, here's my code: it stopped giving error

    PHP:
    $item $event->getPlayer()->getInventory()->getItemInHand()->getId();
            
    $itemName $event->getPlayer()->getInventory()->getItemInHand()->getName();
            if (
    $item == 278) {
                if(
    $itemName == "§i§cPickaxe") {
                    
    $haste Effect::getEffect(Effect::HASTE)->setDuration(20)->setAmplifier(9)->setVisible
                    
    (false);
                    
    $event->getPlayer()->addEffect($haste);
                }
            } 
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.