Is it possible to change the block type at X:125 Y:56 Z:63 every 1 second? Maybe One second ago it was white wool, now it maybe black wool. It may look like it is flashing.
PHP: <?phpnamespace your\own\name\space;use pocketmine\plugin\PluginTask;class ChangeBlockTask extends PluginTask{ private $pos; private $list; private $current = 0; public function __construct(Main $main, Position $pos, array $list){ parent::__construct($main); $this->pos = $pos; $this->list = $list; if(count($list) === 0){ throw new \InvalidArgumentException; } } public function onRun($t){ $this->pos->getLevel()->setBlock($this->pos, $this->list[$this->next()]); } private function next(){ $this->current++; if($this->current >= count($this->list)) $this->current = 0; // loop back to the initial item return $this->current; }} PHP: <?phpnamespace your\own\name\space;use pocketmine\block\Block;use pocketmine\plugin\PluginBase;class Main extends PluginBase{ public function onEnable(){ $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position(125, 56, 63, $this->getServer()->getDefaultLevel()), [Block::get(Block::WOOL, 0), Block::get(Block::WOOL, 15)]), 20, 20); }}
ClassNotFoundException: "Class pocketmine\task\PluginTask not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144
So, like this? blockchanger\src\legoboy\blockchanger\main.php and blockchanger\src\legoboy\blockchanger\task.php
for example, if you setBlock per tick, the Server lags IF you do that more than 100+. well im just assuming in my experience with WEA.
He just asked to change one block. Same as the class name of that file. ChangeBlockTask.php Main.php Of course, change the namespace first.
PHP: <?phpnamespace robozeri\ChangeBlock;use pocketmine\scheduler\PluginTask;class ChangeBlockTask extends PluginTask{ private $pos; private $list; private $current = 0; public function __construct(Main $main, Position $pos, array $list){ parent::__construct($main); $this->pos = $pos; $this->list = $list; if(count($list) === 0){ throw new \InvalidArgumentException; } } public function onRun($t){ $this->pos->getLevel()->setBlock($this->pos, $this->list[$this->next()]); } private function next(){ $this->current++; if($this->current >= count($this->list)) $this->current = 0; // return $this->current; }} PHP: <?phpnamespace robozeri\ChangeBlock;use pocketmine\block\Block;use pocketmine\plugin\PluginBase;use robozeri\ChangeBlock\ChangeBlockTask;class Main extends PluginBase{ public function onEnable(){ $this->getServer()->getScheduler()->scheduleDelayedRepeatingTask(new ChangeBlockTask($this, new Position(129, 4, 141, $this->getServer()->getDefaultLevel()), [Block::get(Block::WOOL, 0), Block::get(Block::WOOL, 15)])); }} Sorry because I know from error it does not work?
Use my edited content. I changed the Main class a bit, and also the first few lines of the ChangePluginTask class.
Code: [CRITICAL] ClassNotFoundException: "Class legoboy\blockchanger\main not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 111 What?!