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.

63 lines
1.7 KiB

  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\CustomBlockData\StickTile;
  15. use Ad5001\BetterBlocks\Main;
  16. class StickTask extends PluginTask {
  17. public function __construct(Main $main) {
  18. parent::__construct($main);
  19. $this->main = $main;
  20. $this->server = $main->getServer();
  21. }
  22. public function onRun($tick) {
  23. foreach($this->server->getOnlinePlayers() as $player) {
  24. $v3Under = $player->round();
  25. $v3Under->y--;
  26. $v3Upper = $player->round();
  27. $v3Upper->y += 2;
  28. $tileUnder = $player->getLevel()->getTile($v3Under);
  29. $tileUpper = $player->getLevel()->getTile($v3Upper);
  30. if($tileUnder instanceof StickTile){
  31. $player->setMotion(new \pocketmine\math\Vector3($player->getMotion()->x, -0.5, $player->getMotion()->z));
  32. }
  33. if($tileUpper instanceof StickTile) {
  34. $player->setMotion(new \pocketmine\math\Vector3($player->getMotion()->x, 0.5, $player->getMotion()->z));
  35. }
  36. }
  37. }
  38. }