GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
ChunkUtils Class Reference

Static Public Member Functions

static reorderByteArray (string $array)
 
static reorderNibbleArray (string $array, string $commonValue="\0")
 
static convertBiomeColors (array $array)
 

Member Function Documentation

◆ convertBiomeColors()

static convertBiomeColors ( array  $array)
static

Converts pre-MCPE-1.0 biome color array to biome ID array.

Parameters
int[]$array of biome color values
Returns
string
98  : string{
99  $result = str_repeat("\x00", 256);
100  foreach($array as $i => $color){
101  $result{$i} = chr(($color >> 24) & 0xff);
102  }
103  return $result;
104  }

◆ reorderByteArray()

static reorderByteArray ( string  $array)
staticfinal

Re-orders a byte array (YZX -> XZY and vice versa)

Parameters
string$arraylength 4096
Returns
string length 4096
35  : string{
36  $result = str_repeat("\x00", 4096);
37  if($array !== $result){
38  $i = 0;
39  for($x = 0; $x < 16; ++$x){
40  $zM = $x + 256;
41  for($z = $x; $z < $zM; $z += 16){
42  $yM = $z + 4096;
43  for($y = $z; $y < $yM; $y += 256){
44  $result{$i} = $array{$y};
45  ++$i;
46  }
47  }
48  }
49  }
50 
51  return $result;
52  }

◆ reorderNibbleArray()

static reorderNibbleArray ( string  $array,
string  $commonValue = "\x00" 
)
staticfinal

Re-orders a nibble array (YZX -> XZY and vice versa)

Parameters
string$arraylength 2048
string$commonValuelength 1 common value to fill the default array with and to expect, may improve sort time
Returns
string length 2048
62  : string{
63  $result = str_repeat($commonValue, 2048);
64 
65  if($array !== $result){
66  $i = 0;
67  for($x = 0; $x < 8; ++$x){
68  for($z = 0; $z < 16; ++$z){
69  $zx = (($z << 3) | $x);
70  for($y = 0; $y < 8; ++$y){
71  $j = (($y << 8) | $zx);
72  $j80 = ($j | 0x80);
73  if($array{$j} === $commonValue and $array{$j80} === $commonValue){
74  //values are already filled
75  }else{
76  $i1 = ord($array{$j});
77  $i2 = ord($array{$j80});
78  $result{$i} = chr(($i2 << 4) | ($i1 & 0x0f));
79  $result{$i | 0x80} = chr(($i1 >> 4) | ($i2 & 0xf0));
80  }
81  $i++;
82  }
83  }
84  $i += 128;
85  }
86  }
87 
88  return $result;
89  }

The documentation for this class was generated from the following file: