Created
December 4, 2020 21:21
-
-
Save PJZ9n/3c4a77285b7dbbbbf19f76649d2af739 to your computer and use it in GitHub Desktop.
見ているブロックを取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @name TargetBlock | |
* @version 1.0.0 | |
* @main pjz9n\test\targetblock\Main | |
* @api 3.0.0 | |
*/ | |
declare(strict_types=1); | |
namespace pjz9n\test\targetblock; | |
use pocketmine\plugin\PluginBase; | |
use pocketmine\scheduler\ClosureTask; | |
use pocketmine\Server; | |
class Main extends PluginBase | |
{ | |
public function onEnable(): void | |
{ | |
$this->getScheduler()->scheduleRepeatingTask(new ClosureTask(function (int $currentTick): void { | |
foreach (Server::getInstance()->getOnlinePlayers() as $player) { | |
$block = $player->getTargetBlock($player->getViewDistance()); | |
if ($block === null) { | |
$player->sendMessage("TargetBlock: null"); | |
} else { | |
$player->sendMessage("TargetBlock: " . $block->__toString() . " " . $block->asPosition()->__toString()); | |
} | |
} | |
}), 5); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment