diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 8500567cbe..41dca435c1 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -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); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f9f5583f7c..bba7d5e633 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -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,14 +1475,16 @@ abstract class Entity extends Location implements Metadatable{ * @param mixed $value */ public function setDataProperty($id, $type, $value){ - $this->dataProperties[$id] = [$type, $value]; + if($this->getDataProperty($id) !== $value){ + $this->dataProperties[$id] = [$type, $value]; - $targets = $this->hasSpawned; - if($this instanceof Player){ - $targets[] = $this; - } + $targets = $this->hasSpawned; + if($this instanceof Player){ + $targets[] = $this; + } - $this->sendData($targets, [$id => $this->dataProperties[$id]]); + $this->sendData($targets, [$id => $this->dataProperties[$id]]); + } } /** diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 2687f8ed2f..13ae68f962 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -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; } - - $pk->records[] = [$b->x, $b->z, $b->y, $b->getId(), $b->getDamage(), $flags]; + 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); } diff --git a/src/pocketmine/level/particle/FloatingTextParticle.php b/src/pocketmine/level/particle/FloatingTextParticle.php index 671b15c6de..98cfb7147e 100644 --- a/src/pocketmine/level/particle/FloatingTextParticle.php +++ b/src/pocketmine/level/particle/FloatingTextParticle.php @@ -91,8 +91,9 @@ 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; } diff --git a/src/pocketmine/network/protocol/UpdateBlockPacket.php b/src/pocketmine/network/protocol/UpdateBlockPacket.php index d42c8d1294..465bca1dbe 100644 --- a/src/pocketmine/network/protocol/UpdateBlockPacket.php +++ b/src/pocketmine/network/protocol/UpdateBlockPacket.php @@ -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_PRIORITY = 0b1000; + 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