diff --git a/src/API/BlockAPI.php b/src/API/BlockAPI.php index 9569d988..ec5c59c3 100755 --- a/src/API/BlockAPI.php +++ b/src/API/BlockAPI.php @@ -298,12 +298,10 @@ class BlockAPI{ if($player instanceof Player){ $item = self::fromString(nullsafe($args[1], "")); if(($player->gamemode & 0x01) === 0x01){ - $output .= "Player is in creative mode."; - break; + return "Player is in creative mode."; } if($item->getID() === 0){ - $output .= "You cannot give an air block to a player."; - break; + return "You cannot give an air block to a player."; } if(!isset($args[2])){ diff --git a/src/entity/Living.php b/src/entity/Living.php index 87d9856c..ecb8fc93 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -26,7 +26,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{ public function hasPath(){ return $this->path != null; } - + public function eatGrass(){} public function __destruct() { parent::__destruct(); diff --git a/src/entity/ai/tasks/TaskBase.php b/src/entity/ai/tasks/TaskBase.php index a1f00294..9c0e4ffd 100644 --- a/src/entity/ai/tasks/TaskBase.php +++ b/src/entity/ai/tasks/TaskBase.php @@ -1,5 +1,5 @@ entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt")) { return false; } - return !$ai->entity->inPanic && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0; + return !$ai->entity->inPanic && !$ai->isStarted("TaskEatTileGoal")&& !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0; } diff --git a/src/entity/animal/Sheep.php b/src/entity/animal/Sheep.php index c6bbbf50..253f95ab 100644 --- a/src/entity/animal/Sheep.php +++ b/src/entity/animal/Sheep.php @@ -12,13 +12,13 @@ class Sheep extends Animal{ $this->data["Color"] = isset($this->data["Color"]) ? $this->data["Color"] : $this->sheepColor(); $this->setSpeed(0.25); $this->update(); - if($this->isSheared() and Entity::$updateOnTick){ //if ai enabled + /*if($this->isSheared() and Entity::$updateOnTick){ //if ai enabled $this->server->schedule(mt_rand(60, 400), [$this, "eatGrass"], null, true); //unknown time }elseif($this->isBaby() and Entity::$updateOnTick){ $this->server->schedule(mt_rand(400, 1000), [$this, "eatGrass"], null, true); //unknown time - } + }*/ + $this->ai->addTask(new TasKEatTileGoal()); } - public function createSaveData(){ $data = parent::createSaveData(); $data["Color"] = @$this->data["Color"]; @@ -27,7 +27,7 @@ class Sheep extends Animal{ } public function eatGrass(){ - $downBlock = $this->level->getBlock(new Vector3($this->x, $this->y-1, $this->z)); + /*$downBlock = $this->level->getBlock(new Vector3($this->x, $this->y-1, $this->z)); if($downBlock->getID() !== GRASS){ //console("eww i don't wanna eat this $downBlock"); return false; @@ -37,7 +37,13 @@ class Sheep extends Animal{ $pk->event = EntityEventPacket::ENTITY_ANIM_10; $this->server->api->player->broadcastPacket($this->level->players, $pk); $this->server->schedule(38, [$this, "setSheared"], false); - $this->level->setblock(new Position($this->x, $this->y-1, $this->z, $this->level), new DirtBlock()); + $this->level->setblock(new Position($this->x, $this->y-1, $this->z, $this->level), new DirtBlock());*/ + $this->setSheared(0); + if($this->isBaby()){ + $age = $this->getAge() + 1200; + if($age > 0) $age = 0; //TODO simplify + $this->setAge($age); + } } public function setSheared($v = null){ diff --git a/src/network/protocol/packet/EntityEventPacket.php b/src/network/protocol/packet/EntityEventPacket.php index c7faf41b..05cf7770 100644 --- a/src/network/protocol/packet/EntityEventPacket.php +++ b/src/network/protocol/packet/EntityEventPacket.php @@ -7,6 +7,12 @@ class EntityEventPacket extends RakNetDataPacket{ const ENTITY_DAMAGE = 2; const ENTITY_DEAD = 3; const ENTITY_ANIM_10 = 10; + + public function __construct($eid = null, $event = null){ + $this->eid = $eid; + $this->event = $event; + } + public function pid(){ return ProtocolInfo::ENTITY_EVENT_PACKET; }