mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-05 17:36:12 +00:00
remove usages of deprecated {} string access, closes #3035
This commit is contained in:
@ -460,7 +460,7 @@ class Chunk{
|
||||
* @return int 0-255
|
||||
*/
|
||||
public function getBiomeId(int $x, int $z) : int{
|
||||
return ord($this->biomeIds{($z << 4) | $x});
|
||||
return ord($this->biomeIds[($z << 4) | $x]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -472,7 +472,7 @@ class Chunk{
|
||||
*/
|
||||
public function setBiomeId(int $x, int $z, int $biomeId){
|
||||
$this->hasChanged = true;
|
||||
$this->biomeIds{($z << 4) | $x} = chr($biomeId & 0xff);
|
||||
$this->biomeIds[($z << 4) | $x] = chr($biomeId & 0xff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -71,31 +71,31 @@ class SubChunk implements SubChunkInterface{
|
||||
}
|
||||
|
||||
public function getBlockId(int $x, int $y, int $z) : int{
|
||||
return ord($this->ids{($x << 8) | ($z << 4) | $y});
|
||||
return ord($this->ids[($x << 8) | ($z << 4) | $y]);
|
||||
}
|
||||
|
||||
public function setBlockId(int $x, int $y, int $z, int $id) : bool{
|
||||
$this->ids{($x << 8) | ($z << 4) | $y} = chr($id);
|
||||
$this->ids[($x << 8) | ($z << 4) | $y] = chr($id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockData(int $x, int $y, int $z) : int{
|
||||
return (ord($this->data{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
||||
return (ord($this->data[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||
}
|
||||
|
||||
public function setBlockData(int $x, int $y, int $z, int $data) : bool{
|
||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$byte = ord($this->data{$i});
|
||||
$this->data{$i} = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift));
|
||||
$byte = ord($this->data[$i]);
|
||||
$this->data[$i] = chr(($byte & ~(0xf << $shift)) | (($data & 0xf) << $shift));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFullBlock(int $x, int $y, int $z) : int{
|
||||
$i = ($x << 8) | ($z << 4) | $y;
|
||||
return (ord($this->ids{$i}) << 4) | ((ord($this->data{$i >> 1}) >> (($y & 1) << 2)) & 0xf);
|
||||
return (ord($this->ids[$i]) << 4) | ((ord($this->data[$i >> 1]) >> (($y & 1) << 2)) & 0xf);
|
||||
}
|
||||
|
||||
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{
|
||||
@ -103,8 +103,8 @@ class SubChunk implements SubChunkInterface{
|
||||
$changed = false;
|
||||
if($id !== null){
|
||||
$block = chr($id);
|
||||
if($this->ids{$i} !== $block){
|
||||
$this->ids{$i} = $block;
|
||||
if($this->ids[$i] !== $block){
|
||||
$this->ids[$i] = $block;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
@ -113,10 +113,10 @@ class SubChunk implements SubChunkInterface{
|
||||
$i >>= 1;
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$oldPair = ord($this->data{$i});
|
||||
$oldPair = ord($this->data[$i]);
|
||||
$newPair = ($oldPair & ~(0xf << $shift)) | (($data & 0xf) << $shift);
|
||||
if($newPair !== $oldPair){
|
||||
$this->data{$i} = chr($newPair);
|
||||
$this->data[$i] = chr($newPair);
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
@ -125,29 +125,29 @@ class SubChunk implements SubChunkInterface{
|
||||
}
|
||||
|
||||
public function getBlockLight(int $x, int $y, int $z) : int{
|
||||
return (ord($this->blockLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
||||
return (ord($this->blockLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||
}
|
||||
|
||||
public function setBlockLight(int $x, int $y, int $z, int $level) : bool{
|
||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$byte = ord($this->blockLight{$i});
|
||||
$this->blockLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
$byte = ord($this->blockLight[$i]);
|
||||
$this->blockLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockSkyLight(int $x, int $y, int $z) : int{
|
||||
return (ord($this->skyLight{($x << 7) | ($z << 3) | ($y >> 1)}) >> (($y & 1) << 2)) & 0xf;
|
||||
return (ord($this->skyLight[($x << 7) | ($z << 3) | ($y >> 1)]) >> (($y & 1) << 2)) & 0xf;
|
||||
}
|
||||
|
||||
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : bool{
|
||||
$i = ($x << 7) | ($z << 3) | ($y >> 1);
|
||||
|
||||
$shift = ($y & 1) << 2;
|
||||
$byte = ord($this->skyLight{$i});
|
||||
$this->skyLight{$i} = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
$byte = ord($this->skyLight[$i]);
|
||||
$this->skyLight[$i] = chr(($byte & ~(0xf << $shift)) | (($level & 0xf) << $shift));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -156,7 +156,7 @@ class SubChunk implements SubChunkInterface{
|
||||
$low = ($x << 8) | ($z << 4);
|
||||
$i = $low | 0x0f;
|
||||
for(; $i >= $low; --$i){
|
||||
if($this->ids{$i} !== "\x00"){
|
||||
if($this->ids[$i] !== "\x00"){
|
||||
return $i & 0x0f;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
for($z = $x; $z < $zM; $z += 16){
|
||||
$yM = $z + 4096;
|
||||
for($y = $z; $y < $yM; $y += 256){
|
||||
$result{$i} = $array{$y};
|
||||
$result[$i] = $array[$y];
|
||||
++$i;
|
||||
}
|
||||
}
|
||||
@ -76,13 +76,13 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
for($y = 0; $y < 8; ++$y){
|
||||
$j = (($y << 8) | $zx);
|
||||
$j80 = ($j | 0x80);
|
||||
if($array{$j} === $commonValue and $array{$j80} === $commonValue){
|
||||
if($array[$j] === $commonValue and $array[$j80] === $commonValue){
|
||||
//values are already filled
|
||||
}else{
|
||||
$i1 = ord($array{$j});
|
||||
$i2 = ord($array{$j80});
|
||||
$result{$i} = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||
$result{$i | 0x80} = chr(($i1 >> 4) | ($i2 & 0xf0));
|
||||
$i1 = ord($array[$j]);
|
||||
$i2 = ord($array[$j80]);
|
||||
$result[$i] = chr(($i2 << 4) | ($i1 & 0x0f));
|
||||
$result[$i | 0x80] = chr(($i1 >> 4) | ($i2 & 0xf0));
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@ -104,7 +104,7 @@ if(!extension_loaded('pocketmine_chunkutils')){
|
||||
public static function convertBiomeColors(array $array) : string{
|
||||
$result = str_repeat("\x00", 256);
|
||||
foreach($array as $i => $color){
|
||||
$result{$i} = chr(($color >> 24) & 0xff);
|
||||
$result[$i] = chr(($color >> 24) & 0xff);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user