Inheritance: extends pocketmine\level\Location, implements pocketmine\metadata\Metadatable
Example #1
5
 public function burstArrow(Player $player)
 {
     if ($player->getInventory()->getItemInHand()->getId() === Item::BOW) {
         $bow = $player->getInventory()->getItemInHand();
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $player->x), new Double("", $player->y + $player->getEyeHeight()), new Double("", $player->z)]), "Motion" => new Enum("Motion", [new Double("", -\sin($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI)), new Double("", -\sin($player->pitch / 180 * M_PI)), new Double("", \cos($player->yaw / 180 * M_PI) * \cos($player->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $player->yaw), new Float("", $player->pitch)])]);
         $ev = new EntityShootBowEvent($player, $bow, Entity::createEntity("Arrow", $player->chunk, $nbt, $player), 1.5);
         $this->getServer()->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             $ev->getProjectile()->kill();
         } else {
             $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
             if ($ev->getProjectile() instanceof Projectile) {
                 $this->getServer()->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                 if ($projectileEv->isCancelled()) {
                     $ev->getProjectile()->kill();
                 } else {
                     $this->object_hash[spl_object_hash($ev->getProjectile())] = 1;
                     $ev->getProjectile()->spawnToAll();
                 }
             } else {
                 $this->object_hash[spl_object_hash($ev->getProjectile())] = 1;
                 $ev->getProjectile()->spawnToAll();
             }
         }
     }
 }
Example #2
1
 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 30 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 200) {
         $this->attackDelay = 0;
         $f = 2;
         $yaw = $this->yaw + mt_rand(-220, 220) / 10;
         $pitch = $this->pitch + mt_rand(-120, 120) / 10;
         $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2), new DoubleTag("", $this->y + 2), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 2)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI) * $f), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
         $fireball = Entity::createEntity("FireBall", $this->chunk, $nbt, $this);
         if ($fireball instanceof FireBall) {
             $fireball->setExplode(true);
         }
         $fireball->setMotion($fireball->getMotion()->multiply($f));
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $fireball, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $projectile->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
Example #3
1
 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 25 && mt_rand(1, 12) < 3 && $this->distanceSquared($player) <= 40) {
         $this->attackDelay = 0;
         $f = 1.5;
         $yaw = $this->yaw + mt_rand(-180, 180) / 10;
         $pitch = $this->pitch + mt_rand(-90, 90) / 10;
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + 1.62), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $f), new Double("", -sin($pitch / 180 * M_PI) * $f), new Double("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * $f)]), "Rotation" => new Enum("Rotation", [new Float("", $yaw), new Float("", $pitch)])]);
         /** @var Projectile $arrow */
         $arrow = Entity::createEntity("Arrow", $this->chunk, $nbt, $this);
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $arrow, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $ev->getProjectile()->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
 public function canCollideWith(Entity $entity)
 {
     if ($entity instanceof Player) {
         return $entity instanceof Living && !$this->onGround && ($entity->getId() !== $this->getDataProperty(self::DATA_SHOOTER_ID) && ToAruPG::$pvpEnabled);
     }
     return $entity instanceof Living && !$this->onGround && $entity->getId() !== $this->getDataProperty(self::DATA_SHOOTER_ID);
 }
Example #5
0
 public function onEntityCollide(Entity $entity)
 {
     $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
     if ($entity->attack($ev->getFinalDamage(), $ev) === true) {
         $ev->useArmors();
     }
 }
Example #6
0
 public function onEntityCollide(Entity $entity)
 {
     if (abs($entity->motionY) < 0.1 && !$entity->isSneaking()) {
         (double) ($d0 = 0.4 + abs($entity->motionY) * 0.2);
         $entity->motionX *= $d0;
         $entity->motionZ *= $d0;
     }
 }
Example #7
0
 public function onEntityCollide(Entity $entity)
 {
     $entity->resetFallDistance();
     if ($entity->fireTicks > 0) {
         $entity->extinguish();
     }
     $entity->resetFallDistance();
 }
Example #8
0
 public function useOnEntity(Entity $entity, Entity $origin)
 {
     if ($entity instanceof Animal) {
         if ($entity->isLeashableType()) {
             $entity->setLeashHolder($origin);
         }
     }
 }
 protected function addAttackerModifiers(Entity $damager)
 {
     if ($damager->hasEffect(Effect::STRENGTH)) {
         $this->setDamage($this->getDamage(self::MODIFIER_BASE) * 0.3 * ($damager->getEffect(Effect::STRENGTH)->getAmplifier() + 1), self::MODIFIER_STRENGTH);
     }
     if ($damager->hasEffect(Effect::WEAKNESS)) {
         $this->setDamage(-($this->getDamage(self::MODIFIER_BASE) * 0.2 * ($damager->getEffect(Effect::WEAKNESS)->getAmplifier() + 1)), self::MODIFIER_WEAKNESS);
     }
 }
Example #10
0
 public function onEntityCollide(Entity $entity)
 {
     $entity->setOnFire(8);
     $ev = new EntityDamageEvent($entity, EntityDamageEvent::CAUSE_FIRE, 1);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->attack($ev->getFinalDamage(), $ev);
     }
 }
Example #11
0
 public function onEntityCollide(Entity $entity)
 {
     $entity->fallDistance = 0;
     if ($entity->fireTicks > 0) {
         $entity->extinguish();
     }
     if ($entity instanceof Player) {
         $entity->onGround = true;
     }
 }
Example #12
0
 public function onEntityCollide(Entity $entity)
 {
     if (!$entity->hasEffect(Effect::FIRE_RESISTANCE)) {
         $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
         $entity->attack($ev->getFinalDamage(), $ev);
     }
     $ev = new EntityCombustByBlockEvent($this, $entity, 8);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
 }
Example #13
0
 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isHoe()) {
         if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
             $this->meta++;
         }
     } elseif ($object instanceof Entity and !$this->isSword()) {
         $this->meta += 2;
     } else {
         $this->meta++;
     }
     return true;
 }
 protected function addAttackerModifiers(Entity $damager)
 {
     if ($damager->hasEffect(Effect::STRENGTH)) {
         $this->setRateDamage(1 + 0.3 * ($damager->getEffect(Effect::STRENGTH)->getAmplifier() + 1), self::MODIFIER_STRENGTH);
     }
     if ($damager->hasEffect(Effect::WEAKNESS)) {
         $eff_level = 1 - 0.2 * ($damager->getEffect(Effect::WEAKNESS)->getAmplifier() + 1);
         if ($eff_level < 0) {
             $eff_level = 0;
         }
         $this->setRateDamage($eff_level, self::MODIFIER_WEAKNESS);
     }
 }
Example #15
0
 public function onEntityCollide(Entity $entity)
 {
     $entity->fallDistance *= 0.5;
     $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
     $entity->attack($ev->getFinalDamage(), $ev);
     $ev = new EntityCombustByBlockEvent($this, $entity, 15);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
     if ($entity instanceof Player) {
         $entity->onGround = true;
     }
 }
 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  * @param 1 for break|2 for Touch $type
  *
  * @return bool
  */
 public function useOn($object, $type = 1)
 {
     if ($this->isUnbreakable()) {
         return true;
     }
     $unbreakingl = $this->getEnchantmentLevel(Enchantment::TYPE_MINING_DURABILITY);
     $unbreakingl = $unbreakingl > 3 ? 3 : $unbreakingl;
     if (mt_rand(1, $unbreakingl + 1) !== 1) {
         return true;
     }
     if ($type === 1) {
         if ($object instanceof Entity) {
             if ($this->isHoe() !== false or $this->isSword() !== false) {
                 //Hoe and Sword
                 $this->meta++;
                 return true;
             } elseif ($this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false) {
                 //Pickaxe Axe and Shovel
                 $this->meta += 2;
                 return true;
             }
             return true;
             //Other tool do not lost durability white hitting
         } elseif ($object instanceof Block) {
             if ($this->isShears() !== false) {
                 if ($object->getToolType() === Tool::TYPE_SHEARS) {
                     //This should be checked in each block
                     $this->meta++;
                 }
                 return true;
             } elseif ($object->getHardness() > 0) {
                 //Sword Pickaxe Axe and Shovel
                 if ($this->isSword() !== false) {
                     $this->meta += 2;
                     return true;
                 } elseif ($this->isPickaxe() !== false or $this->isAxe() !== false or $this->isShovel() !== false) {
                     $this->meta += 1;
                     return true;
                 }
             }
         }
     } elseif ($type === 2) {
         //For Touch. only trigger when OnActivate return true
         if ($this->isHoe() !== false or $this->id === self::FLINT_STEEL or $this->isShovel() !== false) {
             $this->meta++;
             return true;
         }
     }
     return true;
 }
Example #17
0
 public function kill()
 {
     parent::kill();
     foreach ($this->getDrops() as $i) {
         $this->getLevel()->dropItem($this, ItemItem::get($i[0], $i[1], $i[2]));
     }
 }
Example #18
0
 public function spawnTo(Player $player)
 {
     $pk = $this->addEntityDataPacket($player);
     $pk->type = self::NETWORK_ID;
     $player->dataPacket($pk);
     parent::spawnTo($player);
 }
Example #19
0
 public function kill()
 {
     parent::kill();
     foreach ($this->getDrops() as $item) {
         $this->getLevel()->dropItem($this, $item);
     }
 }
Example #20
0
 public function attackEntity(Entity $player)
 {
     if ($this->attackDelay > 23 && mt_rand(1, 32) < 4 && $this->distanceSquared($player) <= 55) {
         $this->attackDelay = 0;
         $f = 1.2;
         $yaw = $this->yaw + mt_rand(-220, 220) / 10;
         $pitch = $this->pitch + mt_rand(-120, 120) / 10;
         $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5), new DoubleTag("", $this->y + 1), new DoubleTag("", $this->z + cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI) * 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI)), new DoubleTag("", -sin($pitch / 180 * M_PI)), new DoubleTag("", cos($yaw / 180 * M_PI) * cos($pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $yaw), new FloatTag("", $pitch)])]);
         /** @var Projectile $snowball */
         $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
         $snowball->setMotion($snowball->getMotion()->multiply($f));
         $property = (new \ReflectionClass($snowball))->getProperty("damage");
         $property->setAccessible(true);
         $property->setValue($snowball, 2);
         $ev = new EntityShootBowEvent($this, Item::get(Item::ARROW, 0, 1), $snowball, $f);
         $this->server->getPluginManager()->callEvent($ev);
         $projectile = $ev->getProjectile();
         if ($ev->isCancelled()) {
             $projectile->kill();
         } elseif ($projectile instanceof Projectile) {
             $this->server->getPluginManager()->callEvent($launch = new ProjectileLaunchEvent($projectile));
             if ($launch->isCancelled()) {
                 $projectile->kill();
             } else {
                 $projectile->spawnToAll();
                 $this->level->addSound(new LaunchSound($this), $this->getViewers());
             }
         }
     }
 }
Example #21
0
 public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
 {
     if ($target->getId() == Block::MONSTER_SPAWNER) {
         return true;
     } else {
         $entity = null;
         $chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
         if (!$chunk instanceof FullChunk) {
             return false;
         }
         $nbt = new CompoundTag("", ["Pos" => new EnumTag("Pos", [new DoubleTag("", $block->getX() + 0.5), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ() + 0.5)]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", lcg_value() * 360), new FloatTag("", 0)])]);
         if ($this->hasCustomName()) {
             $nbt->CustomName = new StringTag("CustomName", $this->getCustomName());
         }
         $entity = Entity::createEntity($this->meta, $chunk, $nbt);
         if ($entity instanceof Entity) {
             if ($player->isSurvival()) {
                 --$this->count;
             }
             $entity->spawnToAll();
             return true;
         }
     }
     return false;
 }
Example #22
0
 public function onBreak(Item $item)
 {
     if ($this->getRandomExperience($item) > 0) {
         Entity::createEntity("ExperienceOrb", $this->level->getChunk($this->x >> 4, $this->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]))->spawnToAll();
     }
     return parent::onBreak($item);
 }
 public function prime()
 {
     $this->meta = 1;
     $mot = (new Random())->nextSignedFloat() * M_PI * 2;
     $tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x + 0.5), new DoubleTag("", $this->y), new DoubleTag("", $this->z + 0.5)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($mot) * 0.02), new DoubleTag("", 0.2), new DoubleTag("", -cos($mot) * 0.02)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)]), "Fuse" => new ByteTag("Fuse", 80)]));
     $tnt->spawnToAll();
     $this->level->addSound(new TNTPrimeSound($this));
 }
Example #24
0
 /**
  * @param Entity    $entity
  * @param int       $cause
  * @param int|int[] $damage
  *
  * @throws \Exception
  */
 public function __construct(Entity $entity, $cause, $damage)
 {
     $this->entity = $entity;
     $this->cause = $cause;
     if (is_array($damage)) {
         $this->modifiers = $damage;
     } else {
         $this->modifiers = [self::MODIFIER_BASE => $damage];
     }
     $this->originals = $this->modifiers;
     if (!isset($this->modifiers[self::MODIFIER_BASE])) {
         throw new \InvalidArgumentException("BASE Damage modifier missing");
     }
     if ($entity->hasEffect(Effect::DAMAGE_RESISTANCE)) {
         $this->setDamage(-($this->getDamage(self::MODIFIER_BASE) * 0.2 * ($entity->getEffect(Effect::DAMAGE_RESISTANCE)->getAmplifier() + 1)), self::MODIFIER_RESISTANCE);
     }
 }
Example #25
0
 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isUnbreakable()) {
         return false;
     }
     $break = true;
     if (($ench = $this->getEnchantment(Enchantment::TYPE_MINING_DURABILITY)) != null) {
         $rnd = mt_rand(1, 100);
         if ($rnd <= 100 / ($ench->getLevel() + 1)) {
             $break = false;
         }
     }
     if ($object instanceof Block) {
         if (!$break) {
             return false;
         }
         if ($object->getToolType() === Tool::TYPE_PICKAXE and $this->isPickaxe() or $object->getToolType() === Tool::TYPE_SHOVEL and $this->isShovel() or $object->getToolType() === Tool::TYPE_AXE and $this->isAxe() or $object->getToolType() === Tool::TYPE_SWORD and $this->isSword() or $object->getToolType() === Tool::TYPE_SHEARS and $this->isShears()) {
             $this->meta++;
         } elseif (!$this->isShears() and $object->getBreakTime($this) > 0) {
             $this->meta += 2;
         }
     } elseif ($this->isHoe()) {
         if (!$break) {
             return false;
         }
         if ($object instanceof Block and ($object->getId() === self::GRASS or $object->getId() === self::DIRT)) {
             $this->meta++;
         }
     } elseif ($object instanceof Entity) {
         $return = true;
         if (!$this->isSword()) {
             if ($break) {
                 $this->meta += 2;
                 $return = false;
             }
         } else {
             if ($break) {
                 $this->meta++;
                 $return = false;
             }
             if (!$this->hasEnchantments()) {
                 return $return;
             }
             //TODO: move attacking from player class here
             //$fire = $this->getEnchantment(Enchantment::TYPE_WEAPON_FIRE_ASPECT);
             //$object->setOnFire($fire->getLevel() * 4);
         }
     }
     return true;
 }
Example #26
0
 public static function dropExpOrb__api200(Position $source, $exp = 1, Vector3 $motion = \null, $delay = 40)
 {
     $motion = $motion === \null ? new Vector3(\lcg_value() * 0.2 - 0.1, 0.4, \lcg_value() * 0.2 - 0.1) : $motion;
     $entity = Entity::createEntity("ExperienceOrb", $source->getLevel()->getChunk($source->getX() >> 4, $source->getZ() >> 4, \true), new \pocketmine\nbt\tag\CompoundTag("", ["Pos" => new \pocketmine\nbt\tag\ListTag("Pos", [new \pocketmine\nbt\tag\DoubleTag("", $source->getX()), new \pocketmine\nbt\tag\DoubleTag("", $source->getY()), new \pocketmine\nbt\tag\DoubleTag("", $source->getZ())]), "Motion" => new \pocketmine\nbt\tag\ListTag("Motion", [new \pocketmine\nbt\tag\DoubleTag("", $motion->x), new \pocketmine\nbt\tag\DoubleTag("", $motion->y), new \pocketmine\nbt\tag\DoubleTag("", $motion->z)]), "Rotation" => new \pocketmine\nbt\tag\ListTag("Rotation", [new \pocketmine\nbt\tag\FloatTag("", \lcg_value() * 360), new \pocketmine\nbt\tag\FloatTag("", 0)]), "Health" => new \pocketmine\nbt\tag\ShortTag("Health", 20), "PickupDelay" => new \pocketmine\nbt\tag\ShortTag("PickupDelay", $delay)]));
     if ($entity instanceof ExperienceOrb) {
         $entity->setExp($exp);
     }
     $entity->spawnToAll();
 }
 public function onEntityCollide(Entity $entity)
 {
     $entity->fallDistance *= 0.5;
     $ProtectL = 0;
     if (!$entity->hasEffect(Effect::FIRE_RESISTANCE)) {
         $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
         if ($entity->attack($ev->getFinalDamage(), $ev) === true) {
             $ev->useArmors();
         }
         $ProtectL = $ev->getMaxEnchantLevel();
     }
     $ev = new EntityCombustByBlockEvent($this, $entity, 15, $ProtectL);
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
     $entity->resetFallDistance();
 }
Example #28
0
 public function onEnable()
 {
     Block::$creative[] = [self::RAILS, 0];
     Block::$creative[] = [self::POWERED_RAILS, 0];
     Block::$creative[] = [self::MINECART, 0];
     Block::$list[self::RAILS] = Rails::class;
     //Block::$list[self::POWERED_RAILS] = PoweredRails::class;
     Item::$list[self::MINECART] = MinecartItem::class;
     Entity::registerEntity(MinecartEntity::class);
 }
 public function onUpdate($type)
 {
     if ($type === Level::BLOCK_UPDATE_NORMAL) {
         $down = $this->getSide(Vector3::SIDE_DOWN);
         if ($down->getId() === self::AIR or $down instanceof Liquid) {
             $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x + 0.5), new Double("", $this->y), new Double("", $this->z + 0.5)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)]), "TileID" => new Int("TileID", $this->getId()), "Data" => new Byte("Data", $this->getDamage())]));
             $fall->spawnToAll();
         }
     }
 }
Example #30
0
 public function onEntityCollide(Entity $entity)
 {
     $ProtectL = 0;
     if (!$entity->hasEffect(Effect::FIRE_RESISTANCE)) {
         $ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
         if ($entity->attack($ev->getFinalDamage(), $ev) === true) {
             $ev->useArmors();
         }
         $ProtectL = $ev->getFireProtectL();
     }
     $ev = new EntityCombustByBlockEvent($this, $entity, 8, $ProtectL);
     if ($entity instanceof Arrow) {
         $ev->setCancelled();
     }
     Server::getInstance()->getPluginManager()->callEvent($ev);
     if (!$ev->isCancelled()) {
         $entity->setOnFire($ev->getDuration());
     }
 }