The same blocks, simply better. For PocketMine & forks.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AttractTask.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. # ____ _ _ ____ _ _
  3. # | __ ) ___ | |_ | |_ ___ _ __ | __ ) | | ___ ___ | | __ ___
  4. # | _ \ / _ \ | __| | __| / _ \ | '__| | _ \ | | / _ \ / __| | |/ / / __|
  5. # | |_) | | __/ | |_ | |_ | __/ | | | |_) | | | | (_) | | (__ | < \__ \
  6. # |____/ \___| \__| \__| \___| |_| |____/ |_| \___/ \___| |_|\_\ |___/
  7. #
  8. # Extends your Minecraft PE blocks palette ! For PocketMine.
  9. namespace Ad5001\BetterBlocks\tasks;
  10. use pocketmine\Server;
  11. use pocketmine\scheduler\PluginTask;
  12. use pocketmine\Player;
  13. use Ad5001\BetterBlocks\CustomBlockData;
  14. use Ad5001\BetterBlocks\Main;
  15. class AttractTask extends PluginTask {
  16. public function __construct(Main $main) {
  17. parent::__construct($main);
  18. $this->main = $main;
  19. $this->server = $main->getServer();
  20. }
  21. public function onRun($tick) {
  22. foreach($this->server->getLevels() as $level) {
  23. foreach($level->getTiles() as $tile) {
  24. if(get_class($tile) == "pocketmine\\tile\\Hopper" && isset($tile->namedtag->isVacuum) && $tile->namedtag->isVacuum->getValue() == 1) {
  25. for($i = 0; $i < 10; $i++) { // Particles
  26. $level->addParticle(new \pocketmine\level\particle\PortalParticle(new \pocketmine\math\Vector3($tile->x + rand(-70, 170) / 100, $tile->y + rand(-70, 130) / 100, $tile->z + rand(-70, 170) / 100)));
  27. }
  28. foreach($level->getEntities() as $et) {
  29. if($et instanceof \pocketmine\entity\Item && $et->distance($tile) < 3) {
  30. $tile->getInventory()->addItem($et->getItem());
  31. $et->close();
  32. }
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }