mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 20:19:44 +00:00
better breeding, baby entities will follow their parent
This commit is contained in:
parent
eff034e897
commit
eab6573b84
10 changed files with 64 additions and 7 deletions
44
src/entity/ai/tasks/TaskFollowParent.php
Normal file
44
src/entity/ai/tasks/TaskFollowParent.php
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
class TaskFollowParent extends TaskBase
|
||||
{
|
||||
public function __construct($speed){
|
||||
$this->speedMultiplier = $speed;
|
||||
}
|
||||
|
||||
public function onStart(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 1;
|
||||
}
|
||||
|
||||
public function onEnd(EntityAI $ai)
|
||||
{
|
||||
$this->selfCounter = 0;
|
||||
}
|
||||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if(!$ai->entity->isBaby() || !($ai->entity->parent instanceof Entity) && $ai->entity->parent->dead){
|
||||
$this->reset();
|
||||
$ai->entity->parent = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
$dist = $ai->entity->distanceSquared($ai->entity->parent);
|
||||
|
||||
if($dist > 256 || $dist < 9){ //3-16 blocks
|
||||
$this->reset();
|
||||
return false;
|
||||
}
|
||||
$parent = $ai->entity->parent;
|
||||
|
||||
$ai->mobController->setLookPosition($parent->x, $parent->y + $parent->getEyeHeight(), $parent->z, 30, $ai->entity->getVerticalFaceSpeed());
|
||||
$ai->mobController->setMovingTarget($parent->x, $parent->y, $parent->z, $this->speedMultiplier);
|
||||
}
|
||||
|
||||
public function canBeExecuted(EntityAI $ai)
|
||||
{
|
||||
return $ai->entity->isBaby() && !$ai->entity->parent->dead; //TODO find a new parent if the current one is dead
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +46,9 @@ class TaskMate extends TaskBase
|
|||
//this.theAnimal.setGrowingAge(6000); TODO growing age?
|
||||
//this.targetMate.setGrowingAge(6000);
|
||||
|
||||
$ai->entity->loveTimeout = 6000;
|
||||
$entpar2->loveTimeout = 6000;
|
||||
|
||||
$ai->entity->resetInLove();
|
||||
$entpar2->resetInLove();
|
||||
$baby->setAge(-24000);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class TaskRandomWalk extends TaskBase
|
|||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->isStarted("TaskTempt")) {
|
||||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->isStarted("TaskTempt") || $ai->isStarted("TaskFollowParent") ) {
|
||||
$this->reset();
|
||||
return false; //TODO Better way: block movement
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ class TaskRandomWalk extends TaskBase
|
|||
if(($ai->entity instanceof Creeper && $ai->entity->isIgnited()) || $ai->entity->hasPath() || $ai->isStarted("TaskTempt") ||$ai->isStarted("TaskAttackPlayer")) {
|
||||
return false;
|
||||
} // i really need mutexBits
|
||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||
return !$ai->entity->inPanic && !$ai->isStarted("TaskMate") && !$ai->isStarted("TaskEatTileGoal") && !$ai->isStarted("TaskLookAround") && !$ai->isStarted("TaskFollowParent") && !$ai->isStarted("TaskLookAtPlayer") && mt_rand(0, 120) == 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class TaskTempt extends TaskBase
|
|||
|
||||
public function onUpdate(EntityAI $ai)
|
||||
{
|
||||
if(!$this->isTargetValid($ai)){
|
||||
if(!$this->isTargetValid($ai) || $ai->entity->inPanic || $ai->isStarted("TaskMate")){
|
||||
$this->reset();
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue