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

Cancelling BlockPlaceEvent not cancelling when placing lava inside a bucket

Discussion in 'Development' started by Levi, Jan 2, 2018.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    I cancelled BlockPlaceEvent so it cancels everything I place but it doesn't cancel bucket of lava and water when i place it
     
    Last edited: Jan 2, 2018
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    i cant place the lava bucket or water when i cancel interact event though but i think that might cause lag
     
  3. Derpific

    Derpific Spider Jockey

    Messages:
    44
    GitHub:
    Derpific
    BlockPlaceEvent only handles placing of BLOCKS, PlayerInteractEvent handles interacting (Potions, tapping a block, buckets, etc) The BucketEmpty and BucketFillEvents are better thought
     
    Last edited: Jan 3, 2018
    OnTheVerge likes this.
  4. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    A bucket of lava isn't a block therefore BlockPlaceEvent will not be triggered , try using something like PlayerInteractEvent
    PHP:
    if($event->getItem()->getId() == Item::BUCKET$event->setCancelled();
     
    Last edited: Jan 3, 2018
    Levi likes this.
  5. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    error
    Code:
    [21:19:53] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerInteractEvent' to 'Server v1.0.0': Object of class pocketmine\item\Bucket could not be converted to int on Server\Main
    [21:19:53] [Server thread/CRITICAL]: ErrorException: "Object of class pocketmine\item\Bucket could not be converted to int" (EXCEPTION) in "plugins/Server/src/Server/Main" at line 701
     
  6. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
    You're trying to compare an object to an int. The proper way would be:
    PHP:
    if($event->getItem()->getId() == Item::BUCKET$event->setCancelled();
     
    Levi likes this.
  7. Teamblocket

    Teamblocket Zombie

    Messages:
    301
    GitHub:
    teamblocket
    Fixed it :) thanks i forgot Item::BUCKET returns the id not the class:facepalm::facepalm::facepalm:
     
    Levi likes this.
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Why use PlayerInteractEvent when there's a dedicated PlayerBucketFillEvent and PlayerBucketEmptyEvent for a reason?
     
    Irish and GamakCZ like this.
  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.