mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
task tempt rework(should give a huge tps bump with a larg amount of entities), small stoptime fix
This commit is contained in:
parent
159d49ebf3
commit
4f9764dee3
6 changed files with 21 additions and 21 deletions
|
|
@ -70,7 +70,7 @@ class EntityAPI{
|
|||
}
|
||||
elseif(is_numeric($args[1])){//summon <mob> [amount]
|
||||
$amount = (int) $args[1];
|
||||
if($amount > 100){
|
||||
if($amount > 1000){
|
||||
return "Cannot spawn > 100 mobs";
|
||||
}
|
||||
$isBaby = false;
|
||||
|
|
@ -167,10 +167,7 @@ class EntityAPI{
|
|||
}
|
||||
|
||||
public function get($eid){
|
||||
if(isset($this->entities[$eid])){
|
||||
return $this->entities[$eid];
|
||||
}
|
||||
return false;
|
||||
return nullsafe($this->entities[$eid], false);
|
||||
}
|
||||
|
||||
public function remove($eid){
|
||||
|
|
|
|||
|
|
@ -1167,6 +1167,7 @@ class Player{
|
|||
$this->resendQueue = [];
|
||||
$this->ackQueue = [];
|
||||
$this->server->api->player->remove($this->CID);
|
||||
console($msg.":".$this->username.":".$this->spawned);
|
||||
if($msg === true and $this->username != "" and $this->spawned !== false){
|
||||
$this->server->api->chat->broadcast($this->username . " left the game: " . $reason);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -409,12 +409,12 @@ class Entity extends Position
|
|||
}
|
||||
}
|
||||
|
||||
$startX = (int) (round($this->x - 0.5) - 1);
|
||||
$startY = (int) (round($this->y) - 1);
|
||||
$startZ = (int) (round($this->z - 0.5) - 1);
|
||||
$endX = $startX + 2;
|
||||
$endY = $startY + 2;
|
||||
$endZ = $startZ + 2;
|
||||
$startX = $this->boundingBox->minX;
|
||||
$startY = $this->boundingBox->minY;
|
||||
$startZ = $this->boundingBox->minZ;
|
||||
$endX = $this->boundingBox->maxX;
|
||||
$endY = $this->boundingBox->maxY;
|
||||
$endZ = $this->boundingBox->maxZ;
|
||||
$waterDone = false;
|
||||
for ($y = $startY; $y <= $endY; ++$y){
|
||||
for ($x = $startX; $x <= $endX; ++$x){
|
||||
|
|
@ -432,7 +432,7 @@ class Entity extends Position
|
|||
$this->harm(2, "water");
|
||||
$hasUpdate = true;
|
||||
$waterDone = true;
|
||||
} elseif ($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1 - (($b->getMetadata() % 8) / 9)) and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER) and ! $waterDone) {
|
||||
} elseif ($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1 - (($b->getMetadata() % 8) / 9)) and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER) and !$waterDone) {
|
||||
$this->air -= 1;
|
||||
$waterDone = true;
|
||||
$this->updateMetadata();
|
||||
|
|
@ -463,7 +463,7 @@ class Entity extends Position
|
|||
}
|
||||
break;
|
||||
default:
|
||||
if ($this->inBlock($pos, 0.7) and $y == $endY and $b->isTransparent === false and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER)) {
|
||||
if ($this->inBlock($pos, 0.7) and $y == $endY and !$b->isTransparent and ($this->class === ENTITY_MOB or $this->class === ENTITY_PLAYER)) {
|
||||
$this->harm(1, "suffocation"); // Suffocation
|
||||
$hasUpdate = true;
|
||||
} elseif ($x == ($endX - 1) and $y == $endY and $z == ($endZ - 1)) {
|
||||
|
|
@ -576,7 +576,6 @@ class Entity extends Position
|
|||
$x1 = $x1 > 256 ? 256 : $x1;
|
||||
$y1 = $y1 > 128 ? 128 : $y1;
|
||||
$z1 = $z1 > 256 ? 256 : $z1;
|
||||
$waterDone = false;
|
||||
for($x = $x0; $x < $x1; ++$x){
|
||||
for($y = $y0; $y < $y1; ++$y){
|
||||
for($z = $z0; $z < $z1; ++$z){
|
||||
|
|
|
|||
|
|
@ -45,23 +45,26 @@ class TaskTempt extends TaskBase
|
|||
protected function findTarget($e, $r){
|
||||
$svd = null;
|
||||
$svdDist = -1;
|
||||
foreach($e->server->api->entity->getRadius($e, $r * 3, ENTITY_PLAYER) as $p){
|
||||
foreach($e->level->players as $p){
|
||||
$p = $p->entity;
|
||||
if(Utils::distance_noroot($e, $p) > $r*$r){
|
||||
continue;
|
||||
}
|
||||
if($svdDist === -1){
|
||||
$svdDist = Utils::manh_distance($e, $p);
|
||||
$svdDist = Utils::distance_noroot($e, $p);
|
||||
$svd = $p;
|
||||
continue;
|
||||
}
|
||||
if($svd != null && $svdDist === 0){
|
||||
$svd = $p;
|
||||
}
|
||||
|
||||
if(($cd = Utils::manh_distance($e, $p)) < $svdDist){
|
||||
if(($cd = Utils::distance_noroot($e, $p)) < $svdDist){
|
||||
$svdDist = $cd;
|
||||
$svd = $p;
|
||||
}
|
||||
}
|
||||
|
||||
if($svd == null || Utils::distance_noroot($e, $svd) > ($r * $r)){
|
||||
if($svd == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ class Utils{
|
|||
return round($number, 0, PHP_ROUND_HALF_DOWN);
|
||||
}
|
||||
/**
|
||||
* manhattan distance, less accurate, but still useful sometimes
|
||||
* manhattan distance
|
||||
*/
|
||||
public static function manh_distance($pos1, $pos2){
|
||||
if($pos1 instanceof Vector3){
|
||||
|
|
|
|||
|
|
@ -502,7 +502,7 @@ class Level{
|
|||
}
|
||||
$now = microtime(true);
|
||||
if($this->stopTime == true){
|
||||
|
||||
$time = $this->startTime;
|
||||
}else{
|
||||
$time = $this->startTime + ($now - $this->startCheck) * 20;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue