当前位置: 首页>>代码示例>>PHP>>正文


PHP Vector3::getY方法代码示例

本文整理汇总了PHP中pocketmine\math\Vector3::getY方法的典型用法代码示例。如果您正苦于以下问题:PHP Vector3::getY方法的具体用法?PHP Vector3::getY怎么用?PHP Vector3::getY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\math\Vector3的用法示例。


在下文中一共展示了Vector3::getY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ifjump

 /**
  * @param Level   $level
  * @param Vector3 $v3
  * @param bool    $hate
  * @param bool    $reason
  * @return bool|float|string
  * 判断某坐标是否可以行走
  * 并给出原因
  */
 public function ifjump(Level $level, Vector3 $v3, $hate = false, $reason = false)
 {
     //boybook Y轴算法核心函数
     $x = floor($v3->getX());
     $y = floor($v3->getY());
     $z = floor($v3->getZ());
     //echo ($y." ");
     if ($this->whatBlock($level, new Vector3($x, $y, $z)) == "air") {
         //echo "前方空气 ";
         if ($this->whatBlock($level, new Vector3($x, $y - 1, $z)) == "block" or new Vector3($x, $y - 1, $z) == "climb") {
             //方块
             //echo "考虑向前 ";
             if ($this->whatBlock($level, new Vector3($x, $y + 1, $z)) == "block" or $this->whatBlock($level, new Vector3($x, $y + 1, $z)) == "half" or $this->whatBlock($level, new Vector3($x, $y + 1, $z)) == "high") {
                 //上方一格被堵住了
                 //echo "上方卡住 \n";
                 if ($reason) {
                     return 'up!';
                 }
                 return false;
                 //上方卡住
             } else {
                 //echo "GO向前走 \n";
                 if ($reason) {
                     return 'GO';
                 }
                 return $y;
                 //向前走
             }
         } elseif ($this->whatBlock($level, new Vector3($x, $y - 1, $z)) == "half") {
             //半砖
             //echo "下到半砖 \n";
             if ($reason) {
                 return 'half';
             }
             return $y - 0.5;
             //向下跳0.5格
         } elseif ($this->whatBlock($level, new Vector3($x, $y - 1, $z)) == "lava") {
             //岩浆
             //echo "前方岩浆 \n";
             if ($reason) {
                 return 'lava';
             }
             return false;
             //前方岩浆
         } elseif ($this->whatBlock($level, new Vector3($x, $y - 1, $z)) == "air") {
             //空气
             //echo "考虑向下跳 ";
             if ($this->whatBlock($level, new Vector3($x, $y - 2, $z)) == "block") {
                 //echo "GO向下跳 \n";
                 if ($reason) {
                     return 'down';
                 }
                 return $y - 1;
                 //向下跳
             } else {
                 //前方悬崖
                 //echo "前方悬崖 \n";
                 if ($reason) {
                     return 'fall';
                 }
                 /*	if ($hate === false) {
                 				return false;
                 			}
                 			else {
                 				return $y-1;  //向下跳
                 			}*/
             }
         }
     } elseif ($this->whatBlock($level, new Vector3($x, $y, $z)) == "half") {
         //半砖
         //echo "前方半砖 \n";
         if ($this->whatBlock($level, new Vector3($x, $y + 1, $z)) == "block" or $this->whatBlock($level, new Vector3($x, $y + 1, $z)) == "half" or $this->whatBlock($level, new Vector3($x, $y + 1, $z)) == "high") {
             //上方一格被堵住了
             //return false;  //上方卡住
         } else {
             if ($reason) {
                 return 'halfGO';
             }
             return $y + 0.5;
         }
     } elseif ($this->whatBlock($level, new Vector3($x, $y, $z)) == "lava") {
         //岩浆
         //echo "前方岩浆 \n";
         if ($reason) {
             return 'lava';
         }
         return false;
     } elseif ($this->whatBlock($level, new Vector3($x, $y, $z)) == "high") {
         //1.5格高方块
         //echo "前方栅栏 \n";
         if ($reason) {
//.........这里部分代码省略.........
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:101,代码来源:AIHolder.php

示例2: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $e)
 {
     // Implement the CompassTP thingie...
     $pl = $e->getPlayer();
     if (!$pl->hasPermission("toybox.compasstp")) {
         return;
     }
     $hand = $pl->getInventory()->getItemInHand();
     if ($hand->getID() != $this->item) {
         return;
     }
     $pos = $pl->getPosition()->add(0, $pl->getEyeHeight(), 0);
     $start = new Vector3($pos->getX(), $pos->getY(), $pos->getZ());
     $lv = $pl->getLevel();
     for ($start = new Vector3($pos->getX(), $pos->getY(), $pos->getZ()); $start->distance($pos) < 120; $pos = $pos->add($pl->getDirectionVector())) {
         $block = $lv->getBlock($pos->floor());
         if ($block->getId() != 0) {
             break;
         }
     }
     if ($block->getId() == 0) {
         $pl->sendMessage(mc::_("Can not teleport to the void!"));
         return;
     }
     $pos = $pos->subtract($pl->getDirectionVector());
     $dist = $start->distance($pos);
     if ($dist < 2.8) {
         $pl->sendMessage(mc::_("Not teleporting..."));
         $pl->sendMessage(mc::_("You could easily walk there!"));
         return;
     }
     //echo "Block: ".$block->getName()." (".$block->getId().")\n";
     //print_r($pos);
     //echo "Distance: ".$start->distance($pos)."\n";
     $pl->sendMessage(mc::_("Teleporting... %1%", intval($dist)));
     $pos = $pos->add(0, 1, 0);
     /*$cb = new CallbackTask([$this,"delayedTP"],[$pl->getName(),
       $pos->getX(),
       $pos->getY(),
       $pos->getZ()]);
       $this->owner->getServer()->getScheduler()->scheduleDelayedTask($cb,20);
       //$pl->teleport($pos);
       return;*/
     $m = 5.0;
     for ($f = 1.0; $f <= $m; $f++) {
         $ticks = intval($f) * 5;
         $x = ($pos->getX() - $start->getX()) * $f / $m + $start->getX();
         $y = ($pos->getY() - $start->getY()) * $f / $m + $start->getY();
         $z = ($pos->getZ() - $start->getZ()) * $f / $m + $start->getZ();
         $c = new PluginCallbackTask($this->owner, [$this, "delayedTP"], [$pl->getName(), $x, $y, $z]);
         $this->owner->getServer()->getScheduler()->scheduleDelayedTask($c, $ticks);
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:53,代码来源:CompassTp.php

示例3: createEffectArrow

 public static function createEffectArrow(Player $player, Vector3 $position, Vector3 $speed, $yaw, $pitch, $r, $g, $b, $critical)
 {
     $nbtTag = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $position->getX()), new Double("", $position->getY()), new Double("", $position->getZ())]), "Rotation" => new Enum("Rotation", [new Float("", $yaw), new Float("", $pitch)])]);
     $arrow = new EffectArrow($player->chunk, $nbtTag, $r, $g, $b, $player, $critical);
     $arrow->setMotion($speed);
     $launchEvent = new ProjectileLaunchEvent($arrow);
     Server::getInstance()->getPluginManager()->callEvent($launchEvent);
     if ($launchEvent->isCancelled()) {
         $arrow->kill();
         return null;
     } else {
         return $arrow;
     }
 }
开发者ID:HelloWorld017,项目名称:ToAruArcher,代码行数:14,代码来源:Archery.php

示例4: __construct

 public function __construct(Level $level, Vector3 $pos)
 {
     if (!($pos instanceof Vector3 && $level instanceof Level)) {
         echo "this is not Floor!\n";
     }
     $this->vector = $pos;
     $this->x = $pos->getX();
     $this->y = $pos->getY();
     $this->z = $pos->getZ();
     $this->level = $level;
     $this->block = $level->getBlock($pos);
     $this->id = $this->block->getId();
     $this->data = $this->block->getDamage();
     $this->height = 128;
     //$this->level->getHeightMap($this->x, $this->z);
     echo "max height: {$this->height}\n";
     if (!($this->isElevatorBlock($this->block) || $this->isExtensionFloorBlock($this->block))) {
         echo "THIS IS NOT FLOOR!\n";
     }
 }
开发者ID:JungHyun3459,项目名称:PMMP-Plugins,代码行数:20,代码来源:Floor.php

示例5: canBlockSeeSky

 public function canBlockSeeSky(Vector3 $pos) : bool
 {
     return $this->getHighestBlockAt($pos->getFloorX(), $pos->getFloorZ()) < $pos->getY();
 }
开发者ID:kniffo80,项目名称:Genisys,代码行数:4,代码来源:Level.php

示例6: getTextPacket

 public function getTextPacket(Vector3 $pos, $text)
 {
     $eid = ++Entity::$entityCount;
     return "{$eid};" . $pos->getX() . ";" . $pos->getY() . ";" . $pos->getZ() . ";{$text}";
 }
开发者ID:HelloWorld017,项目名称:xChange,代码行数:5,代码来源:EntityItemCase.php

示例7: SkeletonRandomWalkCalc

 public function SkeletonRandomWalkCalc()
 {
     $this->dif = $this->plugin->getServer()->getDifficulty();
     //$this->getLogger()->info("僵尸数量:".count($this->plugin->Skeleton));
     foreach ($this->plugin->getServer()->getLevels() as $level) {
         foreach ($level->getEntities() as $zo) {
             if ($zo instanceof Skeleton) {
                 if ($this->plugin->willMove($zo)) {
                     if (!isset($this->plugin->Skeleton[$zo->getId()])) {
                         $this->plugin->Skeleton[$zo->getId()] = array('ID' => $zo->getId(), 'IsChasing' => false, 'motionx' => 0, 'motiony' => 0, 'motionz' => 0, 'hurt' => 10, 'time' => 10, 'x' => 0, 'y' => 0, 'z' => 0, 'oldv3' => $zo->getLocation(), 'yup' => 20, 'up' => 0, 'yaw' => $zo->yaw, 'pitch' => 0, 'level' => $zo->getLevel()->getName(), 'xxx' => 0, 'zzz' => 0, 'gotimer' => 10, 'swim' => 0, 'jump' => 0.01, 'canjump' => true, 'drop' => false, 'canAttack' => 0, 'shoot' => 20, 'knockBack' => false);
                         $zom =& $this->plugin->Skeleton[$zo->getId()];
                         $zom['x'] = $zo->getX();
                         $zom['y'] = $zo->getY();
                         $zom['z'] = $zo->getZ();
                     }
                     $zom =& $this->plugin->Skeleton[$zo->getId()];
                     if ($zom['IsChasing'] === false) {
                         //自由行走模式
                         if ($zom['gotimer'] == 0 or $zom['gotimer'] == 10) {
                             //限制转动幅度
                             $newmx = mt_rand(-5, 5) / 10;
                             while (abs($newmx - $zom['motionx']) >= 0.7) {
                                 $newmx = mt_rand(-5, 5) / 10;
                             }
                             $zom['motionx'] = $newmx;
                             $newmz = mt_rand(-5, 5) / 10;
                             while (abs($newmz - $zom['motionz']) >= 0.7) {
                                 $newmz = mt_rand(-5, 5) / 10;
                             }
                             $zom['motionz'] = $newmz;
                         } elseif ($zom['gotimer'] >= 20 and $zom['gotimer'] <= 24) {
                             $zom['motionx'] = 0;
                             $zom['motionz'] = 0;
                             //僵尸停止
                         }
                         $zom['gotimer'] += 0.5;
                         if ($zom['gotimer'] >= 22) {
                             $zom['gotimer'] = 0;
                         }
                         //重置走路计时器
                         //$zom['motionx'] = mt_rand(-10,10)/10;
                         //$zom['motionz'] = mt_rand(-10,10)/10;
                         $zom['yup'] = 0;
                         $zom['up'] = 0;
                         //boybook的y轴判断法
                         //$width = $this->width;
                         $pos = new Vector3($zom['x'] + $zom['motionx'], floor($zo->getY()) + 1, $zom['z'] + $zom['motionz']);
                         //目标坐标
                         $zy = $this->plugin->ifjump($zo->getLevel(), $pos);
                         if ($zy === false) {
                             //前方不可前进
                             $pos2 = new Vector3($zom['x'], $zom['y'], $zom['z']);
                             //目标坐标
                             if ($this->plugin->ifjump($zo->getLevel(), $pos2) === false) {
                                 //原坐标依然是悬空
                                 $pos2 = new Vector3($zom['x'], $zom['y'] - 1, $zom['z']);
                                 //下降
                                 $zom['up'] = 1;
                                 $zom['yup'] = 0;
                             } else {
                                 $zom['motionx'] = -$zom['motionx'];
                                 $zom['motionz'] = -$zom['motionz'];
                                 //转向180度,向身后走
                                 $zom['up'] = 0;
                             }
                         } else {
                             $pos2 = new Vector3($zom['x'] + $zom['motionx'], $zy - 1, $zom['z'] + $zom['motionz']);
                             //目标坐标
                             if ($pos2->y - $zom['y'] < 0) {
                                 $zom['up'] = 1;
                             } else {
                                 $zom['up'] = 0;
                             }
                         }
                         if ($zom['motionx'] == 0 and $zom['motionz'] == 0) {
                             //僵尸停止
                         } else {
                             //转向计算
                             $yaw = $this->plugin->getyaw($zom['motionx'], $zom['motionz']);
                             //$zo->setRotation($yaw,0);
                             $zom['yaw'] = $yaw;
                             $zom['pitch'] = 0;
                         }
                         //更新僵尸坐标
                         if (!$zom['knockBack']) {
                             $zom['x'] = $pos2->getX();
                             $zom['z'] = $pos2->getZ();
                             $zom['y'] = $pos2->getY();
                         }
                         $zom['motiony'] = $pos2->getY() - $zo->getY();
                         //echo($zo->getY()."\n");
                         //var_dump($pos2);
                         //var_dump($zom['motiony']);
                         $zo->setPosition($pos2);
                         //echo "SetPosition \n";
                     }
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:edwinyoo44,项目名称:MyOwnWorld,代码行数:101,代码来源:SkeletonAI.php

示例8: randVector

 protected static function randVector(Vector3 $center)
 {
     return new Vector3(self::randy($center->getX(), 0.5, -0.25), self::randy($center->getY(), 2, 0), self::randy($center->getZ(), 0.5, -0.25));
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:4,代码来源:BcTpMgr.php

示例9: SpecialMobRandomWalkCalc

 public function SpecialMobRandomWalkCalc()
 {
     $this->dif = $this->getServer()->getDifficulty();
     $filter_res = array_filter($this->animals);
     if (!empty($filter_res)) {
         foreach ($this->animals as $animal) {
             if (in_array($animal['type'], $this->specialMobtype)) {
                 $level = $this->getServer()->getLevelByName($animal['level']);
                 $an = $level->getEntity($animal['ID']);
                 //var_dump($animal);
                 if ($an != "") {
                     $zom =& $this->animals[$an->getId()];
                     if ($zom['IsChasing'] == "0") {
                         if ($animal['type'] == 38) {
                             $move = mt_rand(-2, 2);
                             //var_dump("Ender");
                             if ($move == 0) {
                                 //var_dump("Move!");
                                 $pos = new Vector3($zom['x'] + rand(-50, 50), floor($an->getY()), $zom['z'] + rand(-50, 50));
                                 //目标坐标
                                 if ($this->whatBlock($level, $pos) == "block") {
                                     $v3_1 = $pos;
                                     $v3_1->y = floor($an->getY()) + 1 + 1;
                                     $v3_2 = $pos;
                                     $v3_2->y = floor($an->getY()) + 1 + 2;
                                     $an->setPosition($pos);
                                     $pos4 = new Vector3($zom['x'], $zom['y'], $zom['z']);
                                     $w1 = new HeartParticle($pos);
                                     $w2 = new HeartParticle($pos4);
                                     $an->getLevel()->addParticle($w1);
                                     $an->getLevel()->addParticle($w2);
                                     if ($level->getBlock($v3_1)->getID() == 0 and $level->getBlock($v3_2)->getID() == 0) {
                                         $zom['x'] = $pos->x;
                                         $zom['y'] = $pos->y;
                                         $zom['z'] = $pos->z;
                                     }
                                 }
                             }
                         }
                     }
                     if ($this->willMove($an)) {
                         $zo = $level->getEntity($animal['ID']);
                         if ($zom['IsChasing'] == "0") {
                             //自由行走模式
                             if ($zom['gotimer'] == 0 or $zom['gotimer'] == 10) {
                                 //限制转动幅度
                                 $newmx = mt_rand(-5, 5) / 10;
                                 while (abs($newmx - $zom['motionx']) >= 0.7) {
                                     $newmx = mt_rand(-5, 5) / 10;
                                 }
                                 $zom['motionx'] = $newmx;
                                 $newmz = mt_rand(-5, 5) / 10;
                                 while (abs($newmz - $zom['motionz']) >= 0.7) {
                                     $newmz = mt_rand(-5, 5) / 10;
                                 }
                                 $zom['motionz'] = $newmz;
                             } elseif ($zom['gotimer'] >= 20 and $zom['gotimer'] <= 24) {
                                 $zom['motionx'] = 0;
                                 $zom['motionz'] = 0;
                                 //僵尸停止
                             }
                             $zom['gotimer'] += 0.5;
                             if ($zom['gotimer'] >= 22) {
                                 $zom['gotimer'] = 0;
                             }
                             //重置走路计时器
                             //$zom['motionx'] = mt_rand(-10,10)/10;
                             //$zom['motionz'] = mt_rand(-10,10)/10;
                             $zom['yup'] = 0;
                             $zom['up'] = 0;
                             //boybook的y轴判断法
                             //$width = $this->width;
                             $pos = new Vector3($zom['x'] + $zom['motionx'], floor($zo->getY()) + 1, $zom['z'] + $zom['motionz']);
                             //目标坐标
                             $zy = $this->ifjump($zo->getLevel(), $pos);
                             if ($zy === false) {
                                 //前方不可前进
                                 $pos2 = new Vector3($zom['x'], $zom['y'], $zom['z']);
                                 //目标坐标
                                 if ($this->ifjump($zo->getLevel(), $pos2) === false) {
                                     //原坐标依然是悬空
                                     $pos2 = new Vector3($zom['x'], $zom['y'] - 1, $zom['z']);
                                     //下降
                                     $zom['up'] = 1;
                                     $zom['yup'] = 0;
                                 } else {
                                     $zom['motionx'] = -$zom['motionx'];
                                     $zom['motionz'] = -$zom['motionz'];
                                     //转向180度,向身后走
                                     $zom['up'] = 0;
                                 }
                             } else {
                                 $pos2 = new Vector3($zom['x'] + $zom['motionx'], $zy - 1, $zom['z'] + $zom['motionz']);
                                 //目标坐标
                                 if ($pos2->y - $zom['y'] < 0) {
                                     $zom['up'] = 1;
                                 } else {
                                     $zom['up'] = 0;
                                 }
                             }
//.........这里部分代码省略.........
开发者ID:ianju,项目名称:AnimalWorld,代码行数:101,代码来源:Animalworld.php

示例10: lightning

 /**
  * @param Vector3 $pos
  * @return AddEntityPacket
  */
 public function lightning(Vector3 $pos)
 {
     if ($this->lightningPacket === null) {
         $pk = new AddEntityPacket();
         $pk->type = 93;
         $pk->eid = Entity::$entityCount++;
         $pk->metadata = [];
         $pk->speedX = 0;
         $pk->speedY = 0;
         $pk->speedZ = 0;
         $pk->x = $pos->getX();
         $pk->y = $pos->getY();
         $pk->z = $pos->getZ();
         $this->lightningPacket = $pk;
     }
     return $this->lightningPacket;
 }
开发者ID:TBNRFrags2468,项目名称:EssentialsPE,代码行数:21,代码来源:BaseAPI.php

示例11: onRun

 public function onRun($currentTick)
 {
     foreach ($this->getOwner()->getServer()->getOnlinePlayers() as $p) {
         $name = strtolower($p->getName());
         $welt = strtolower($p->getLevel()->getName());
         if ($welt == $this->getOwner()->lobbyname) {
             $pos1 = explode(",", $this->getOwner()->lobbyareapos1);
             $pos2 = explode(",", $this->getOwner()->lobbyareapos2);
         }
         if ($welt == $this->getOwner()->arena1name) {
             $pos1 = explode(",", $this->getOwner()->arena1areapos1);
             $pos2 = explode(",", $this->getOwner()->arena1areapos2);
         }
         if ($welt == $this->getOwner()->arena2name) {
             $pos1 = explode(",", $this->getOwner()->arena2areapos1);
             $pos2 = explode(",", $this->getOwner()->arena2areapos2);
         }
         if ($welt == $this->getOwner()->arena3name) {
             $pos1 = explode(",", $this->getOwner()->arena3areapos1);
             $pos2 = explode(",", $this->getOwner()->arena3areapos2);
         }
         if ($welt == $this->getOwner()->arena4name) {
             $pos1 = explode(",", $this->getOwner()->arena4areapos1);
             $pos2 = explode(",", $this->getOwner()->arena4areapos2);
         }
         if ($welt == $this->getOwner()->arena5name) {
             $pos1 = explode(",", $this->getOwner()->arena5areapos1);
             $pos2 = explode(",", $this->getOwner()->arena5areapos2);
         }
         $ppos = new Vector3($p->x, $p->y, $p->z);
         if (min($pos1[0], $pos2[0]) <= $ppos->getX() && max($pos1[0], $pos2[0]) >= $ppos->getX() && min($pos1[1], $pos2[1]) <= $ppos->getY() && max($pos1[1], $pos2[1]) >= $ppos->getY() && min($pos1[2], $pos2[2]) <= $ppos->getZ() && max($pos1[2], $pos2[2]) >= $ppos->getZ()) {
         } else {
             $knockback = 3.0;
             if ($pos1[0] >= $pos2[0]) {
                 $minX = $pos2[0];
                 $maxX = $pos1[0];
             } else {
                 $minX = $pos1[0];
                 $maxX = $pos2[0];
             }
             if ($pos1[2] >= $pos2[2]) {
                 $minZ = $pos2[2];
                 $maxZ = $pos1[2];
             } else {
                 $minZ = $pos1[2];
                 $maxZ = $pos2[2];
             }
             $x = $p->getX();
             $z = $p->getZ();
             $y = $p->getY();
             if ($x <= $minX) {
                 $x = $minX + $knockback;
             } elseif ($x >= $maxX) {
                 $x = $maxX - $knockback;
             }
             if ($z <= $minZ) {
                 $z = $minZ + $knockback;
             } elseif ($z >= $maxZ) {
                 $z = $maxZ - $knockback;
             }
             $p->teleport(new Vector3($x, $y, $z));
             $p->sendMessage(MT::RED . 'End of World/Ende der Welt');
         }
     }
 }
开发者ID:100henrik100,项目名称:Minecraft-Pocket-Edition,代码行数:65,代码来源:minigame.php

示例12: isInside

 public function isInside(Vector3 $v)
 {
     $out = true;
     switch ($this->axis) {
         case self::X:
             $out = ($out and $this->base->getX() <= $v->getX() and $v->getX() <= $this->base->getX() + $this->height);
             $out = ($out and $v->distance(new Vector3($v->getX(), $this->base->getY(), $this->base->getZ())) <= $this->radius);
             break;
         case self::Y:
             $out = ($out and $this->base->getY() <= $v->getY() and $v->getY() <= $this->base->getY() + $this->height);
             $out = ($out and $v->distance(new Vector3($this->base->getX(), $v->getY(), $this->base->getZ())) <= $this->radius);
             break;
         case self::Z:
             $out = ($out and $this->base->getZ() <= $v->getZ() and $v->getZ() <= $this->base->getZ() + $this->height);
             $out = ($out and $v->distance(new Vector3($this->base->getX(), $this->base->getY(), $v->getZ())) <= $this->radius);
             break;
     }
     if ($v instanceof Position) {
         $out = ($out and $v->getLevel()->getName() === $this->base->getLevel()->getName());
     }
     return $out;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:22,代码来源:CylinderSpace.php

示例13: canPVP

 public function canPVP(Vector3 $pp, Vector3 $p1, Vector3 $p2, $lv1, $lv2)
 {
     /*var_dump(min($p1->getX(),$p2->getX()) <= $pp->getX());
     		var_dump(max($p1->getX(),$p2->getX()) >= $pp->getX());
     		var_dump(min($p1->getY(),$p2->getY()) <= $pp->getY());
     		var_dump(max($p1->getY(),$p2->getY()) >= $pp->getY());//returns false
     		var_dump(max($p1->getY(),$p2->getY()).">=".$pp->getY());
     		var_dump(min($p1->getZ(),$p2->getZ()) <= $pp->getZ());
     		var_dump(max($p1->getZ(),$p2->getZ()) >= $pp->getZ());
     		var_dump($lv1 === $lv2);*/
     return min($p1->getX(), $p2->getX()) <= $pp->getX() && max($p1->getX(), $p2->getX()) >= $pp->getX() && min($p1->getY(), $p2->getY()) <= $pp->getY() && max($p1->getY(), $p2->getY()) >= $pp->getY() && min($p1->getZ(), $p2->getZ()) <= $pp->getZ() && max($p1->getZ(), $p2->getZ()) >= $pp->getZ() && $lv1 === $lv2;
 }
开发者ID:diamond-gold,项目名称:AreaPVP,代码行数:12,代码来源:Main+CN.php

示例14: place

 public function place()
 {
     for ($x = $this->start->getFloorX(); $x < $this->end->getFloorX(); $x++) {
         $xOffset = ($this->chunk->getX() + $x + 0.5 - $this->target->getX()) / $this->horizontalSize;
         for ($z = $this->start->getFloorZ(); $z < $this->end->getFloorZ(); $z++) {
             $zOffset = ($this->chunk->getZ() + $z + 0.5 - $this->target->getZ()) / $this->horizontalSize;
             if ($xOffset * $xOffset + $zOffset * $zOffset >= 1) {
                 continue;
             }
             for ($y = $this->end->getFloorY() - 1; $y >= $this->start->getFloorY(); $y--) {
                 $yOffset = ($y + 0.5 - $this->target->getY()) / $this->verticalSize;
                 if ($yOffset > -0.7 and $xOffset * $xOffset + $yOffset * $yOffset + $zOffset * $zOffset < 1) {
                     $xx = $this->chunk->getX() + $x;
                     $zz = $this->chunk->getZ() + $z;
                     $blockId = $this->level->getBlockIdAt($xx, $y, $zz);
                     if ($blockId == Block::STONE or $blockId == Block::DIRT or $blockId == Block::GRASS) {
                         if ($y < 10) {
                             $this->level->setBlockIdAt($xx, $y, $zz, Block::STILL_LAVA);
                         } else {
                             if ($blockId == Block::GRASS and $this->level->getBlockIdAt($xx, $y - 1, $zz) == Block::DIRT) {
                                 $this->level->setBlockIdAt($xx, $y - 1, $zz, Block::GRASS);
                             }
                             $this->level->setBlockIdAt($xx, $y, $zz, Block::AIR);
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:iTXTech,项目名称:Genisys,代码行数:30,代码来源:Cave.php

示例15: calculateVector

 public function calculateVector(Vector3 $vector, Position $position, $maxStep, $size, $yOffset)
 {
     $motionX = $vector->getX();
     $motionY = $vector->getY();
     $motionZ = $vector->getZ();
     $x = $position->getX();
     $y = $position->getY() + $yOffset;
     $z = $position->getZ();
     $return = ["stack" => array(), "final" => null];
     $return["stack"] = array();
     for ($i = 0; $i < $maxStep; $i++) {
         $x += $motionX;
         $y += $motionY;
         $z += $motionZ;
         $aabb = new AxisAlignedBB($x - $size, $y - $size, $z - $size, $x + $size, $y + $size, $z + $size);
         $currentPos = new Position($x, $y, $z, $position->getLevel());
         array_push($return["stack"], $currentPos);
         $collidingEntities = $position->getLevel()->getCollidingEntities($aabb);
         foreach ($collidingEntities as $entity) {
             if ($entity instanceof Player && $this->getPlugin()->isEnemy($this->player->getName(), $entity->getName())) {
                 $return["final"] = $currentPos;
                 $this->processBazookaShoot($return);
                 return;
             }
         }
         $block = $position->getLevel()->getBlock($currentPos);
         if ($block->getId() !== 0 || $y < 0) {
             $return["final"] = $currentPos;
             $this->processBazookaShoot($return);
             return;
         }
     }
     $this->processBazookaShoot(null);
 }
开发者ID:EmreTr1,项目名称:MineCombat,代码行数:34,代码来源:Bazooka.php


注:本文中的pocketmine\math\Vector3::getY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。