mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
uwu
This commit is contained in:
parent
60c8603c8b
commit
d0ec32dc02
5 changed files with 22 additions and 16 deletions
|
|
@ -5,7 +5,9 @@ class Entity extends Position
|
|||
|
||||
const TYPE = - 1;
|
||||
const CLASS_TYPE = - 1;
|
||||
|
||||
|
||||
public $counter = 0;
|
||||
|
||||
public static $updateOnTick, $allowedAI;
|
||||
public $isCollidable;
|
||||
public $canBeAttacked;
|
||||
|
|
@ -487,7 +489,6 @@ class Entity extends Position
|
|||
return;
|
||||
}
|
||||
$tdiff = $now - $this->lastUpdate;
|
||||
|
||||
if($this->tickCounter === 0){
|
||||
$this->tickCounter = 1;
|
||||
$hasUpdate = $this->environmentUpdate();
|
||||
|
|
@ -499,7 +500,7 @@ class Entity extends Position
|
|||
if($this->closed === true){
|
||||
return false;
|
||||
}
|
||||
|
||||
++$this->counter;
|
||||
if($this->isStatic === false){
|
||||
$startX = floor($this->x - 0.5 - $this->width - 1);
|
||||
// prefix for flying when player on fence
|
||||
|
|
@ -510,6 +511,7 @@ class Entity extends Position
|
|||
$endZ = ceil($this->z - 0.5 + $this->width + 1);
|
||||
$support = false;
|
||||
$isFlying = true;
|
||||
|
||||
if($this->isPlayer()){
|
||||
for($z = $startZ; $z <= $endZ; ++ $z){
|
||||
for($x = $startX; $x <= $endX; ++ $x){
|
||||
|
|
@ -569,9 +571,9 @@ class Entity extends Position
|
|||
$y1 = $y1 > 128 ? 128 : $y1;
|
||||
$z1 = $z1 > 256 ? 256 : $z1;
|
||||
$waterDone = false;
|
||||
for($x = $x0; $x < $x1; ++ $x){
|
||||
for($x = $x0 - 1; $x < $x1 + 1; ++ $x){
|
||||
for($y = $y0; $y < $y1; ++ $y){
|
||||
for($z = $z0; $z < $z1; ++ $z){
|
||||
for($z = $z0 - 1; $z < $z1 + 1; ++ $z){
|
||||
$pos = new Vector3($x, $y, $z);
|
||||
$b = $this->level->getBlock($pos);
|
||||
switch($b->getID()) {
|
||||
|
|
@ -623,7 +625,7 @@ class Entity extends Position
|
|||
}
|
||||
break;
|
||||
}
|
||||
if($b != false && $b->boundingBox->intersectsWith($aABB) && $b->isSolid && $this->isMoving()){
|
||||
if($this->isMoving() && $b != false && $b->isSolid && $b->boundingBox->intersectsWith($aABB)){
|
||||
$this->speedX = $b->boundingBox->calculateXOffset($this->boundingBox, $this->speedX);
|
||||
$this->speedZ = $b->boundingBox->calculateZOffset($this->boundingBox, $this->speedZ);
|
||||
$lastY = $this->speedY;
|
||||
|
|
@ -721,9 +723,9 @@ class Entity extends Position
|
|||
// $this->speedZ = 0;
|
||||
$this->server->api->handle("entity.move", $this);
|
||||
$update = true;
|
||||
}elseif($this->lastYaw != $this->yaw || $this->lastPitch != $this->pitch){
|
||||
$update = true;
|
||||
}
|
||||
}elseif ($this->lastYaw != $this->yaw || $this->lastPitch != $this->pitch) {
|
||||
$update = true;
|
||||
}
|
||||
|
||||
if($update === true){
|
||||
$hasUpdate = true;
|
||||
|
|
|
|||
|
|
@ -42,4 +42,11 @@ abstract class Living extends Entity implements Damageable, Pathfindable{
|
|||
parent::update();
|
||||
}
|
||||
|
||||
public function sendMoveUpdate(){
|
||||
if($this->counter % 3 != 0){
|
||||
return;
|
||||
}
|
||||
parent::sendMoveUpdate();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,8 +18,6 @@ class EntityAI
|
|||
|
||||
public $lastTask;
|
||||
|
||||
public $counter = 0;
|
||||
|
||||
public function __construct($entity){
|
||||
$this->entity = $entity;
|
||||
$this->tasks = [];
|
||||
|
|
@ -49,9 +47,6 @@ class EntityAI
|
|||
}
|
||||
|
||||
public function updateTasks(){
|
||||
if($this->counter % 3 != 0){
|
||||
return;
|
||||
}
|
||||
foreach($this->tasks as $t){
|
||||
if(!$t->isStarted && $t->canBeExecuted($this)){
|
||||
$t->isStarted = true;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class MobController
|
|||
$dz = $d->z;
|
||||
|
||||
$tan = $dz == 0 ? ($dx < 0 ? 180 : 0) : (90 - rad2deg($dx / $dz));
|
||||
$thetaOffset = $dz < 0 ? 90 : 270;
|
||||
$thetaOffset = $dz <= 0 ? 90 : 270;
|
||||
$this->entity->yaw = $this->entity->headYaw = ($thetaOffset + $tan);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
$this->target = $this->findTarget($ai->entity, 6); //TODO max distance for different mobs
|
||||
if(!($this->target instanceof Entity) || !$this->target->isPlayer()){
|
||||
$this->reset();
|
||||
$this->onEnd($ai);
|
||||
return;
|
||||
}
|
||||
$this->yaw = $ai->entity->yaw;
|
||||
|
|
@ -44,12 +45,13 @@ class TaskLookAtPlayer extends TaskBase{
|
|||
public function onUpdate(EntityAI $ai){
|
||||
if(!($this->target instanceof Entity) || Utils::distance($ai->entity, $this->target) > 6 || $this->target->level->getName() != $ai->entity->level->getName()){ //TODO max distance for different mobs
|
||||
$this->reset();
|
||||
$this->onEnd($ai);
|
||||
return;
|
||||
}
|
||||
$ai->mobController->lookOn($this->target);
|
||||
$this->selfCounter--;
|
||||
}
|
||||
|
||||
|
||||
public function onEnd(EntityAI $ai){
|
||||
unset($this->target);
|
||||
$ai->entity->pitch = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue