Advertisement
LA_

Untitled

LA_
May 12th, 2024 (edited)
539
0
2 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.59 KB | None | 0 0
  1. <?php
  2. declare(strict_types=1);
  3.  
  4. namespace plugin\entity\type;
  5.  
  6. use pocketmine\entity\Entity;
  7. use pocketmine\entity\EntitySizeInfo;
  8. use pocketmine\nbt\tag\CompoundTag;
  9. use pocketmine\entity\Location;
  10. use pocketmine\player\Player;
  11. use pocketmine\math\Vector3;
  12. use pocketmine\event\entity\EntityDamageEvent;
  13.  
  14. // use pocketmine\entity\Human;
  15.  
  16.  
  17. // https://github.com/CustomiesDevs/Customies/wiki/Custom-Entities
  18. class DinosaurEntity extends Entity {
  19.  
  20.     public function __construct(Location $location) {
  21.         $this->setNameTag("Dino");
  22.         $this->setNameTagAlwaysVisible(true);
  23.  
  24.         parent::__construct($location);
  25.     }
  26.  
  27.     // public function __construct(Location $location, ?CompoundTag $nbt = null) {
  28.     //     parent::__construct($location, $nbt);
  29.     //     $this->setNameTagVisible();
  30.     //     $this->setNameTagAlwaysVisible();
  31.     //     $this->setNameTag("zzzz");
  32.     // }
  33.  
  34.     protected function getInitialSizeInfo() : EntitySizeInfo {
  35.         return new EntitySizeInfo(0.0, 0.0);
  36.     }
  37.  
  38.     protected function getInitialDragMultiplier() : float {
  39.         return 0;
  40.     }
  41.  
  42.     protected function getInitialGravity() : float {
  43.         return 0;
  44.     }
  45.  
  46.     public static function getNetworkTypeId() : string {
  47.         return "alleva:dinosaur";
  48.     }
  49.  
  50.     // public function onInteract(Player $player, Vector3 $clickPos) : bool{
  51.     //     $player->sendMessage("Hello, my friend!");
  52.     //     return true;
  53.     // }
  54.  
  55.     // public function onInteract(Player $player, Vector3 $clickPos) : bool {
  56.     //     $player->sendMessage("Hello, my friend!");
  57.     // }
  58.  
  59.     public function attack(EntityDamageEvent $source): void {
  60.         parent::atack($source);
  61.         if ($source instanceof EntityDamageByEntityEvent) {
  62.             $player = $source->getDamager();
  63.             $player->sendMessage("Hello");
  64.         }
  65.     }
  66.  
  67.     public function entityBaseTick(int $tickDiff = 1) : bool {
  68.         return parent::entityBaseTick($tickDiff);
  69.     }
  70.  
  71.  
  72.     public function onUpdate(int $currentTick) : bool {
  73.         // $this->server->getLogger()->info("onUpdate DinosaurEntity");
  74.         if ($this->closed){
  75.             return false;
  76.         }
  77.         $tickDiff = $currentTick - $this->lastUpdate;
  78.         // $this->server->getLogger()->info((string)$tickDiff);
  79.         // if($this->attackTime > 0) {
  80.             $this->move($this->motion->x * $tickDiff, $this->motion->y, $this->motion->z * $tickDiff);
  81.             $this->motion->y -= 0.2 * $tickDiff;
  82.             $this->updateMovement();
  83.             return true;
  84.         // }
  85.         // return true;
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement