Created
June 6, 2018 11:39
-
-
Save gollilla/0e1e17464654d2a0ed5f7f5399505c77 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 | |
class autowalk extends PluginBase implements Listener{ | |
public const DISTANCE = 10; | |
public function onEnable(){ | |
$this->getServer()->getPluginManager()->registerEvents($this,$this); | |
} | |
public function onMove(PlayerMoveEvent $ev){ | |
$player = $ev->getPlayer(); | |
$level = $player->getLevel(); | |
$x = $player->x + 0.3; | |
$y = $player->y + $player->eyeHeight; | |
$z = $player->z + 0.3; | |
$radYaw = deg2rad(-$player->yaw); | |
$radPitch = deg2rad(-$player->pitch); | |
$vecX = self::DISTANCE * sin($radYaw); | |
$vecY = self::DISTANCE * sin($radPitch); | |
$vecZ = self::DISTANCE * cos($radYaw); | |
$block = Block::get(1); | |
$level->setBlock(new Vector3($x + $vecX, $y + $vecY, $z + $vecZ), $block); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment