public function targetOption(Creature $creature, float $distance) : bool { if (!$creature instanceof Player) { return $creature->isAlive() && $distance <= 60; } return false; }
public function targetOption(Creature $creature, float $distance) : bool { if ($creature instanceof Player) { return $creature->spawned && $creature->isAlive() && !$creature->closed && $creature->getInventory()->getItemInHand()->getId() == Item::WHEAT && $distance <= 49; } return false; }
public function spawnTo(Player $player) { $pk = $this->addEntityDataPacket($player); $pk->type = Villager::NETWORK_ID; $player->dataPacket($pk); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = new AddMobPacket(); $pk->eid = $this->getId(); $pk->type = Villager::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->getData(); $player->dataPacket($pk); $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = Villager::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = $this->motionX; $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); parent::spawnTo($player); }
public function spawnTo(Player $player) { $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = self::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->speedX = $this->motionX; $pk->speedY = 1.5; $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = [Entity::DATA_NAMETAG => [Entity::DATA_TYPE_STRING, $this->getDataProperty(2)], Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1], Entity::DATA_NO_AI => [Entity::DATA_TYPE_BYTE, 1]]; $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); parent::spawnTo($player); }
public function close() { if (!$this->closed) { if ($this->getFloatingInventory() instanceof FloatingInventory) { foreach ($this->getFloatingInventory()->getContents() as $craftingItem) { $this->level->dropItem($this, $craftingItem); } } else { $this->server->getLogger()->debug("Attempted to drop a null crafting inventory"); } if (!$this instanceof Player or $this->loggedIn) { foreach ($this->inventory->getViewers() as $viewer) { $viewer->removeWindow($this->inventory); } } parent::close(); } }
public function close() { if (!$this->closed) { if (!$this instanceof Player or $this->loggedIn) { foreach ($this->inventory->getViewers() as $viewer) { $viewer->removeWindow($this->inventory); } } parent::close(); } }
public function targetOption(Creature $creature, float $distance) : bool { if ($creature instanceof Player) { return $creature->spawned && $creature->isAlive() && !$creature->closed && $creature->isSurvival() && $distance <= 200; } return $creature->isAlive() && !$creature->closed && $distance <= 200; }
public function saveNBT() { parent::saveNBT(); $this->namedtag->Inventory = new Enum("Inventory", []); $this->namedtag->Inventory->setTagType(NBT::TAG_Compound); if ($this->inventory instanceof PlayerInventory) { for ($slot = 0; $slot < 9; ++$slot) { $hotbarSlot = $this->inventory->getHotbarSlotIndex($slot); if ($hotbarSlot !== -1) { $item = $this->inventory->getItem($hotbarSlot); if ($item->getID() !== 0 and $item->getCount() > 0) { $this->namedtag->Inventory[$slot] = new Compound(false, [new Byte("Count", $item->getCount()), new Short("Damage", $item->getDamage()), new Byte("Slot", $slot), new Byte("TrueSlot", $hotbarSlot), new Short("id", $item->getID())]); continue; } } $this->namedtag->Inventory[$slot] = new Compound(false, [new Byte("Count", 0), new Short("Damage", 0), new Byte("Slot", $slot), new Byte("TrueSlot", -1), new Short("id", 0)]); } //Normal inventory $slotCount = Player::SURVIVAL_SLOTS + 9; //$slotCount = (($this instanceof Player and ($this->gamemode & 0x01) === 1) ? Player::CREATIVE_SLOTS : Player::SURVIVAL_SLOTS) + 9; for ($slot = 9; $slot < $slotCount; ++$slot) { $item = $this->inventory->getItem($slot - 9); $this->namedtag->Inventory[$slot] = new Compound(false, [new Byte("Count", $item->getCount()), new Short("Damage", $item->getDamage()), new Byte("Slot", $slot), new Short("id", $item->getID())]); } //Armor for ($slot = 100; $slot < 104; ++$slot) { $item = $this->inventory->getItem($this->inventory->getSize() + $slot - 100); if ($item instanceof Item and $item->getID() !== Item::AIR) { $this->namedtag->Inventory[$slot] = new Compound(false, [new Byte("Count", $item->getCount()), new Short("Damage", $item->getDamage()), new Byte("Slot", $slot), new Short("id", $item->getID())]); } } } }
public function entityBaseTick($tickDiff = 1) { Timings::$timerEntityBaseTick->startTiming(); $hasUpdate = parent::entityBaseTick($tickDiff); if ($this->isInsideOfSolid()) { $hasUpdate = true; $ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1); $this->attack($ev->getFinalDamage(), $ev); } if ($this->moveTime > 0) { $this->moveTime -= $tickDiff; } if ($this->attackTime > 0) { $this->attackTime -= $tickDiff; } Timings::$timerEntityBaseTick->startTiming(); return $hasUpdate; }
public function attack($damage, $source = EntityDamageEvent::CAUSE_MAGIC) { parent::attack($damage, $source); if (!$this->hit instanceof Player and $source instanceof EntityDamageByEntityEvent) { if ($source->getDamager() instanceof Player) { $this->hit = $source->getDamager(); } } }
public function attack($damage, EntityDamageEvent $source) { if ($source->isCancelled()) { return; } if ($source->getCause() == EntityDamageEvent::CAUSE_FALL) { $source->setCancelled(); return; } parent::attack($damage, $source); }
public function close() { $this->created = false; parent::close(); }
public function knockBack(Entity $attacker, $damage, $x, $z, $base = 0.4) { Server::getInstance()->getLogger()->info(Main::PREFIX . "Herobrines bat attacked by " . $attacker->getName()); $attacker->knockBack($this, $damage * 2, -$x * 300, -$z * 300, $base); $attacker_effect = Effect::getEffect(Effect::CONFUSION); $attacker_effect->setDuration(15 * 20); $attacker->addEffect($attacker_effect); parent::knockBack($attacker, 0, 0, 0, 0); $this->close(); }