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

How do you do that after destroying Stone with a golden pick, you cancel the task of renewing?

Discussion in 'Requests' started by Krystian Sqiun, Jun 12, 2018.

  1. Krystian Sqiun

    Krystian Sqiun Creeper

    Messages:
    4
    How do you do that after destroying Stone with a golden pick, you cancel the task of renewing?

    PHP:
    <?php
    public function onBreak(BlockBreakEvent $event){
      
    $blok $event->getBlock();
      
    $gracz $event->getPlayer();
      
    $y $blok->getFloorY();
      
    $x $blok->getFloorX();
      
    $z $blok->getFloorZ();
        if(
    $blok->getId() == 1){
       
    $task = new Task($this$event->getBlock()->getFloorX(), $event->getBlock()->getFloorY(), $event->getBlock()->getFloorZ());
           
    $this->getServer()->getScheduler()->scheduleDelayedTask($task30);
            }
         }
    }

    //Task.php
    <?php

    namespace StoneFarm;

    use 
    pocketmine\block\Block;
    use 
    pocketmine\block\Air;
    use 
    pocketmine\block\Stone;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\scheduler\PluginTask;

    class 
    Task extends PluginTask{

        private 
    $z;
        private 
    $y;
        private 
    $x;
    private 
    $gracz;
        
        public function  
    __construct($gracz$x$y$z){
    parent::__construct($gracz);
        
    $this->$x;
    $this->$y;
    $this->$z;
    $this->gracz $gracz;
        }
        
        

    public function 
    onRun($currentTick){
    $level $this->gracz->getServer()->getLevelByName("world");
    if(
    $level->getBlock(new Vector3($this->x$this->y$this->z))->getId() == 0) { 
           
    $level->setBlock(new Vector3($this->x$this->y$this->z), new Stone());
        }
    }
    }

     
  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.