Trying update core to PHP 7.4.21

This commit is contained in:
ArkQuark 2022-06-16 16:47:49 +03:00
parent e74e6c3f77
commit 1a884f6d2a
12 changed files with 80 additions and 79 deletions

View file

@ -182,7 +182,7 @@ class ConsoleAPI{
if(preg_match_all('#@([@a-z]{1,})#', $params, $matches, PREG_OFFSET_CAPTURE) > 0){ if(preg_match_all('#@([@a-z]{1,})#', $params, $matches, PREG_OFFSET_CAPTURE) > 0){
$offsetshift = 0; $offsetshift = 0;
foreach($matches[1] as $selector){ foreach($matches[1] as $selector){
if($selector[0]{0} === "@"){ //Escape! if($selector[0][0] === "@"){ //Escape!
$params = substr_replace($params, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1); $params = substr_replace($params, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
--$offsetshift; --$offsetshift;
continue; continue;

View file

@ -228,7 +228,7 @@ class PluginAPI extends stdClass{
private function loadAll(){ private function loadAll(){
$dir = dir($this->pluginsPath()); $dir = dir($this->pluginsPath());
while(false !== ($file = $dir->read())){ while(false !== ($file = $dir->read())){
if($file{0} !== "."){ if($file[0] !== "."){
$ext = strtolower(substr($file, -3)); $ext = strtolower(substr($file, -3));
if($ext === "php" or $ext === "pmf"){ if($ext === "php" or $ext === "pmf"){
$this->load($dir->path . $file); $this->load($dir->path . $file);

View file

@ -19,11 +19,6 @@
* *
*/ */
class PlayerNull extends Player{
public function __construct(){
}
}
class Player{ class Player{
private $server; private $server;
private $recoveryQueue = array(); private $recoveryQueue = array();
@ -710,7 +705,7 @@ class Player{
if(preg_match_all('#@([@A-Za-z_]{1,})#', $m, $matches, PREG_OFFSET_CAPTURE) > 0){ if(preg_match_all('#@([@A-Za-z_]{1,})#', $m, $matches, PREG_OFFSET_CAPTURE) > 0){
$offsetshift = 0; $offsetshift = 0;
foreach($matches[1] as $selector){ foreach($matches[1] as $selector){
if($selector[0]{0} === "@"){ //Escape! if($selector[0][0] === "@"){ //Escape!
$m = substr_replace($m, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1); $m = substr_replace($m, $selector[0], $selector[1] + $offsetshift - 1, strlen($selector[0]) + 1);
--$offsetshift; --$offsetshift;
continue; continue;
@ -1163,7 +1158,7 @@ class Player{
case ProtocolInfo::REQUEST_CHUNK_PACKET: case ProtocolInfo::REQUEST_CHUNK_PACKET:
case ProtocolInfo::ANIMATE_PACKET: case ProtocolInfo::ANIMATE_PACKET:
case ProtocolInfo::SET_HEALTH_PACKET: case ProtocolInfo::SET_HEALTH_PACKET:
continue; continue 2;
} }
} }
$this->received[$p->messageIndex] = true; $this->received[$p->messageIndex] = true;
@ -2088,7 +2083,7 @@ class Player{
$this->toCraft = array(); $this->toCraft = array();
if(trim($packet->message) != "" and strlen($packet->message) <= 255){ if(trim($packet->message) != "" and strlen($packet->message) <= 255){
$message = $packet->message; $message = $packet->message;
if($message{0} === "/"){ //Command if($message[0] === "/"){ //Command
if($this instanceof Player){ if($this instanceof Player){
console("[DEBUG] ".FORMAT_AQUA.$this->username.FORMAT_RESET." issued server command: ".$message); console("[DEBUG] ".FORMAT_AQUA.$this->username.FORMAT_RESET." issued server command: ".$message);
}else{ }else{
@ -2507,3 +2502,9 @@ class Player{
} }
} }
class PlayerNull extends Player{
public function __construct(){
}
}

View file

@ -140,7 +140,7 @@ function arguments ( $args ){
$args = array(); $args = array();
} }
array_shift( $args ); array_shift( $args );
$args = join( $args, ' ' ); $args = join(' ', $args);
preg_match_all('/ (--[\w\-]+ (?:[= ] [^-\s]+ )? ) | (-\w+) | (\w+) /x', $args, $match ); preg_match_all('/ (--[\w\-]+ (?:[= ] [^-\s]+ )? ) | (-\w+) | (\w+) /x', $args, $match );
$args = array_shift( $match ); $args = array_shift( $match );

View file

@ -54,7 +54,7 @@ class MinecraftInterface{
} }
private function parsePacket($buffer, $source, $port){ private function parsePacket($buffer, $source, $port){
$pid = ord($buffer{0}); $pid = ord($buffer[0]);
if(RakNetInfo::isValid($pid)){ if(RakNetInfo::isValid($pid)){
$parser = new RakNetParser($buffer); $parser = new RakNetParser($buffer);
@ -67,7 +67,7 @@ class MinecraftInterface{
return $parser->packet; return $parser->packet;
} }
return false; return false;
}elseif($pid === 0xfe and $buffer{1} === "\xfd" and ServerAPI::request()->api->query instanceof QueryHandler){ }elseif($pid === 0xfe and $buffer[1] === "\xfd" and ServerAPI::request()->api->query instanceof QueryHandler){
$packet = new QueryPacket; $packet = new QueryPacket;
$packet->ip = $source; $packet->ip = $source;
$packet->port = $port; $packet->port = $port;

View file

@ -28,7 +28,7 @@ class QueryPacket extends Packet{
public $payload; public $payload;
public function decode(){ public function decode(){
$this->packetType = ord($this->buffer{2}); $this->packetType = ord($this->buffer[2]);
$this->sessionID = Utils::readInt(substr($this->buffer, 3, 4)); $this->sessionID = Utils::readInt(substr($this->buffer, 3, 4));
$this->payload = substr($this->buffer, 7); $this->payload = substr($this->buffer, 7);
} }

View file

@ -317,7 +317,7 @@ class PMFLevel extends PMF{
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$b = ord($this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))}); $b = ord($this->chunks[$index][$Y][(int) ($aY + ($aX << 5) + ($aZ << 9))]);
return $b; return $b;
} }
@ -336,7 +336,7 @@ class PMFLevel extends PMF{
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))} = chr($block); $this->chunks[$index][$Y][(int) ($aY + ($aX << 5) + ($aZ << 9))] = chr($block);
if(!isset($this->chunkChange[$index][$Y])){ if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1; $this->chunkChange[$index][$Y] = 1;
}else{ }else{
@ -357,7 +357,7 @@ class PMFLevel extends PMF{
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))}); $m = ord($this->chunks[$index][$Y][(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))]);
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = $m & 0x0F; $m = $m & 0x0F;
}else{ }else{
@ -382,7 +382,7 @@ class PMFLevel extends PMF{
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9)); $mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
$old_m = ord($this->chunks[$index][$Y]{$mindex}); $old_m = ord($this->chunks[$index][$Y][$mindex]);
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = ($old_m & 0xF0) | $damage; $m = ($old_m & 0xF0) | $damage;
}else{ }else{
@ -390,7 +390,7 @@ class PMFLevel extends PMF{
} }
if($old_m != $m){ if($old_m != $m){
$this->chunks[$index][$Y]{$mindex} = chr($m); $this->chunks[$index][$Y][$mindex] = chr($m);
if(!isset($this->chunkChange[$index][$Y])){ if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1; $this->chunkChange[$index][$Y] = 1;
}else{ }else{
@ -420,8 +420,8 @@ class PMFLevel extends PMF{
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$b = ord($this->chunks[$index][$Y]{(int) ($aY + ($aX << 5) + ($aZ << 9))}); $b = ord($this->chunks[$index][$Y][(int) ($aY + ($aX << 5) + ($aZ << 9))]);
$m = ord($this->chunks[$index][$Y]{(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))}); $m = ord($this->chunks[$index][$Y][(int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9))]);
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = $m & 0x0F; $m = $m & 0x0F;
}else{ }else{
@ -452,8 +452,8 @@ class PMFLevel extends PMF{
$aY = $y - ($Y << 4); $aY = $y - ($Y << 4);
$bindex = (int) ($aY + ($aX << 5) + ($aZ << 9)); $bindex = (int) ($aY + ($aX << 5) + ($aZ << 9));
$mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9)); $mindex = (int) (($aY >> 1) + 16 + ($aX << 5) + ($aZ << 9));
$old_b = ord($this->chunks[$index][$Y]{$bindex}); $old_b = ord($this->chunks[$index][$Y][$bindex]);
$old_m = ord($this->chunks[$index][$Y]{$mindex}); $old_m = ord($this->chunks[$index][$Y][$mindex]);
if(($y & 1) === 0){ if(($y & 1) === 0){
$m = ($old_m & 0xF0) | $meta; $m = ($old_m & 0xF0) | $meta;
}else{ }else{
@ -461,8 +461,8 @@ class PMFLevel extends PMF{
} }
if($old_b !== $block or $old_m !== $m){ if($old_b !== $block or $old_m !== $m){
$this->chunks[$index][$Y]{$bindex} = chr($block); $this->chunks[$index][$Y][$bindex] = chr($block);
$this->chunks[$index][$Y]{$mindex} = chr($m); $this->chunks[$index][$Y][$mindex] = chr($m);
if(!isset($this->chunkChange[$index][$Y])){ if(!isset($this->chunkChange[$index][$Y])){
$this->chunkChange[$index][$Y] = 1; $this->chunkChange[$index][$Y] = 1;
}else{ }else{
@ -475,8 +475,8 @@ class PMFLevel extends PMF{
for($side = 0; $side <= 5; ++$side) for($side = 0; $side <= 5; ++$side)
{ {
$b = $pos->getSide($side); $b = $pos->getSide($side);
if($b instanceof LavaBlock) { ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL); } if($b instanceof LavaBlock) ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 40, BLOCK_UPDATE_NORMAL);
else { ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL); } else ServerAPI::request()->api->block->scheduleBlockUpdate(new Position($b, 0, 0, $this->level), 10, BLOCK_UPDATE_NORMAL);
} }
} }
return true; return true;

View file

@ -48,7 +48,7 @@ class Java_String{
trigger_error("Undefined offset $index", E_USER_WARNING); trigger_error("Undefined offset $index", E_USER_WARNING);
return false; return false;
} }
return $this->value{$index}; return $this->value[$index];
} }
public function hashCode(){ public function hashCode(){

View file

@ -34,7 +34,7 @@ class Random{
$state[] = $i; $state[] = $i;
} }
for($i = $j = 0; $i < 256; ++$i){ for($i = $j = 0; $i < 256; ++$i){
$j = ($j + ord($seed{$i & 0x03}) + $state[$i]) & 0xFF; $j = ($j + ord($seed[$i & 0x03]) + $state[$i]) & 0xFF;
$state[$i] ^= $state[$j]; $state[$i] ^= $state[$j];
$state[$j] ^= $state[$i]; $state[$j] ^= $state[$i];
$state[$i] ^= $state[$j]; $state[$i] ^= $state[$j];

View file

@ -27,9 +27,9 @@ class Utils{
public static $online = true; public static $online = true;
public static $ip = false; public static $ip = false;
public static function isOnline(){ /*public static function isOnline(){
return ((@fsockopen("8.8.8.8", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.linux.org", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.php.net", 80, $e = null, $n = null, 2) !== false) ? true:false); return ((@fsockopen("8.8.8.8", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.linux.org", 80, $e = null, $n = null, 2) !== false or @fsockopen("www.php.net", 80, $e = null, $n = null, 2) !== false) ? true:false);
} }*/
public static function getCallableIdentifier(callable $variable){ public static function getCallableIdentifier(callable $variable){
if(is_array($variable)){ if(is_array($variable)){
@ -205,14 +205,14 @@ class Utils{
public static function readMetadata($value, $types = false){ public static function readMetadata($value, $types = false){
$offset = 0; $offset = 0;
$m = array(); $m = array();
$b = ord($value{$offset}); $b = ord($value[$offset]);
++$offset; ++$offset;
while($b !== 127 and isset($value{$offset})){ while($b !== 127 and isset($value[$offset])){
$bottom = $b & 0x1F; $bottom = $b & 0x1F;
$type = $b >> 5; $type = $b >> 5;
switch($type){ switch($type){
case 0: case 0:
$r = Utils::readByte($value{$offset}); $r = Utils::readByte($value[$offset]);
++$offset; ++$offset;
break; break;
case 1: case 1:
@ -237,7 +237,7 @@ class Utils{
$r = array(); $r = array();
$r[] = Utils::readLShort(substr($value, $offset, 2)); $r[] = Utils::readLShort(substr($value, $offset, 2));
$offset += 2; $offset += 2;
$r[] = ord($value{$offset}); $r[] = ord($value[$offset]);
++$offset; ++$offset;
$r[] = Utils::readLShort(substr($value, $offset, 2)); $r[] = Utils::readLShort(substr($value, $offset, 2));
$offset += 2; $offset += 2;
@ -256,7 +256,7 @@ class Utils{
}else{ }else{
$m[$bottom] = $r; $m[$bottom] = $r;
} }
$b = ord($value{$offset}); $b = ord($value[$offset]);
++$offset; ++$offset;
} }
return $m; return $m;
@ -309,7 +309,7 @@ class Utils{
(string) memory_get_usage().".".memory_get_peak_usage(), (string) memory_get_usage().".".memory_get_peak_usage(),
php_uname(), php_uname(),
phpversion(), phpversion(),
extension_loaded("gmp") ? gmp_strval(gmp_random(4)):microtime(), //extension_loaded("gmp") ? gmp_strval(gmp_random(4)):microtime(),
zend_version(), zend_version(),
(string) getmypid(), (string) getmypid(),
(string) getmyuid(), (string) getmyuid(),
@ -353,11 +353,11 @@ class Utils{
//Von Neumann randomness extractor, increases entropy //Von Neumann randomness extractor, increases entropy
$bitcnt = 0; $bitcnt = 0;
for($j = 0; $j < 64; ++$j){ for($j = 0; $j < 64; ++$j){
$a = ord($strongEntropy{$j}); $a = ord($strongEntropy[$j]);
for($i = 0; $i < 8; $i += 2){ for($i = 0; $i < 8; $i += 2){
$b = ($a & (1 << $i)) > 0 ? 1:0; $b = ($a & (1 << $i)) > 0 ? 1:0;
if($b != (($a & (1 << ($i + 1))) > 0 ? 1:0)){ if($b != (($a & (1 << ($i + 1))) > 0 ? 1:0)){
$secureValue |= $b << $bitcnt; $secureValue = $b << $bitcnt;
if($bitcnt == 7){ if($bitcnt == 7){
$value .= chr($secureValue); $value .= chr($secureValue);
$secureValue = 0; $secureValue = 0;
@ -465,7 +465,7 @@ class Utils{
} }
public static function readByte($c, $signed = true){ public static function readByte($c, $signed = true){
$b = ord($c{0}); $b = ord($c[0]);
if($signed === true and ($b & 0x80) === 0x80){ //calculate Two's complement if($signed === true and ($b & 0x80) === 0x80){ //calculate Two's complement
$b = -0x80 + ($b & 0x7f); $b = -0x80 + ($b & 0x7f);
} }
@ -585,7 +585,7 @@ class Utils{
public static function readLong($x, $signed = true){ public static function readLong($x, $signed = true){
$value = "0"; $value = "0";
if($signed === true){ if($signed === true){
$negative = ((ord($x{0}) & 0x80) === 0x80) ? true:false; $negative = ((ord($x[0]) & 0x80) === 0x80) ? true:false;
if($negative){ if($negative){
$x = ~$x; $x = ~$x;
} }
@ -595,17 +595,17 @@ class Utils{
for($i = 0; $i < 8; $i += 4){ for($i = 0; $i < 8; $i += 4){
$value = bcmul($value, "4294967296", 0); //4294967296 == 2^32 $value = bcmul($value, "4294967296", 0); //4294967296 == 2^32
$value = bcadd($value, 0x1000000 * ord(@$x{$i}) + ((ord(@$x{$i + 1}) << 16) | (ord(@$x{$i + 2}) << 8) | ord(@$x{$i + 3})), 0); $value = bcadd($value, 0x1000000 * ord(@$x[$i]) + ((ord(@$x[$i + 1]) << 16) | (ord(@$x[$i + 2]) << 8) | ord(@$x[$i + 3])), 0);
} }
return ($negative === true ? "-".$value:$value); return ($negative === true ? "-".$value:$value);
} }
public static function writeLong($value){ public static function writeLong($value){
$x = ""; $x = "";
if($value{0} === "-"){ if($value[0] === "-"){
$negative = true; $negative = true;
$value = bcadd($value, "1"); $value = bcadd($value, "1");
if($value{0} === "-"){ if($value[0] === "-"){
$value = substr($value, 1); $value = substr($value, 1);
} }
}else{ }else{
@ -634,6 +634,6 @@ class Utils{
} }
if(Utils::isOnline() === false){ //if(Utils::isOnline() === false){
Utils::$online = false; //Utils::$online = false;
} //}

View file

@ -22,23 +22,6 @@
define("ASYNC_CURL_GET", 1); define("ASYNC_CURL_GET", 1);
define("ASYNC_CURL_POST", 2); define("ASYNC_CURL_POST", 2);
class StackableArray extends Stackable{
public function __construct(){
foreach(func_get_args() as $n => $value){
if(is_array($value)){
$this->{$n} = new StackableArray();
call_user_func_array(array($this->{$n}, "__construct"), $value);
}else{
$this->{$n} = $value;
}
}
}
public function __destruct(){}
public function run(){}
}
class AsyncMultipleQueue extends Thread{ class AsyncMultipleQueue extends Thread{
public $input; public $input;
public $output; public $output;
@ -57,8 +40,8 @@ class AsyncMultipleQueue extends Thread{
} }
$offset = 0; $offset = 0;
while(!isset($str{$len - 1})){ while(!isset($str{$len - 1})){
if(isset($this->input{$offset})){ if(isset($this->input[$offset])){
$str .= $this->input{$offset}; $str .= $this->input[$offset];
++$offset; ++$offset;
} }
} }
@ -76,9 +59,9 @@ class AsyncMultipleQueue extends Thread{
$timeout = Utils::readShort($this->get(2)); $timeout = Utils::readShort($this->get(2));
$res = (string) Utils::curl_get($url, $timeout); $res = (string) Utils::curl_get($url, $timeout);
$this->lock(); //$this->lock();
$this->output .= Utils::writeInt($rID).Utils::writeShort(ASYNC_CURL_GET).Utils::writeInt(strlen($res)).$res; $this->output .= Utils::writeInt($rID).Utils::writeShort(ASYNC_CURL_GET).Utils::writeInt(strlen($res)).$res;
$this->unlock(); //$this->unlock();
break; break;
case ASYNC_CURL_POST: case ASYNC_CURL_POST:
$url = $this->get(Utils::readShort($this->get(2), false)); $url = $this->get(Utils::readShort($this->get(2), false));
@ -90,9 +73,9 @@ class AsyncMultipleQueue extends Thread{
$d[$key] = $this->get(Utils::readInt($this->get(4), false)); $d[$key] = $this->get(Utils::readInt($this->get(4), false));
} }
$res = (string) Utils::curl_post($url, $d, $timeout); $res = (string) Utils::curl_post($url, $d, $timeout);
$this->lock(); //$this->lock();
$this->output .= Utils::writeInt($rID).Utils::writeShort(ASYNC_CURL_POST).Utils::writeInt(strlen($res)).$res; $this->output .= Utils::writeInt($rID).Utils::writeShort(ASYNC_CURL_POST).Utils::writeInt(strlen($res)).$res;
$this->unlock(); //$this->unlock();
break; break;
} }
} }
@ -132,4 +115,21 @@ class Async extends Thread{
return $this->result; return $this->result;
} }
} }
/*class StackableArray extends Stackable{
public function __construct(){
foreach(func_get_args() as $n => $value){
if(is_array($value)){
$this->{$n} = new StackableArray();
call_user_func_array(array($this->{$n}, "__construct"), $value);
}else{
$this->{$n} = $value;
}
}
}
public function __destruct(){}
public function run(){}
}*/

View file

@ -58,14 +58,14 @@ class PocketChunkParser{
$this->raw = file_get_contents($file); $this->raw = file_get_contents($file);
} }
$this->file = $file; $this->file = $file;
$this->chunkLength = $this->sectorLength * ord($this->raw{0}); $this->chunkLength = $this->sectorLength * ord($this->raw[0]);
return true; return true;
} }
public function loadRaw($raw, $file){ public function loadRaw($raw, $file){
$this->file = $file; $this->file = $file;
$this->raw = $raw; $this->raw = $raw;
$this->chunkLength = $this->sectorLength * ord($this->raw{0}); $this->chunkLength = $this->sectorLength * ord($this->raw[0]);
return true; return true;
} }
@ -161,7 +161,7 @@ class PocketChunkParser{
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$index = $aZ + ($aX << 4); $index = $aZ + ($aX << 4);
for($y = 127; $y <= 0; --$y){ for($y = 127; $y <= 0; --$y){
if($this->map[$X][$Z][0][$index]{$y} !== "\x00"){ if($this->map[$X][$Z][0][$index][$y] !== "\x00"){
break; break;
} }
} }
@ -177,8 +177,8 @@ class PocketChunkParser{
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$index = $aZ + ($aX << 4); $index = $aZ + ($aX << 4);
$block = ord($this->map[$X][$Z][0][$index]{$y}); $block = ord($this->map[$X][$Z][0][$index][$y]);
$meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); $meta = ord($this->map[$X][$Z][1][$index][$y >> 1]);
if(($y & 1) === 0){ if(($y & 1) === 0){
$meta = $meta & 0x0F; $meta = $meta & 0x0F;
}else{ }else{
@ -201,14 +201,14 @@ class PocketChunkParser{
$aX = $x - ($X << 4); $aX = $x - ($X << 4);
$aZ = $z - ($Z << 4); $aZ = $z - ($Z << 4);
$index = $aZ + ($aX << 4); $index = $aZ + ($aX << 4);
$this->map[$X][$Z][0][$index]{$y} = chr($block); $this->map[$X][$Z][0][$index][$y] = chr($block);
$old_meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); $old_meta = ord($this->map[$X][$Z][1][$index][$y >> 1]);
if(($y & 1) === 0){ if(($y & 1) === 0){
$meta = ($old_meta & 0xF0) | ($meta & 0x0F); $meta = ($old_meta & 0xF0) | ($meta & 0x0F);
}else{ }else{
$meta = (($meta << 4) & 0xF0) | ($old_meta & 0x0F); $meta = (($meta << 4) & 0xF0) | ($old_meta & 0x0F);
} }
$this->map[$X][$Z][1][$index]{$y >> 1} = chr($meta); $this->map[$X][$Z][1][$index][$y >> 1] = chr($meta);
} }
} }