Skip to content

Instantly share code, notes, and snippets.

@gollilla
Created June 6, 2018 11:39
Show Gist options
  • Save gollilla/0e1e17464654d2a0ed5f7f5399505c77 to your computer and use it in GitHub Desktop.
Save gollilla/0e1e17464654d2a0ed5f7f5399505c77 to your computer and use it in GitHub Desktop.
<?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