more entity optimizations

This commit is contained in:
GameHerobrine 2023-07-28 02:50:23 +03:00
parent 2b0ad36e14
commit 2d9b37aa9c
12 changed files with 44 additions and 62 deletions

View file

@ -211,11 +211,11 @@ class ConsoleAPI{
break;
case "status":
if(!($issuer instanceof Player) and $issuer === "console"){
$this->server->debugInfo(true);
$info = $this->server->debugInfo(true);
}else{
$info = $this->server->debugInfo();
}
$info = $this->server->debugInfo();
$output .= "TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . ")\n";
break;
return "TPS: " . $info["tps"] . ", Memory usage: " . $info["memory_usage"] . " (Peak " . $info["memory_peak_usage"] . ")";
case "stop":
$this->loop->stop = true;
$output .= "Stopping the server\n";
@ -228,8 +228,7 @@ class ConsoleAPI{
break;
}
$this->server->api->setProperty("difficulty", (int) $s);
$output .= "Difficulty changed to " . $this->server->difficulty . "\n";
break;
return "Difficulty changed to " . $this->server->difficulty . "\n";
case "?":
if($issuer !== "console" and $issuer !== "rcon"){
break;

View file

@ -191,7 +191,7 @@ class EntityAPI{
}
public function updateRadius(Position $center, $radius = 15, $class = false){
$this->server->query("UPDATE entities SET hasUpdate = 1 WHERE level = '" . $center->level->getName() . "' " . ($class !== false ? "AND class = $class " : "") . "AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
//useless now? $this->server->query("UPDATE entities SET hasUpdate = 1 WHERE level = '" . $center->level->getName() . "' " . ($class !== false ? "AND class = $class " : "") . "AND abs(x - {$center->x}) <= $radius AND abs(y - {$center->y}) <= $radius AND abs(z - {$center->z}) <= $radius;");
}
public function getRadius(Position $center, $radius = 15, $class = false){
@ -254,9 +254,9 @@ class EntityAPI{
"y" => $pos->y + 0.19,
"z" => $pos->z + mt_rand(-10, 10) / 50,
"level" => $pos->level,
"speedX" => Utils::randomFloat() * 0.2 - 0.1,
"speedX" => lcg_value() * 0.2 - 0.1,
"speedY" => 0.2,
"speedZ" => Utils::randomFloat() * 0.2 - 0.1,
"speedZ" => lcg_value() * 0.2 - 0.1,
"item" => $item,
];
if($this->server->api->handle("item.drop", $data) !== false){