Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- declare(strict_types=1);
- namespace plugin\entity\type;
- use pocketmine\entity\Entity;
- use pocketmine\entity\EntitySizeInfo;
- use pocketmine\nbt\tag\CompoundTag;
- use pocketmine\entity\Location;
- use pocketmine\player\Player;
- use pocketmine\math\Vector3;
- use pocketmine\event\entity\EntityDamageEvent;
- // use pocketmine\entity\Human;
- // https://github.com/CustomiesDevs/Customies/wiki/Custom-Entities
- class DinosaurEntity extends Entity {
- public function __construct(Location $location) {
- $this->setNameTag("Dino");
- $this->setNameTagAlwaysVisible(true);
- parent::__construct($location);
- }
- // public function __construct(Location $location, ?CompoundTag $nbt = null) {
- // parent::__construct($location, $nbt);
- // $this->setNameTagVisible();
- // $this->setNameTagAlwaysVisible();
- // $this->setNameTag("zzzz");
- // }
- protected function getInitialSizeInfo() : EntitySizeInfo {
- return new EntitySizeInfo(0.0, 0.0);
- }
- protected function getInitialDragMultiplier() : float {
- return 0;
- }
- protected function getInitialGravity() : float {
- return 0;
- }
- public static function getNetworkTypeId() : string {
- return "alleva:dinosaur";
- }
- // public function onInteract(Player $player, Vector3 $clickPos) : bool{
- // $player->sendMessage("Hello, my friend!");
- // return true;
- // }
- // public function onInteract(Player $player, Vector3 $clickPos) : bool {
- // $player->sendMessage("Hello, my friend!");
- // }
- public function attack(EntityDamageEvent $source): void {
- parent::atack($source);
- if ($source instanceof EntityDamageByEntityEvent) {
- $player = $source->getDamager();
- $player->sendMessage("Hello");
- }
- }
- public function entityBaseTick(int $tickDiff = 1) : bool {
- return parent::entityBaseTick($tickDiff);
- }
- public function onUpdate(int $currentTick) : bool {
- // $this->server->getLogger()->info("onUpdate DinosaurEntity");
- if ($this->closed){
- return false;
- }
- $tickDiff = $currentTick - $this->lastUpdate;
- // $this->server->getLogger()->info((string)$tickDiff);
- // if($this->attackTime > 0) {
- $this->move($this->motion->x * $tickDiff, $this->motion->y, $this->motion->z * $tickDiff);
- $this->motion->y -= 0.2 * $tickDiff;
- $this->updateMovement();
- return true;
- // }
- // return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement