More awesomeness, No AI flag!

This commit is contained in:
Shoghi Cervantes 2015-03-23 14:43:48 +01:00
parent 38f3dda13b
commit 4e934654ef
5 changed files with 30 additions and 20 deletions

View File

@ -105,6 +105,7 @@ use pocketmine\network\protocol\SetSpawnPositionPacket;
use pocketmine\network\protocol\SetTimePacket;
use pocketmine\network\protocol\StartGamePacket;
use pocketmine\network\protocol\TakeItemEntityPacket;
use pocketmine\network\protocol\UpdateBlockPacket;
use pocketmine\network\SourceInterface;
use pocketmine\permission\PermissibleBase;
use pocketmine\permission\PermissionAttachment;
@ -1714,7 +1715,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$target = $this->level->getBlock($blockVector);
$block = $target->getSide($packet->face);
$this->level->sendBlocks([$this], [$target, $block]);
$this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
break;
}elseif($packet->face === 0xff){
if($this->isCreative()){
@ -1891,7 +1892,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$target = $this->level->getBlock($vector);
$tile = $this->level->getTile($vector);
$this->level->sendBlocks([$this], [$target]);
$this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY);
if($tile instanceof Spawnable){
$tile->spawnTo($this);

View File

@ -83,6 +83,7 @@ abstract class Entity extends Location implements Metadatable{
const DATA_SHOW_NAMETAG = 3;
const DATA_POTION_COLOR = 7;
const DATA_POTION_VISIBLE = 8;
const DATA_NO_AI = 15;
const DATA_FLAG_ONFIRE = 0;
@ -1474,6 +1475,7 @@ abstract class Entity extends Location implements Metadatable{
* @param mixed $value
*/
public function setDataProperty($id, $type, $value){
if($this->getDataProperty($id) !== $value){
$this->dataProperties[$id] = [$type, $value];
$targets = $this->hasSpawned;
@ -1483,6 +1485,7 @@ abstract class Entity extends Location implements Metadatable{
$this->sendData($targets, [$id => $this->dataProperties[$id]]);
}
}
/**
* @param int $id

View File

@ -161,7 +161,7 @@ class Level implements ChunkManager, Metadatable{
/** @var FullChunk[]|Chunk[] */
private $chunks = [];
/** @var Block[][] */
/** @var Vector3[][] */
protected $changedBlocks = [];
/** @var ReversePriorityQueue */
@ -591,7 +591,7 @@ class Level implements ChunkManager, Metadatable{
$p->unloadChunk($X, $Z);
}
}else{
$this->sendBlocks($this->getUsingChunk($X, $Z), $blocks);
$this->sendBlocks($this->getUsingChunk($X, $Z), $blocks, UpdateBlockPacket::FLAG_ALL);
}
}
}
@ -618,8 +618,12 @@ class Level implements ChunkManager, Metadatable{
if($b === null){
continue;
}
if($b instanceof Block){
$pk->records[] = [$b->x, $b->z, $b->y, $b->getId(), $b->getDamage(), $flags];
}else{
$fullBlock = $this->getFullBlock($b->x, $b->y, $b->z);
$pk->records[] = [$b->x, $b->z, $b->y, $fullBlock >> 4, $fullBlock & 0xf, $flags];
}
}
Server::broadcastPacket($target, $pk);
}

View File

@ -91,7 +91,8 @@ class FloatingTextParticle extends Particle{
$pk->metadata = [
Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE],
Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300],
Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1]
Entity::DATA_SHOW_NAMETAG => [Entity::DATA_TYPE_BYTE, 1],
Entity::DATA_NO_AI => [Entity::DATA_TYPE_BYTE, 1]
];
$p[] = $pk;

View File

@ -28,13 +28,14 @@ class UpdateBlockPacket extends DataPacket{
public static $pool = [];
public static $next = 0;
const FLAG_NONE = 0b0;
const FLAG_NEIGHBORS = 0b1;
const FLAG_NOGRAPHIC = 0b100;
const FLAG_NONE = 0b0000;
const FLAG_NEIGHBORS = 0b0001;
const FLAG_NETWORK = 0b0010;
const FLAG_NOGRAPHIC = 0b0100;
const FLAG_PRIORITY = 0b1000;
const FLAG_ALL = self::FLAG_NEIGHBORS;
const FLAG_ALL_PRIORITY = self::FLAG_NEIGHBORS | self::FLAG_PRIORITY;
const FLAG_ALL = (self::FLAG_NEIGHBORS | self::FLAG_NETWORK);
const FLAG_ALL_PRIORITY = (self::FLAG_ALL | self::FLAG_PRIORITY);
public $records = []; //x, z, y, blockId, blockData, flags