mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 04:59:46 +00:00
sheep will eat grass now
This commit is contained in:
parent
4a58ac2ad8
commit
0d1fb47898
6 changed files with 22 additions and 12 deletions
|
|
@ -298,12 +298,10 @@ class BlockAPI{
|
||||||
if($player instanceof Player){
|
if($player instanceof Player){
|
||||||
$item = self::fromString(nullsafe($args[1], ""));
|
$item = self::fromString(nullsafe($args[1], ""));
|
||||||
if(($player->gamemode & 0x01) === 0x01){
|
if(($player->gamemode & 0x01) === 0x01){
|
||||||
$output .= "Player is in creative mode.";
|
return "Player is in creative mode.";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if($item->getID() === 0){
|
if($item->getID() === 0){
|
||||||
$output .= "You cannot give an air block to a player.";
|
return "You cannot give an air block to a player.";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($args[2])){
|
if(!isset($args[2])){
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
||||||
public function hasPath(){
|
public function hasPath(){
|
||||||
return $this->path != null;
|
return $this->path != null;
|
||||||
}
|
}
|
||||||
|
public function eatGrass(){}
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
parent::__destruct();
|
parent::__destruct();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
//TODO mutexBits
|
||||||
abstract class TaskBase
|
abstract class TaskBase
|
||||||
{
|
{
|
||||||
public $isStarted = false, $selfCounter = 0;
|
public $isStarted = false, $selfCounter = 0;
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ class TaskRandomWalk extends TaskBase
|
||||||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt")) {
|
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt")) {
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,13 @@ class Sheep extends Animal{
|
||||||
$this->data["Color"] = isset($this->data["Color"]) ? $this->data["Color"] : $this->sheepColor();
|
$this->data["Color"] = isset($this->data["Color"]) ? $this->data["Color"] : $this->sheepColor();
|
||||||
$this->setSpeed(0.25);
|
$this->setSpeed(0.25);
|
||||||
$this->update();
|
$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
|
$this->server->schedule(mt_rand(60, 400), [$this, "eatGrass"], null, true); //unknown time
|
||||||
}elseif($this->isBaby() and Entity::$updateOnTick){
|
}elseif($this->isBaby() and Entity::$updateOnTick){
|
||||||
$this->server->schedule(mt_rand(400, 1000), [$this, "eatGrass"], null, true); //unknown time
|
$this->server->schedule(mt_rand(400, 1000), [$this, "eatGrass"], null, true); //unknown time
|
||||||
}
|
}*/
|
||||||
|
$this->ai->addTask(new TasKEatTileGoal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createSaveData(){
|
public function createSaveData(){
|
||||||
$data = parent::createSaveData();
|
$data = parent::createSaveData();
|
||||||
$data["Color"] = @$this->data["Color"];
|
$data["Color"] = @$this->data["Color"];
|
||||||
|
|
@ -27,7 +27,7 @@ class Sheep extends Animal{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eatGrass(){
|
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){
|
if($downBlock->getID() !== GRASS){
|
||||||
//console("eww i don't wanna eat this $downBlock");
|
//console("eww i don't wanna eat this $downBlock");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -37,7 +37,13 @@ class Sheep extends Animal{
|
||||||
$pk->event = EntityEventPacket::ENTITY_ANIM_10;
|
$pk->event = EntityEventPacket::ENTITY_ANIM_10;
|
||||||
$this->server->api->player->broadcastPacket($this->level->players, $pk);
|
$this->server->api->player->broadcastPacket($this->level->players, $pk);
|
||||||
$this->server->schedule(38, [$this, "setSheared"], false);
|
$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){
|
public function setSheared($v = null){
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ class EntityEventPacket extends RakNetDataPacket{
|
||||||
const ENTITY_DAMAGE = 2;
|
const ENTITY_DAMAGE = 2;
|
||||||
const ENTITY_DEAD = 3;
|
const ENTITY_DEAD = 3;
|
||||||
const ENTITY_ANIM_10 = 10;
|
const ENTITY_ANIM_10 = 10;
|
||||||
|
|
||||||
|
public function __construct($eid = null, $event = null){
|
||||||
|
$this->eid = $eid;
|
||||||
|
$this->event = $event;
|
||||||
|
}
|
||||||
|
|
||||||
public function pid(){
|
public function pid(){
|
||||||
return ProtocolInfo::ENTITY_EVENT_PACKET;
|
return ProtocolInfo::ENTITY_EVENT_PACKET;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue