
<?php
echo "PocketMine-MP plugin car v2.4.0
This file has been generated using DevTools v1.13.2 at Mon, 08 Jul 2019 23:44:39 +0930
----------------
";

if(extension_loaded("phar")){
	$phar = new \Phar(__FILE__);
	foreach($phar->getMetadata() as $key => $value){
		echo ucfirst($key) . ": " . (is_array($value) ? implode(", ", $value) : $value) . "\n";
	}
}

__HALT_COMPILER(); ?>
                a:9:{s:4:"name";s:3:"car";s:7:"version";s:5:"2.4.0";s:4:"main";s:14:"aieuo\car\Main";s:3:"api";s:5:"3.0.0";s:6:"depend";s:0:"";s:11:"description";s:0:"";s:7:"authors";s:0:"";s:7:"website";s:0:"";s:12:"creationDate";i:1562595279;}
   plugin.ymle   O#]e   D         src/aieuo/car/cars/Car.php  O#]  LE         src/aieuo/car/cars/Dolphin.phpn  O#]n  A?         src/aieuo/car/cars/Vehicle.php  O#]  Q          src/aieuo/car/Main.php  O#]  zN      ---
name: car
main: aieuo\car\Main
version: 2.4.0
api: 3.0.0
load: POSTWORLD
author: aieuo
...<?php

namespace aieuo\car\cars;

use pocketmine\Player;
use pocketmine\item\Item;

use pocketmine\block\Block;
use pocketmine\block\Slab;
use pocketmine\block\Stair;
use pocketmine\block\SignPost;
use pocketmine\block\Fence;
use pocketmine\block\FenceGate;
use pocketmine\block\Liquid;

class Car extends Vehicle {
	const NETWORK_ID = self::MINECART;

	public $height = 0.8;
	public $width = 0.98;

	public function jump() {
		if(!($this->player instanceof Player) or !$this->player->isOnline()) return false;
		switch ($this->player->getDirection()) {
			case 0:
				$pos = $this->add(1);
				break;
			case 1:
				$pos = $this->add(0, 0, 1);
				break;
			case 2:
				$pos = $this->add(-1);
				break;
			case 3:
				$pos = $this->add(0, 0, -1);
				break;
		}
		if($this->level->getBlock($pos->add(0, 1))->getId() !== 0) return false;
		$block = $this->level->getBlock($pos);
		if($block->getId() === 0) return false;
		if(
			$block instanceof SignPost
			or $block instanceof Fence
			or $block instanceof FenceGate
			or $block instanceof Liquid
		) {
			return false;
		}
        if($block instanceof Slab or $block instanceof Stair) {
            $this->motion->y = 1;
        }else{
            $this->motion->y = 2;
        }
		return true;
	}

	public function getDrops() : array{
		$drops = [
			Item::get(Item::MINECART, 0, 1)
		];
		return $drops;
	}
}
<?php

namespace aieuo\car\cars;

use pocketmine\Player;
use pocketmine\item\Item;

use pocketmine\block\Block;
use pocketmine\block\Slab;
use pocketmine\block\Stair;
use pocketmine\block\SignPost;
use pocketmine\block\Fence;
use pocketmine\block\FenceGate;
use pocketmine\block\Liquid;
use pocketmine\block\Water;
use pocketmine\block\AIR;

class Dolphin extends Vehicle {
    const NETWORK_ID = self::DOLPHIN;

    public $height = 0.7;
    public $width = 1.6;

    public function onUpdate(int $currentTick): bool {
        parent::onUpdate($currentTick);
        if($this->player instanceof Player) {
            if(!$this->player->isOnline()) {
                $this->onLeave();
                return false;
            }
            if(abs($this->x - $this->player->x) > 50 or abs($this->z - $this->player->z) > 50) {
                $this->onLeave();
                return false;
            }
            $this->motion->x = (-sin($this->player->yaw / 180 * M_PI) * ($this->brake ? cos($this->player->pitch / 180 * M_PI) : 1) * $this->getSpeed());
            $this->motion->z = (cos($this->player->yaw / 180 * M_PI) * ($this->brake ? cos($this->player->pitch / 180 * M_PI) : 1) * $this->getSpeed());
            $this->setRotation($this->player->yaw, 0);
            $jump = false;
            if($this->jump) $jump = $this->jump();
            if(!$jump) $this->motion->y -= 0.03999999910593033;
        } elseif($this->hasMovementUpdate()) {
            $this->speed *= 0.999;
            $this->motion->x *= 0.999;
            $this->motion->z *= 0.999;
        }
        return !$this->onGround or abs($this->motion->x) > 0.00001 or abs($this->motion->y) > 0.00001 or abs($this->motion->z) > 0.00001;
    }

    public function jump() {
        if(!($this->player instanceof Player) or !$this->player->isOnline()) return false;
        switch ($this->player->getDirection()) {
            case 0:
                $pos = $this->add(1);
                break;
            case 1:
                $pos = $this->add(0, 0, 1);
                break;
            case 2:
                $pos = $this->add(-1);
                break;
            case 3:
                $pos = $this->add(0, 0, -1);
                break;
        }
        $block = $this->level->getBlock($pos->add(0, 1));
        if(!($block instanceof AIR) and !($block instanceof Liquid)) return false;
        $block = $this->level->getBlock($pos);
        if($block->getId() === 0) return false;
        if(
            $block instanceof SignPost
            or $block instanceof Fence
            or $block instanceof FenceGate
        ) {
            return false;
        }
        if($block instanceof Slab or $block instanceof Stair) {
            $this->motion->y = 1;
        }else{
            $this->motion->y = 2;
        }
        return true;
    }
}
<?php

namespace aieuo\car\cars;

use pocketmine\Player;
use pocketmine\network\mcpe\protocol\SetEntityLinkPacket;
use pocketmine\network\mcpe\protocol\types\EntityLink;
use pocketmine\math\Vector3;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\entity\Vehicle as PMVehicle;

class Vehicle extends PMVehicle {
    public $gravity = 1.5;

    public $brake = true;
    public $jump = true;

    public $max_speed = 0.5;
    public $accel = 0.001;

    protected $speed = 0;

    protected $player = null;

    public function setMaxSpeed(float $speed) {
        $this->max_speed = $speed;
    }

    public function setAccel(float $accel) {
        $this->accel = $accel;
    }

    public function onLeave() {
        $this->player = null;
    }

    public function onRide($rider) {
        if($this->player instanceof Player and $this->player->isOnline()) return false;
        $this->player = $rider;

        $rider->getDataPropertyManager()->setVector3(self::DATA_RIDER_SEAT_POSITION, new Vector3(0, 1, 0));

        $pk = new SetEntityLinkPacket();
        $pk->link = new EntityLink($this->getId(), $rider->getId(), EntityLink::TYPE_PASSENGER);
        $rider->getServer()->broadcastPacket($rider->getServer()->getOnlinePlayers(), $pk);
        return true;
    }

    public function onUpdate(int $currentTick): bool {
        parent::onUpdate($currentTick);
        if($this->player instanceof Player) {
            if(!$this->player->isOnline()) {
                $this->onLeave();
                return false;
            }
            if(abs($this->x - $this->player->x) > 50 or abs($this->z - $this->player->z) > 50) {
                $this->onLeave();
                return false;
            }
            $this->motion->x = (-sin($this->player->yaw / 180 * M_PI) * ($this->brake ? cos($this->player->pitch / 180 * M_PI) : 1) * $this->getSpeed());
            $this->motion->z = (cos($this->player->yaw / 180 * M_PI) * ($this->brake ? cos($this->player->pitch / 180 * M_PI) : 1) * $this->getSpeed());
            $this->setRotation($this->player->yaw + 90, 0);
            $jump = false;
            if($this->jump) $jump = $this->jump();
            if(!$jump) $this->motion->y -= 0.03999999910593033;
        } elseif($this->hasMovementUpdate()) {
            $this->speed *= 0.999;
            $this->motion->x *= 0.999;
            $this->motion->z *= 0.999;
        }
        return !$this->onGround or abs($this->motion->x) > 0.00001 or abs($this->motion->y) > 0.00001 or abs($this->motion->z) > 0.00001;
    }

    public function getSpeed() {
        $this->speed += $this->accel;
        if($this->speed > $this->max_speed) $this->speed = $this->max_speed;
        return $this->speed;
    }

    public function attack(EntityDamageEvent $source) : void{
        parent::attack($source);

        if($source->isCancelled()) return;
        $this->kill();
    }
}<?php

namespace aieuo\car;

use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\event\Listener;
use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\utils\Config;
use pocketmine\event\entity\EntityTeleportEvent;
use pocketmine\event\entity\EntityLevelChangeEvent;
use pocketmine\event\player\PlayerDeathEvent;
use pocketmine\event\player\PlayerInteractEvent;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\network\mcpe\protocol\InteractPacket;
use pocketmine\network\mcpe\protocol\InventoryTransactionPacket;

use aieuo\car\cars\Vehivle;
use aieuo\car\cars\Dolphin;
use aieuo\car\cars\Car;

class Main extends PluginBase implements Listener {

	private $cars = [];

	public function onEnable() {
        $this->getServer()->getPluginManager()->registerEvents($this, $this);
        $this->config = new Config($this->getDataFolder()."config.yml", Config::YAML, [
        	"maxspeed" => 0.5,
        	"accel" => 0.004,
        	"brake" => true,
        	"段差を超える" => true
        ]);
        $this->config->save();
		Entity::registerEntity(Car::class, true, ["Car"]);
		Entity::registerEntity(Dolphin::class, true, ["DolphinCar"]);
	}

	public function onTouch(PlayerInteractEvent $event) {
		$item = $event->getItem();
		if($item->getId() == Item::MINECART) {
			$pos = $event->getBlock()->getSide($event->getFace());
			$this->spawnCar($pos, "Car");
		} elseif($item->getId() == Item::SPAWN_EGG and $item->getDamage() == Entity::DOLPHIN) {
			$pos = $event->getBlock()->getSide($event->getFace());
			$this->spawnCar($pos, "DolphinCar");
		}
	}

	public function spawnCar($pos, $entityname) {
		if(!$pos->level->isChunkLoaded($pos->x, $pos->y)) $pos->level->loadChunk($pos->x, $pos->y);
		$nbt = Entity::createBaseNBT($pos);
		$entity = Entity::createEntity($entityname, $pos->level, $nbt);
		$entity->spawnToAll();
		$entity->setMaxSpeed((float)$this->config->get("maxspeed"));
		$entity->setAccel((float)$this->config->get("accel"));
		$entity->brake = (boolean)$this->config->get("brake");
		$entity->jump = (boolean)$this->config->get("段差を超える");
	}

	public function onRecive(DataPacketReceiveEvent $event) {
		$pk = $event->getPacket();
		if($pk instanceof InventoryTransactionPacket) {
			if($pk->transactionType !== InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY) return;
			if($pk->trData->actionType !== InventoryTransactionPacket::USE_ITEM_ON_ENTITY_ACTION_INTERACT) return;

			$player = $event->getPlayer();
			$entity = $player->level->getEntity($pk->trData->entityRuntimeId);
			if(!($entity instanceof Car) and !($entity instanceof Dolphin)) return;

			if(isset($this->cars[$player->getName()])) {
				$this->cars[$player->getName()]->onLeave();
			}
			$this->cars[$player->getName()] = $entity;
			$entity->onRide($player);
		} elseif($pk instanceof InteractPacket) {
			if($pk->action == InteractPacket::ACTION_LEAVE_VEHICLE) {
				$player = $event->getPlayer();
				$this->checkLeaveCar($player);
			}
		}
	}

	public function checkLeaveCar($player) {
		if(isset($this->cars[$player->getName()])) {
			$this->cars[$player->getName()]->onLeave();
			unset($this->cars[$player->getName()]);
		}
	}

	public function onDeath(PlayerDeathEvent $event) {
		$player = $event->getPlayer();
		$this->checkLeaveCar($player);
	}

	public function onTeleport(EntityTeleportEvent $event) {
		$player = $event->getEntity();
		if($player instanceof Player) $this->checkLeaveCar($player);
	}

	public function onLevelChange(EntityLevelChangeEvent $event) {
		$player = $event->getEntity();
		if($player instanceof Player) $this->checkLeaveCar($player);
	}
}5-dRq$-%   GBMB