<?php echo 'Phar compiled on https://pmt.mcpe.fun.'; __HALT_COMPILER(); ?>
                a:6:{s:4:"name";s:10:"HomingHook";s:4:"main";s:24:"hototya\monst\HomingHook";s:7:"version";s:5:"1.0.0";s:3:"api";a:3:{i:0;s:5:"3.0.0";i:1;s:12:"3.0.0-ALPHA9";i:2;s:13:"3.0.0-ALPHA10";}s:4:"load";s:9:"POSTWORLD";s:6:"author";s:7:"hototya";}    src/hototya/monst/HomingHook.php  ąKZ  ɇ      &   src/hototya/monst/EntityHomingHook.phpk  ąKZk  e:5      	   README.md   ąKZ   Qn      
   plugin.yml   ąKZ   8Ӷ         LICENSE(  ąKZ(  G.      <?php
namespace hototya\monst;

use pocketmine\plugin\PluginBase;

use pocketmine\event\Listener;
use pocketmine\event\player\PlayerInteractEvent;

use pocketmine\item\ItemIds;
use pocketmine\entity\Entity;
use pocketmine\math\Vector3;

class HomingHook extends PluginBase implements Listener
{

    public function onLoad()
    {
        Entity::registerEntity(EntityHomingHook::class, false, ['Hominghook', 'minecraft:hominghook']);
    }

    public function onEnable()
    {
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }

    public function onPlayerHold(PlayerInteractEvent $event)
    {
        $action = $event->getAction();
        $item = $event->getItem();
        if ($action === PlayerInteractEvent::RIGHT_CLICK_AIR || $action === PlayerInteractEvent::LEFT_CLICK_AIR) {
            if ($item->getId() === ItemIds::FISHING_ROD) {
                //$item->setDamage($item->getDamage() - 1);
                $player = $event->getPlayer();
                $entity = Entity::createEntity("Hominghook", $player->level, Entity::createBaseNBT(
                    $player->add($player->getDirectionVector())->add(0, $player->getEyeHeight()),
                    new Vector3(
                        -sin($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI),
                        -sin($player->pitch / 180 * M_PI),
                        cos($player->yaw / 180 * M_PI) * cos($player->pitch / 180 * M_PI))));
                if ($entity instanceof EntityHomingHook) {
                    foreach ($player->getViewers() as $view) {
                        $entity->setTarget($view);
                        break;
                    }
                }
                $entity->spawnToAll();
            }
        }
    }
}<?php
namespace hototya\monst;

use pocketmine\entity\projectile\Throwable;

use pocketmine\Player;
use pocketmine\math\Vector3;
use pocketmine\level\particle\Particle;

class EntityHomingHook extends Throwable
{
    public const NETWORK_ID = self::FISHING_HOOK;

    private $target;

    public function entityBaseTick(int $tickDiff = 1): bool
    {
        if ($this->closed){
            return false;
        }
        $hasUpdate = parent::entityBaseTick($tickDiff);
        if ($this->age > 1200 or $this->isCollided) {
            $this->flagForDespawn();
            $hasUpdate = true;
        }
        if ($this->target !== null) {
            $this->gravity = 0.0;
            $this->pitch = rad2deg(atan2($this->y - $this->target->y - 2, sqrt(($this->x  - $this->target->x) ** 2 + ($this->z - $this->target->z) ** 2)));
            $this->yaw = rad2deg(atan2($this->z - $this->target->z, $this->x - $this->target->x)) + 90;
            $this->setMotion($this->getDirectionVector());
        }
        return $hasUpdate;
    }

    public function setTarget(Player $player)
    {
        $this->target = $player;
    }
}# HomingHook
プレイヤー追尾弾  
釣り竿を持って長押しするとプレイヤー追尾弾が発射されるぞ！  
※プレイヤーが見当たらないと追尾はできません
name: HomingHook
main: hototya\monst\HomingHook
version: 1.0.0
api:
  - 3.0.0
  - 3.0.0-ALPHA9
  - 3.0.0-ALPHA10
load: POSTWORLD
author: hototyaMIT License

Copyright (c) 2018 hototya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
xX--eP8   GBMB