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

Farmland

Discussion in 'Development' started by #A6543, Jun 17, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    How can I stop destroying farmland? I already tried something. But it didn't work.

    PHP:
    public function onBreak(BlockBreakEvent $e) {
    $e->setCancelled();
    }
    This only prevents a player from breaking the block :/
     
  2. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    Use this:
    PHP:
    public function onBreak(BlockBreakEvent $e) {
        
    $block $e->getBlock(); // Gets the block that gets broken
        // 60 is the Block ID of Farmland
        
    if($block->getId() === 60) { // Finds out if the Farmland (ID 60) is broken
            
    $e->setCancelled(); // Cancells the event
        
    }
    }
     
  3. #A6543

    #A6543 Zombie

    Messages:
    267
    But if I cancel the whole event it also should work! This is no difference in this case
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Do you mean to prevent when a player jumps of farmland?
     
    Sandertv likes this.
  5. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    693
    GitHub:
    winterbuild7074
    It only cancels the event if a player breaks the Farmland Block.That means it stops the player breaking Farmland.
     
  6. #A6543

    #A6543 Zombie

    Messages:
    267
    Yes
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    SPOON USER!
    PMMP doesn't even have the feature, so you are either using a plugin or a spoon. Most likely the latter, so you cannot be helped here.
     
    EdwardHamHam and Muqsit like this.
  8. #A6543

    #A6543 Zombie

    Messages:
    267
    I use the newest pmmp
     
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    If you are using PMMP, you shouldn't have a problem. PMMP doesn't have the feature yet.
     
    Muqsit likes this.
  10. #A6543

    #A6543 Zombie

    Messages:
    267
    What feature do u mean? I only want to cancel the breaking of farmland when jumping on it
     
  11. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    It doesn't break anyway, so you don't need to cancel it
     
  12. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    What he means is that PocketMine doesn't even have the trampling crops feature yet. Therefore, you shouldn't need to cancel it because it can't happen anyways. If it does happen to you, then you must be using a spoon.
     
    SOFe, Muqsit and jasonwynn10 like this.
  13. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i think they means are you sure farmlands break if you jump on it
    afaik i am not sure if this is a thing or not
     
  14. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    I think that's what they mean too. That's what "trampling crops" means.
     
  15. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    As far as I know, I am not sure if "afaik i am not sure" is a thing or not ;)
     
  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.