mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09: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
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue