Example #1
0
 public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null)
 {
     $this->shootingEntity = $shootingEntity;
     if ($shootingEntity !== null) {
         $this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId());
     }
     parent::__construct($chunk, $nbt);
 }
Example #2
0
 /**
  * TODO: Move this to each item
  *
  * @param Entity|Block $object
  *
  * @return bool
  */
 public function useOn($object)
 {
     if ($this->isUnbreakable()) {
         return true;
     }
     if ($object instanceof Block) {
         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 ($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;
 }
Example #3
0
 /**
  * @param Entity $entity
  *
  * @throws LevelException
  */
 public function addEntity(Entity $entity)
 {
     if ($entity->getLevel() !== $this) {
         throw new LevelException("Invalid Entity level");
     }
     if ($entity instanceof Player) {
         $this->players[$entity->getId()] = $entity;
     }
     $this->entities[$entity->getId()] = $entity;
 }
Example #4
0
 public function removeEntity(Entity $entity)
 {
     unset($this->entities[$entity->getId()]);
     if (!$entity instanceof Player and $this->isInit) {
         $this->hasChanged = true;
     }
 }
Example #5
0
 public function unlinkEntity(Entity $entity)
 {
     if ($this->linkedTarget instanceof Entity) {
         $this->linkedTarget = null;
         $entity->islinked = false;
     }
     $pk = new SetEntityLinkPacket();
     $pk->from = $entity->getId();
     $pk->to = 0;
     $pk->type = 0;
     $this->dataPacket($pk);
     $this->islinked = false;
 }