getY() public method

public getY ( )
コード例 #1
0
ファイル: CompassTp.php プロジェクト: DWWf/pocketmine-plugins
 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);
     }
 }
コード例 #2
0
ファイル: Archery.php プロジェクト: HelloWorld017/ToAruArcher
 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;
     }
 }
コード例 #3
0
ファイル: Floor.php プロジェクト: JungHyun3459/PMMP-Plugins
 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";
     }
 }
コード例 #4
0
 public function getTextPacket(Vector3 $pos, $text)
 {
     $eid = ++Entity::$entityCount;
     return "{$eid};" . $pos->getX() . ";" . $pos->getY() . ";" . $pos->getZ() . ";{$text}";
 }
コード例 #5
0
 /**
  * Zombie initialization routine and freely walking mode cycle timer
  * Timer:20 ticks
  */
 public function ZombieRandomWalkCalc()
 {
     $this->dif = Server::getInstance()->getDifficulty();
     //$this->getLogger()->info(count($this->plugin->zombie));
     $zo = $this->entity;
     if ($this->willMove()) {
         if (!isset($this->data)) {
             $this->data = 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, 'knockBack' => false);
             $zom =& $this->data;
             $zom['x'] = $zo->getX();
             $zom['y'] = $zo->getY();
             $zom['z'] = $zo->getZ();
         }
         $zom =& $this->data;
         if ($zom['IsChasing'] === false) {
             //Walk mode
             if ($zom['gotimer'] == 0 or $zom['gotimer'] == 10) {
                 //Limit rotation rate
                 $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;
                 //Zombie stop
             }
             $zom['gotimer'] += 0.5;
             if ($zom['gotimer'] >= 22) {
                 $zom['gotimer'] = 0;
             }
             //Reset timer walk
             //$zom['motionx'] = mt_rand(-10,10)/10;
             //$zom['motionz'] = mt_rand(-10,10)/10;
             $zom['yup'] = 0;
             $zom['up'] = 0;
             //$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) {
                 //if can not move forward
                 $pos2 = new Vector3($zom['x'], $zom['y'], $zom['z']);
                 //Target coordinates
                 if ($this->ifjump($zo->getLevel(), $pos2) === false) {
                     //Original coordinate
                     $pos2 = new Vector3($zom['x'], $zom['y'] - 1, $zom['z']);
                     //decline
                     $zom['up'] = 1;
                     $zom['yup'] = 0;
                 } else {
                     $zom['motionx'] = -$zom['motionx'];
                     $zom['motionz'] = -$zom['motionz'];
                     //He turned 180 degrees
                     $zom['up'] = 0;
                 }
             } else {
                 $pos2 = new Vector3($zom['x'] + $zom['motionx'], $zy - 1, $zom['z'] + $zom['motionz']);
                 //Target coordinates
                 if ($pos2->y - $zom['y'] < 0) {
                     $zom['up'] = 1;
                 } else {
                     $zom['up'] = 0;
                 }
             }
             if ($zom['motionx'] == 0 and $zom['motionz'] == 0) {
                 //Zombie stop
             } else {
                 //Steering computing
                 $yaw = $this->getyaw($zom['motionx'], $zom['motionz']);
                 //$zo->setRotation($yaw,0);
                 $zom['yaw'] = $yaw;
                 $zom['pitch'] = 0;
             }
             //Update zombie coordinates
             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";
         }
     }
 }
コード例 #6
0
ファイル: Level.php プロジェクト: orlando092/ImagicalMine
 public function spawnExperienceOrb(Vector3 $pos, $exp = 1)
 {
     $ExpPerBall = mt_rand(1, 5);
     while ($exp >= $ExpPerBall) {
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000), new Double("", $pos->getY()), new Double("", $pos->getZ() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Experience" => new Long("Experience", $exp)]);
         $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false);
         $expOrb = new ExperienceOrb($chunk, $nbt);
         $expOrb->spawnToAll();
         $exp -= $ExpPerBall;
         $ExpPerBall = mt_rand(1, 5);
     }
     if ($exp > 0) {
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000), new Double("", $pos->getY()), new Double("", $pos->getZ() + mt_rand(-1, 1) + mt_rand(100, 999) / 1000)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Experience" => new Long("Experience", $exp)]);
         $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false);
         $expOrb = new ExperienceOrb($chunk, $nbt);
         $expOrb->spawnToAll();
     }
 }
コード例 #7
0
ファイル: Level.php プロジェクト: xpyctum/Genisys
 public function addExperienceOrb(Vector3 $pos, $exp = 2)
 {
     if ($exp > 0) {
         $nbt = new CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $pos->getX()), new DoubleTag("", $pos->getY() + 0.5), new DoubleTag("", $pos->getZ())]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)]), "Experience" => new LongTag("Experience", $exp)]);
         $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false);
         $expOrb = new ExperienceOrb($chunk, $nbt);
         //$expBall->setExperience($exp);
         $expOrb->spawnToAll();
         return $expOrb;
     }
     return false;
 }
コード例 #8
0
ファイル: Level.php プロジェクト: xpyctum/PocketMinePlusPlus
 /**
  * @param Vector3 $source
  * @param Item    $item
  * @param Vector3 $motion
  * @param int     $delay
  */
 public function dropItem(Vector3 $source, Item $item, Vector3 $motion = \null, $delay = 10)
 {
     $motion = $motion === \null ? new Vector3(\lcg_value() * 0.2 - 0.1, 0.2, \lcg_value() * 0.2 - 0.1) : $motion;
     $itemTag = NBT::putItemHelper($item);
     $itemTag->setName("Item");
     if ($item->getId() > 0 and $item->getCount() > 0) {
         $itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4, \true), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $source->getX()), new Double("", $source->getY()), new Double("", $source->getZ())]), "Motion" => new Enum("Motion", [new Double("", $motion->x), new Double("", $motion->y), new Double("", $motion->z)]), "Rotation" => new Enum("Rotation", [new Float("", \lcg_value() * 360), new Float("", 0)]), "Health" => new Short("Health", 5), "Item" => $itemTag, "PickupDelay" => new Short("PickupDelay", $delay)]));
         $itemEntity->spawnToAll();
     }
 }
コード例 #9
0
 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');
         }
     }
 }
コード例 #10
0
 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;
 }
コード例 #11
0
ファイル: Main CN.php プロジェクト: diamond-gold/AreaPVP
 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;
 }
コード例 #12
0
ファイル: Cave.php プロジェクト: iTXTech/Genisys
 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);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #13
0
ファイル: Bazooka.php プロジェクト: EmreTr1/MineCombat
 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);
 }
コード例 #14
0
ファイル: Level.php プロジェクト: kniffo80/Genisys
 public function canBlockSeeSky(Vector3 $pos) : bool
 {
     return $this->getHighestBlockAt($pos->getFloorX(), $pos->getFloorZ()) < $pos->getY();
 }
コード例 #15
0
 /**
  * @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;
 }
コード例 #16
0
ファイル: Level.php プロジェクト: MateiGamingYTB/PocketEarth
 public function addExperienceOrb(Vector3 $pos, $exp = 2)
 {
     $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $pos->getX()), new Double("", $pos->getY()), new Double("", $pos->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "Experience" => new Long("Experience", $exp)]);
     $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false);
     $expBall = new ExperienceOrb($chunk, $nbt);
     //$expBall->setExperience($exp);
     $expBall->spawnToAll();
 }
コード例 #17
0
ファイル: Main.php プロジェクト: diamond-gold/AreaPVP
 public function canPVP(Vector3 $pp, Vector3 $p1, Vector3 $p2, $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;
 }
コード例 #18
0
ファイル: Animalworld.php プロジェクト: ianju/AnimalWorld
 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;
                                 }
                             }
                             if ($zom['motionx'] == 0 and $zom['motionz'] == 0) {
                                 //僵尸停止
                             } else {
                                 //转向计算
                                 $yaw = $this->getyaw($zom['motionx'], $zom['motionz']);
                                 //$zo->setRotation($yaw,0);
                                 $zom['yaw'] = $yaw;
                                 $zom['pitch'] = 0;
                             }
                             //更新僵尸坐标
                             $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);
                             $animal = $zom;
                             foreach ($this->getServer()->getOnlinePlayers() as $pl) {
                                 $pk2 = new RemoveEntityPacket();
                                 $pk2->eid = $animal['ID'];
                                 $pk3 = new AddEntityPacket();
                                 $pk3->eid = $animal['ID'];
                                 $pk3->type = $animal['type'];
                                 $pk3->x = $animal['x'];
                                 $pk3->y = $animal['y'];
                                 $pk3->z = $animal['z'];
                                 $pk3->pitch = $animal['pitch'];
                                 $pk3->yaw = $animal['yaw'];
                                 $pk3->metadata = [];
                                 $pl->dataPacket($pk2);
                                 $pl->dataPacket($pk3);
                             }
                             //echo "SetPosition \n";
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #19
0
 /**
  * @param Vector3 $v0
  * @param Vector3 $v1
  * @return bool
  */
 protected final function equals(Vector3 $v0, Vector3 $v1)
 {
     $out = true;
     $out = ($out and $v0->getX() === $v1->getX());
     $out = ($out and $v0->getY() === $v1->getY());
     $out = ($out and $v0->getZ() === $v1->getZ());
     if ($v0 instanceof Position and $v1 instanceof Position) {
         $out = ($out and $v0->getLevel()->getName() === $v1->getLevel()->getName());
     }
     return $out;
 }
コード例 #20
0
ファイル: BcTpMgr.php プロジェクト: DWWf/pocketmine-plugins
 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));
 }
コード例 #21
0
 protected function isInsideZone(Vector3 $test, Vector3 $a, Vector3 $b)
 {
     return $test->getX() >= $a->getX() && $test->getX() <= $b->getX() && $test->getY() >= $a->getY() && $test->getY() <= $b->getY() && $test->getZ() >= $a->getZ() && $test->getZ() <= $b->getZ();
 }
コード例 #22
0
ファイル: SkeletonAI.php プロジェクト: edwinyoo44/MyOwnWorld
 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";
                     }
                 }
             }
         }
     }
 }
コード例 #23
0
 public function isInside(Vector3 $v)
 {
     $out = true;
     $out = ($out and $this->baked0->getFloorX() <= $v->getX() and $v->getX() <= $this->baked1->getFloorX());
     $out = ($out and $this->baked0->getFloorY() <= $v->getY() and $v->getY() <= $this->baked1->getFloorY());
     $out = ($out and $this->baked0->getFloorZ() <= $v->getZ() and $v->getZ() <= $this->baked1->getFloorZ());
     if ($v instanceof Position) {
         $out = ($out and $this->baked0->getLevel()->getName() === $v->getLevel()->getName());
     }
     return $out;
 }
コード例 #24
0
ファイル: MyZombie.php プロジェクト: qq505916481/MyZombie
 public function ZombieRandomWalkCalc()
 {
     //计算行进路线
     foreach ($this->getServer()->getLevels() as $level) {
         foreach ($level->getEntities() as $zo) {
             if ($zo instanceof Zombie) {
                 if (count($zo->getViewers() != 0)) {
                     if (!isset($this->zombie[$zo->getId()])) {
                         $this->zombie[$zo->getId()] = array('ID' => $zo->getId(), 'IsChasing' => 0, 'motionx' => 0, 'motiony' => 0, 'motionz' => 0, 'hurt' => 10, 'time' => 10, 'x' => 0, 'y' => 0, 'z' => 0, 'yup' => 20, 'up' => 0, 'yaw' => $zo->yaw, 'level' => $zo->getLevel()->getName(), 'xxx' => 0, 'zzz' => 0);
                         $zom =& $this->zombie[$zo->getId()];
                         $zom['x'] = $zo->getX();
                         $zom['y'] = $zo->getY();
                         $zom['z'] = $zo->getZ();
                         $this->lz = $zo->getId() + 1;
                         $zo->setMaxHealth(15);
                     }
                     $zom =& $this->zombie[$zo->getId()];
                     if ($zom['IsChasing'] == "0") {
                         //自由行走模式
                         //限制转动幅度
                         $newmx = mt_rand(-5, 5) / 10;
                         while (abs($newmx - $zom['motionx']) >= 0.3) {
                             $newmx = mt_rand(-5, 5) / 10;
                         }
                         $zom['motionx'] = $newmx;
                         $newmz = mt_rand(-5, 5) / 10;
                         while (abs($newmz - $zom['motionz']) >= 0.3) {
                             $newmz = mt_rand(-5, 5) / 10;
                         }
                         $zom['motionz'] = $newmz;
                         //$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'] - 2, $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;
                             }
                         }
                         //转向计算
                         $yaw = $this->getyaw($zom['motionx'], $zom['motionz']);
                         //$zo->setRotation($yaw,0);
                         $zom['yaw'] = $yaw;
                         //更新僵尸坐标
                         $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";
                     }
                 }
             }
         }
     }
 }
コード例 #25
-1
ファイル: Level.php プロジェクト: RedstoneAlmeida/Steadfast2
 /**
  * @param Vector3 $source
  * @param Item    $item
  * @param Vector3 $motion
  * @param int     $delay
  */
 public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, $delay = 10)
 {
     $motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion;
     if ($item->getId() > 0 and $item->getCount() > 0) {
         $itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $source->getX()), new Double("", $source->getY()), new Double("", $source->getZ())]), "Motion" => new Enum("Motion", [new Double("", $motion->x), new Double("", $motion->y), new Double("", $motion->z)]), "Rotation" => new Enum("Rotation", [new Float("", lcg_value() * 360), new Float("", 0)]), "Health" => new Short("Health", 5), "Item" => new Compound("Item", ["id" => new Short("id", $item->getId()), "Damage" => new Short("Damage", $item->getDamage()), "Count" => new Byte("Count", $item->getCount())]), "PickupDelay" => new Short("PickupDelay", $delay)]));
         $itemEntity->spawnToAll();
     }
 }
コード例 #26
-1
ファイル: AIHolder.php プロジェクト: yungtechboy1/Genisys
 /**
  * @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) {
             return 'high';
         }
         return false;
     } elseif ($this->whatBlock($level, new Vector3($x, $y, $z)) == "climb") {
         //梯子
         //echo "前方梯子 \n";
         //return $y;
         if ($reason) {
             return 'climb';
         }
         if ($hate) {
             return $y + 0.7;
         } else {
             return $y + 0.5;
         }
     } else {
         //考虑向上
         //echo "考虑向上 ";
         if ($this->whatBlock($level, new Vector3($x, $y + 1, $z)) != "air") {
             //前方是面墙
             //echo "前方是墙 \n";
             if ($reason) {
                 return 'wall';
             }
             return false;
         } else {
             if ($this->whatBlock($level, new Vector3($x, $y + 2, $z)) == "block" or $this->whatBlock($level, new Vector3($x, $y + 2, $z)) == "half" or $this->whatBlock($level, new Vector3($x, $y + 2, $z)) == "high") {
                 //上方两格被堵住了
                 //echo "2格处被堵 \n";
                 if ($reason) {
                     return 'up2!';
                 }
                 return false;
             } else {
                 //echo "GO向上跳 \n";
                 if ($reason) {
                     return 'upGO';
                 }
                 return $y + 1;
                 //向上跳
             }
         }
     }
     return false;
 }