mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 08:39:53 +00:00
Improved metadata sending and made it less spammy
Add changed properties to a list to send in a group on tick in a single packet
This commit is contained in:
parent
8637e0224f
commit
be7b057fa5
@ -874,6 +874,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
$this->sendSettings();
|
$this->sendSettings();
|
||||||
$this->sendPotionEffects($this);
|
$this->sendPotionEffects($this);
|
||||||
|
|
||||||
$this->sendData($this);
|
$this->sendData($this);
|
||||||
$this->inventory->sendContents($this);
|
$this->inventory->sendContents($this);
|
||||||
$this->inventory->sendArmorContents($this);
|
$this->inventory->sendArmorContents($this);
|
||||||
@ -2730,7 +2731,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
$this->setSneaking(false);
|
$this->setSneaking(false);
|
||||||
|
|
||||||
$this->extinguish();
|
$this->extinguish();
|
||||||
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 400, false);
|
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 400);
|
||||||
$this->deadTicks = 0;
|
$this->deadTicks = 0;
|
||||||
$this->noDamageTicks = 60;
|
$this->noDamageTicks = 60;
|
||||||
|
|
||||||
|
@ -229,7 +229,6 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
|
|
||||||
protected $id;
|
protected $id;
|
||||||
|
|
||||||
protected $dataFlags = 0;
|
|
||||||
protected $dataProperties = [
|
protected $dataProperties = [
|
||||||
self::DATA_FLAGS => [self::DATA_TYPE_LONG, 0],
|
self::DATA_FLAGS => [self::DATA_TYPE_LONG, 0],
|
||||||
self::DATA_AIR => [self::DATA_TYPE_SHORT, 400],
|
self::DATA_AIR => [self::DATA_TYPE_SHORT, 400],
|
||||||
@ -239,6 +238,8 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
self::DATA_SCALE => [self::DATA_TYPE_FLOAT, 1]
|
self::DATA_SCALE => [self::DATA_TYPE_FLOAT, 1]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $changedDataProperties = [];
|
||||||
|
|
||||||
public $passenger = null;
|
public $passenger = null;
|
||||||
public $vehicle = null;
|
public $vehicle = null;
|
||||||
|
|
||||||
@ -1132,6 +1133,11 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(count($this->changedDataProperties) > 0){
|
||||||
|
$this->sendData($this->hasSpawned, $this->changedDataProperties);
|
||||||
|
$this->changedDataProperties = [];
|
||||||
|
}
|
||||||
|
|
||||||
if(count($this->effects) > 0){
|
if(count($this->effects) > 0){
|
||||||
foreach($this->effects as $effect){
|
foreach($this->effects as $effect){
|
||||||
if($effect->canTick()){
|
if($effect->canTick()){
|
||||||
@ -1866,11 +1872,11 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setDataProperty($id, $type, $value, $send = true){
|
public function setDataProperty($id, $type, $value, bool $send = true){
|
||||||
if($this->getDataProperty($id) !== $value){
|
if($this->getDataProperty($id) !== $value){
|
||||||
$this->dataProperties[$id] = [$type, $value];
|
$this->dataProperties[$id] = [$type, $value];
|
||||||
if($send === true){
|
if($send){
|
||||||
$this->sendData($this->hasSpawned, [$id => $this->dataProperties[$id]]);
|
$this->changedDataProperties[$id] = $this->dataProperties[$id]; //This will be sent on the next tick
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user