Example #1
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;
 }
Example #2
0
 /**
  * @param Entity $entity
  *
  * @throws \RuntimeException
  */
 public function addEntity(Entity $entity)
 {
     if ($entity->getLevel() !== $this) {
         throw new \RuntimeException("Invalid Entity level");
     }
     if ($entity instanceof Player) {
         $this->players[$entity->getID()] = $entity;
     }
     $this->entities[$entity->getID()] = $entity;
 }
Example #3
0
 public function isEntityExempted(Entity $entity)
 {
     return isset($this->exemptedEntities[$entity->getID()]);
 }