mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 20:28:31 +00:00
Preparing chunk changes...
This commit is contained in:
parent
8918c3c2c8
commit
d4487e66f6
@ -77,6 +77,10 @@ class ChunkParser{
|
|||||||
return 0x1000 + (($Z * $sectors) << 12) + (($X * $sectors) << 16);
|
return 0x1000 + (($Z * $sectors) << 12) + (($X * $sectors) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getOffsetLocation($X, $Z){
|
||||||
|
return $X << 2 + $Z << 7;
|
||||||
|
}
|
||||||
|
|
||||||
public function getChunk($X, $Z){
|
public function getChunk($X, $Z){
|
||||||
$X = (int) $X;
|
$X = (int) $X;
|
||||||
$Z = (int) $Z;
|
$Z = (int) $Z;
|
||||||
@ -113,7 +117,7 @@ class ChunkParser{
|
|||||||
foreach($chunk as $section => &$data){
|
foreach($chunk as $section => &$data){
|
||||||
$l = $section === 0 ? 128:64;
|
$l = $section === 0 ? 128:64;
|
||||||
for($i = 0; $i < 256; ++$i){
|
for($i = 0; $i < 256; ++$i){
|
||||||
$data[] = substr($this->raw, $offset, $l);
|
$data[$i] = substr($this->raw, $offset, $l);
|
||||||
$offset += $l;
|
$offset += $l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,7 +146,7 @@ class ChunkParser{
|
|||||||
flock($fp, LOCK_EX);
|
flock($fp, LOCK_EX);
|
||||||
foreach($this->map as $x => $d){
|
foreach($this->map as $x => $d){
|
||||||
foreach($d as $z => $chunk){
|
foreach($d as $z => $chunk){
|
||||||
fseek($fp, $this->getOffset($x, $z));
|
fseek($fp, $this->location[$x][$z]);
|
||||||
fwrite($fp, $this->writeChunk($x, $z), $this->chunkLength);
|
fwrite($fp, $this->writeChunk($x, $z), $this->chunkLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user