New batched UpdateBlockPacket, added Level->sendBlocks()

This commit is contained in:
Shoghi Cervantes
2015-03-22 02:44:39 +01:00
parent 93a50d08e7
commit d2bf92c3ed
3 changed files with 52 additions and 102 deletions

View File

@ -28,11 +28,15 @@ class UpdateBlockPacket extends DataPacket{
public static $pool = [];
public static $next = 0;
public $x;
public $z;
public $y;
public $block;
public $meta;
const FLAG_NONE = 0b0;
const FLAG_NEIGHBORS = 0b1;
const FLAG_NOGRAPHIC = 0b100;
const FLAG_PRIORITY = 0b1000;
const FLAG_ALL = self::FLAG_NEIGHBORS;
const FLAG_ALL_PRIORITY = self::FLAG_NEIGHBORS | self::FLAG_PRIORITY;
public $records = []; //x, z, y, blockId, blockData, flags
public function pid(){
return Info::UPDATE_BLOCK_PACKET;
@ -44,11 +48,14 @@ class UpdateBlockPacket extends DataPacket{
public function encode(){
$this->reset();
$this->putInt($this->x);
$this->putInt($this->z);
$this->putByte($this->y);
$this->putByte($this->block);
$this->putByte($this->meta);
$this->putInt(count($this->records));
foreach($this->records as $r){
$this->putInt($r[0]);
$this->putInt($r[1]);
$this->putByte($r[2]);
$this->putByte($r[3]);
$this->putByte(($r[5] << 4) | $r[4]);
}
}
}