daily pastebin goal
42%
SHARE
TWEET

movement

a guest Oct 29th, 2017 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace An0ther;
  4.  
  5. USE pocketmine\math\Vector3;
  6.  
  7. class Movement{
  8.     PRIVATE $main;
  9.     PRIVATE $motion;
  10.    
  11.     PUBLIC FUNCTION __construct($main){
  12.         $this->main = $main;
  13.         $this->motion = 0.2;
  14.     }
  15.    
  16.     PUBLIC FUNCTION fixYaw($entity){
  17.         $yaw = $entity->yaw;
  18.     IF($yaw > 0 && $yaw < 90)
  19.      $yaw = 0;
  20.     IF($yaw > 90 && $yaw < 180)
  21.      $yaw = 90;
  22.     IF($yaw > 180 && $yaw < 270)
  23.      $yaw = 180;
  24.     IF($yaw > 270 && $yaw < 0)
  25.      $yaw = 270;
  26.     RETURN $yaw;
  27.     }
  28.    
  29.     PUBLIC FUNCTION fixY($entity){
  30.         $y = $entity->getY();
  31.         IF($entity->getLevel()->getBlock(NEW Vector3($entity->getX(),$y - 1,$entity->getZ()))->getId() == 0){
  32.             $y -= 1;
  33.         }
  34.         RETURN $y;
  35.     }
  36.    
  37.     PUBLIC FUNCTION getForward($entity){
  38.         $yaw = $entity->yaw;
  39.         $x = $entity->getX();
  40.         $y = $this->fixY($entity);
  41.         $z = $entity->getZ();
  42.         switch($yaw){
  43.             CASE 0:
  44.             $z += $this->motion;
  45.             break;
  46.             CASE 90:
  47.             $x -= $this->motion;
  48.             break;
  49.             CASE 180:
  50.             $z -= $this->motion;
  51.             break;
  52.             CASE 270:
  53.             $x += $this->motion;
  54.             break;
  55.         }
  56. ifblock:
  57. IF($this->isBlock($x,$y,$z,$entity->getLevel())){
  58. $y++;
  59. IF($entity->getY() - $y >= 2)
  60. RETURN [$entity->getX(),$entity->getY(),$entity->getZ()];
  61. ELSE
  62. GOTO ifblock;
  63. }
  64.         RETURN [$x,$y,$z];
  65.     }
  66.  
  67. PUBLIC FUNCTION isBlock($x,$y,$z,$level){
  68. IF($level->getBlock(NEW Vector3($x,$y,$z))->getId() == 0)
  69. RETURN FALSE;
  70. ELSE
  71. RETURN TRUE;
  72. }
  73.  
  74.   PUBLIC FUNCTION getBack($entity){
  75.        
  76.     }
  77. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top