php8.2 fixes

This commit is contained in:
GameHerobrine 2023-07-03 07:10:04 +03:00
parent d7d346a237
commit 6d89c50e43
13 changed files with 33 additions and 26 deletions

View file

@ -3,7 +3,7 @@
class ConsoleAPI{ class ConsoleAPI{
private $loop, $server, $event, $help, $cmds, $alias; private $loop, $server, $event, $help, $cmds, $alias;
public $last;
function __construct(){ function __construct(){
$this->help = []; $this->help = [];
$this->cmds = []; $this->cmds = [];

View file

@ -4,7 +4,7 @@ class EntityAPI{
public $entities; public $entities;
private $server; private $server;
private $eCnt = 1; private $eCnt = 1;
public $serverSpawnAnimals, $serverSpawnMobs;
function __construct(){ function __construct(){
$this->entities = []; $this->entities = [];
$this->server = ServerAPI::request(); $this->server = ServerAPI::request();

View file

@ -57,6 +57,11 @@ class ServerAPI{
*/ */
public $plugin; public $plugin;
/**
* @var QueryHandler
*/
public $query;
private $asyncCalls = []; private $asyncCalls = [];
private $server; private $server;
private $config; private $config;

View file

@ -9,7 +9,7 @@ class PocketMinecraftServer{
*/ */
public $api; public $api;
private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0; private $serverip, $evCnt, $handCnt, $events, $eventsID, $handlers, $serverType, $lastTick, $memoryStats, $async = [], $asyncID = 0;
public $levelData, $doTick, $difficulty, $tiles, $entities, $schedule, $scheduleCnt, $whitelist, $spawn, $asyncThread, $stop;
function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){ function __construct($name, $gamemode = SURVIVAL, $seed = false, $port = 19132, $serverip = "0.0.0.0"){
$this->port = (int) $port; $this->port = (int) $port;
$this->doTick = true; $this->doTick = true;

View file

@ -7,7 +7,7 @@ class Entity extends Position
const CLASS_TYPE = - 1; const CLASS_TYPE = - 1;
public $counter = 0; public $counter = 0;
public $invincible, $status, $health, $fire, $crouched, $position, $meta, $stack;
public static $updateOnTick, $allowedAI; public static $updateOnTick, $allowedAI;
public $isCollidable; public $isCollidable;
public $canBeAttacked; public $canBeAttacked;

View file

@ -5,7 +5,7 @@ class MinecraftInterface{
public $bandwidth; public $bandwidth;
private $socket; private $socket;
private $packets; private $packets;
public $start, $stop;
function __construct($server, $port = 25565, $serverip = "0.0.0.0"){ function __construct($server, $port = 25565, $serverip = "0.0.0.0"){
$this->socket = new UDPSocket($server, $port, true, $serverip); $this->socket = new UDPSocket($server, $port, true, $serverip);
if($this->socket->connected === false){ if($this->socket->connected === false){

View file

@ -3,7 +3,7 @@
class UDPSocket{ class UDPSocket{
public $connected, $sock, $server; public $connected, $sock, $server;
public $port;
function __construct($server, $port, $listen = false, $serverip = "0.0.0.0"){ function __construct($server, $port, $listen = false, $serverip = "0.0.0.0"){
$this->server = $server; $this->server = $server;
$this->port = $port; $this->port = $port;

View file

@ -3,7 +3,7 @@
class RakNetCodec{ class RakNetCodec{
public $packet; public $packet;
public $buffer;
public function __construct(RakNetPacket $packet){ public function __construct(RakNetPacket $packet){
$this->packet = $packet; $this->packet = $packet;
$this->buffer = &$this->packet->buffer; $this->buffer = &$this->packet->buffer;

View file

@ -5,6 +5,7 @@ define("PMF_CURRENT_LEVEL_VERSION", 0x01);
class PMFLevel extends PMF{ class PMFLevel extends PMF{
public $isLoaded = true; public $isLoaded = true;
public $level;
public $levelData = []; public $levelData = [];
private $locationTable = []; private $locationTable = [];
private $log = 4; private $log = 4;

View file

@ -4,6 +4,7 @@
class Random{ class Random{
public $x, $y, $z, $w; public $x, $y, $z, $w;
public $i, $j, $state;
public $haveNextNextGaussian = false; public $haveNextNextGaussian = false;
public $nextNextGaussian = 0; public $nextNextGaussian = 0;

View file

@ -18,7 +18,7 @@ class Level{
* @var Entity[] * @var Entity[]
*/ */
public $entityList; public $entityList;
public $tiles, $blockUpdates, $nextSave, $players = [], $level; public $tiles, $blockUpdates, $nextSave, $players = [], $level, $mobSpawner;
private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime; private $time, $startCheck, $startTime, $server, $name, $usedChunks, $changedBlocks, $changedCount, $stopTime;
private $generator; private $generator;
@ -397,7 +397,7 @@ class Level{
foreach($eids as $cid => $_){ foreach($eids as $cid => $_){
$p = $this->server->clients[$cid] ?? false; $p = $this->server->clients[$cid] ?? false;
if($p instanceof Player){ if($p instanceof Player){
$dist = abs($xz[0] - ($p->entity->x >> 4)) + abs($xz[1] - ($p->entity->z >> 4)); $dist = abs($xz[0] - (((int)$p->entity->x) >> 4)) + abs($xz[1] - (((int)$p->entity->z) >> 4));
if($dist > 8){ if($dist > 8){
//ConsoleAPI::debug("{$p->player} freeing chunk: {$xz[0]} {$xz[1]}"); //ConsoleAPI::debug("{$p->player} freeing chunk: {$xz[0]} {$xz[1]}");
$this->freeChunk($xz[0], $xz[1], $p); $this->freeChunk($xz[0], $xz[1], $p);

View file

@ -10,28 +10,28 @@ class ExperimentalGenerator implements NewLevelGenerator{
/** /**
* @var Populator[] * @var Populator[]
*/ */
private $populators = array(); public $populators = array();
/** /**
* @var Populator[] * @var Populator[]
*/ */
private $genPopulators = array(); public $genPopulators = array();
private $level; public $level;
private $random; public $random;
private $waterHeight = 63; public $waterHeight = 63;
private $noiseHills; public $noiseHills;
private $noisePatches; public $noisePatches;
private $noisePatchesSmall; public $noisePatchesSmall;
private $noiseBase; public $noiseBase;
public $selector;
public static $GAUSSIAN_KERNEL = null;
private static $GAUSSIAN_KERNEL = null; public static $SMOOTH_SIZE = 2;
private static $SMOOTH_SIZE = 2;
public function __construct(array $options = array()){ public function __construct(array $options = array()){
ExperimentalGenerator::generateKernel(); ExperimentalGenerator::generateKernel();
} }
private static function generateKernel(){ public static function generateKernel(){
ExperimentalGenerator::$GAUSSIAN_KERNEL = []; ExperimentalGenerator::$GAUSSIAN_KERNEL = [];
$bellSize = 1 / ExperimentalGenerator::$SMOOTH_SIZE; $bellSize = 1 / ExperimentalGenerator::$SMOOTH_SIZE;
@ -88,10 +88,10 @@ class ExperimentalGenerator implements NewLevelGenerator{
} }
public function pickBiome($x, $z){ public function pickBiome($x, $z){
$hash = $x * 2345803 ^ $z * 9236449 ^ $this->level->level->getSeed(); $hash = (int) ($x * 2345803 ^ $z * 9236449 ^ $this->level->level->getSeed());
$hash *= $hash + 223; $hash *= $hash + 223;
$xNoise = $hash >> 20 & 3; $xNoise = ((int)$hash) >> 20 & 3;
$zNoise = $hash >> 22 & 3; $zNoise = ((int)$hash) >> 22 & 3;
if($xNoise == 3){ if($xNoise == 3){
$xNoise = 1; $xNoise = 1;
} }

View file

@ -2,7 +2,7 @@
class WorldGenerator{ class WorldGenerator{
private $seed, $level, $path, $random, $generator, $width; private $seed, $level, $path, $random, $generator, $width, $height;
public function __construct(LevelGenerator $generator, $name, $seed = false, $width = 16, $height = 8){ public function __construct(LevelGenerator $generator, $name, $seed = false, $width = 16, $height = 8){
$this->seed = $seed !== false ? (int) $seed : Utils::readInt(Utils::getRandomBytes(4, false)); $this->seed = $seed !== false ? (int) $seed : Utils::readInt(Utils::getRandomBytes(4, false));