Send MiniChunks

This commit is contained in:
Shoghi Cervantes Pueyo
2013-02-05 17:36:38 +01:00
parent 7f92c6fab3
commit e5ed7e04cf
3 changed files with 51 additions and 36 deletions

View File

@@ -39,6 +39,10 @@ class ChatAPI{
$this->send(false, $message);
}
public function sendTo($owner, $text, $username){
$this->send($owner, $text, array($username));
}
public function send($owner, $text, $whitelist = false, $blacklist = false){
$message = "";
if($owner !== false){

View File

@@ -111,9 +111,8 @@ class LevelAPI{
return true;
}
public function getOrderedChunk($X, $Z, $columnsPerPacket = 2){
public function getOrderedChunks($X, $Z, $columnsPerPacket = 2){
$columnsPerPacket = max(1, (int) $columnsPerPacket);
$c = $this->getChunk($X, $Z);
$ordered = array();
$i = 0;
$cnt = 0;
@@ -137,4 +136,26 @@ class LevelAPI{
}
return $ordered;
}
public function getMiniChunk($X, $Z, $Y, $MTU){
$ordered = array();
$i = 0;
$ordered[$i] = "";
$cnt = 0;
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
if((strlen($ordered[$i]) + 16 + 8 + 1) > $MTU){
++$i;
$ordered[$i] = str_repeat("\x00", $cnt);
}
$ordered[$i] .= chr(1 << $Y);
$block = $this->map->getChunkColumn($X, $Z, $x, $z, 0);
$meta = $this->map->getChunkColumn($X, $Z, $x, $z, 1);
$ordered[$i] .= substr($block, $Y << 4, 16);
$ordered[$i] .= substr($meta, $Y << 3, 8);
++$cnt;
}
}
return $ordered;
}
}