This commit is contained in:
Sunch 2025-01-12 20:26:18 +08:00
parent 165388c8ae
commit 761ac69a20
13 changed files with 7 additions and 23 deletions

View file

@ -337,7 +337,6 @@ class BlockAPI{
$output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$issuer->username; $output .= "Giving ".$item->count." of ".$item->getName()." (".$item->getID().":".$item->getMetadata().") to ".$issuer->username;
break; break;
} }
break;
} }
return $output; return $output;
} }

View file

@ -92,7 +92,7 @@ class ConsoleAPI{
$end = strlen($line); $end = strlen($line);
} }
$cmd = strtolower(substr($line, 0, $end)); $cmd = strtolower(substr($line, 0, $end));
$params = (string) substr($line, $end + 1); $params = substr($line, $end + 1);
if(isset($this->alias[$cmd])){ if(isset($this->alias[$cmd])){
return $this->run($this->alias[$cmd] . ($params !== "" ? " " . $params : ""), $issuer, $cmd); return $this->run($this->alias[$cmd] . ($params !== "" ? " " . $params : ""), $issuer, $cmd);
} }

View file

@ -170,7 +170,6 @@ class LevelAPI{
} }
$issuer->entity->level->setSpawn(new Vector3($issuer->entity->x, $issuer->entity->y, $issuer->entity->z)); $issuer->entity->level->setSpawn(new Vector3($issuer->entity->x, $issuer->entity->y, $issuer->entity->z));
return ("Spawn set!"); return ("Spawn set!");
break;
case "save-all": case "save-all":
$output .= "Saving...\n"; $output .= "Saving...\n";
foreach($this->server->clients as $p){ foreach($this->server->clients as $p){

View file

@ -218,7 +218,6 @@ class PlayerAPI{
}else{ }else{
return "Usage: /$cmd [player]\n"; return "Usage: /$cmd [player]\n";
} }
break;
case "list": case "list":
$output .= "There are " . count($this->server->clients) . "/" . $this->server->maxClients . " players online:\n"; $output .= "There are " . count($this->server->clients) . "/" . $this->server->maxClients . " players online:\n";
if(count($this->server->clients) == 0){ if(count($this->server->clients) == 0){
@ -228,7 +227,6 @@ class PlayerAPI{
$output .= $c->username . ", "; $output .= $c->username . ", ";
} }
return substr($output, 0, -2) . "\n"; return substr($output, 0, -2) . "\n";
break;
case "loc": case "loc":
if(!($issuer instanceof Player)) return "Please run this command in-game."; if(!($issuer instanceof Player)) return "Please run this command in-game.";
$x = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP); $x = round($issuer->entity->x, 1, PHP_ROUND_HALF_UP);

View file

@ -22,7 +22,6 @@ class TimeAPI{
$output = ""; $output = "";
switch($cmd){ switch($cmd){
case "time": case "time":
$level = false;
if($issuer instanceof Player){ if($issuer instanceof Player){
$level = $issuer->level; $level = $issuer->level;
}else{ }else{

View file

@ -666,7 +666,7 @@ class Player{
public function sendInventorySlot($s){ public function sendInventorySlot($s){
$this->sendInventory(); $this->sendInventory();
return; return true;
$s = (int) $s; $s = (int) $s;
if(!isset($this->inventory[$s])){ if(!isset($this->inventory[$s])){
$pk = new ContainerSetSlotPacket; $pk = new ContainerSetSlotPacket;
@ -1727,7 +1727,7 @@ class Player{
$this->server->schedule(50, [$this, "measureLag"], [], true); $this->server->schedule(50, [$this, "measureLag"], [], true);
$pk = new SetTimePacket; $pk = new SetTimePacket;
$pk->time = (int) $this->level->getTime(); $pk->time = $this->level->getTime();
$pk->started = !$this->level->isTimeStopped(); $pk->started = !$this->level->isTimeStopped();
$this->dataPacket($pk); $this->dataPacket($pk);

View file

@ -39,11 +39,8 @@ class GrassBlock extends SolidBlock{
$chance = lcg_value() * 100; $chance = lcg_value() * 100;
if($chance <= 1){ if($chance <= 1){
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS,0,1), 10); ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(BEETROOT_SEEDS,0,1), 10);
return; }elseif($chance > 1 and $chance <= 16){
}
elseif($chance > 1 and $chance <= 16){
ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(SEEDS,0,1), 10); ServerAPI::request()->api->entity->drop(new Position($this->x+0.5, $this->y+1, $this->z+0.5, $this->level), BlockAPI::getItem(SEEDS,0,1), 10);
return;
} }
} }
public static function onRandomTick(Level $level, $x, $y, $z){ public static function onRandomTick(Level $level, $x, $y, $z){

View file

@ -61,7 +61,7 @@ class AsyncMultipleQueue extends Thread{
++$offset; ++$offset;
} }
} }
$this->input = (string) substr($this->input, $offset); $this->input = substr($this->input, $offset);
return $str; return $str;
} }
} }

View file

@ -109,7 +109,6 @@ class Config{
default: default:
$this->correct = false; $this->correct = false;
return false; return false;
break;
} }
if(!is_array($this->config)){ if(!is_array($this->config)){
$this->config = $default; $this->config = $default;
@ -247,7 +246,7 @@ class Config{
unset($this->correct); unset($this->correct);
unset($this->type); unset($this->type);
$this->load($this->file); $this->load($this->file);
$correct = $this->check(); $this->check();
} }
/** /**

View file

@ -67,7 +67,6 @@ class NBT{
default: default:
echo bin2hex(substr($this->binary, $this->offset - 1)) . PHP_EOL . PHP_EOL; echo bin2hex(substr($this->binary, $this->offset - 1)) . PHP_EOL . PHP_EOL;
die("Invalid NBT Tag $tag"); die("Invalid NBT Tag $tag");
break;
} }
$node[$name] = $value; $node[$name] = $value;
} }
@ -155,7 +154,6 @@ class NBT{
default: default:
echo bin2hex(substr($this->binary, $this->offset - 1)) . PHP_EOL . PHP_EOL; echo bin2hex(substr($this->binary, $this->offset - 1)) . PHP_EOL . PHP_EOL;
die("Invalid NBT Tag $tag"); die("Invalid NBT Tag $tag");
break;
} }
$node[] = $value; $node[] = $value;
} }

View file

@ -34,7 +34,6 @@ class Random{
$this->haveNextNextGaussian = false; $this->haveNextNextGaussian = false;
return $this->nextNextGaussian; return $this->nextNextGaussian;
}else{ }else{
$v1 = $v2 = $s = null;
do{ do{
$v1 = 2 * $this->nextFloat() - 1; // between -1.0 and 1.0 $v1 = 2 * $this->nextFloat() - 1; // between -1.0 and 1.0
$v2 = 2 * $this->nextFloat() - 1; // between -1.0 and 1.0 $v2 = 2 * $this->nextFloat() - 1; // between -1.0 and 1.0

View file

@ -549,7 +549,7 @@ class Level{
$curChunkZ = (int)$e->z >> 4; $curChunkZ = (int)$e->z >> 4;
$index = "$curChunkX $curChunkZ"; $index = "$curChunkX $curChunkZ";
if(isset($this->entityListPositioned[$index]) && isset($this->entityListPositioned[$index][$k])){ if(isset($this->entityListPositioned[$index][$k])){
unset($this->entityListPositioned[$index][$k]); unset($this->entityListPositioned[$index][$k]);
} }

View file

@ -7,10 +7,6 @@ class PocketChunkParser{
var $map; //21 * $sectorLength var $map; //21 * $sectorLength
private $location, $raw = b"", $file; private $location, $raw = b"", $file;
function __construct(){
$map = [];
}
public function loadFile($file){ public function loadFile($file){
if(file_exists($file . ".gz")){ if(file_exists($file . ".gz")){
$this->raw = gzinflate(file_get_contents($file . ".gz")); $this->raw = gzinflate(file_get_contents($file . ".gz"));