diff --git a/src/entity/Animal.php b/src/entity/Animal.php index 60dbf9c46..17fb750b2 100644 --- a/src/entity/Animal.php +++ b/src/entity/Animal.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine\entity; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; abstract class Animal extends Living implements Ageable{ @@ -33,8 +34,8 @@ abstract class Animal extends Living implements Ageable{ return $this->baby; } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); + $properties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby); } } diff --git a/src/entity/Entity.php b/src/entity/Entity.php index e428b1391..0125fa557 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -87,7 +87,7 @@ abstract class Entity{ protected $id; /** @var EntityMetadataCollection */ - protected $networkProperties; + private $networkProperties; /** @var Chunk|null */ public $chunk; @@ -1650,30 +1650,30 @@ abstract class Entity{ * @return MetadataProperty[] */ final protected function getSyncedNetworkData(bool $dirtyOnly) : array{ - $this->syncNetworkData(); + $this->syncNetworkData($this->networkProperties); return $dirtyOnly ? $this->networkProperties->getDirty() : $this->networkProperties->getAll(); } - protected function syncNetworkData() : void{ - $this->networkProperties->setByte(EntityMetadataProperties::ALWAYS_SHOW_NAMETAG, $this->alwaysShowNameTag ? 1 : 0); - $this->networkProperties->setFloat(EntityMetadataProperties::BOUNDING_BOX_HEIGHT, $this->height); - $this->networkProperties->setFloat(EntityMetadataProperties::BOUNDING_BOX_WIDTH, $this->width); - $this->networkProperties->setFloat(EntityMetadataProperties::SCALE, $this->scale); - $this->networkProperties->setLong(EntityMetadataProperties::LEAD_HOLDER_EID, -1); - $this->networkProperties->setLong(EntityMetadataProperties::OWNER_EID, $this->ownerId ?? -1); - $this->networkProperties->setLong(EntityMetadataProperties::TARGET_EID, $this->targetId ?? 0); - $this->networkProperties->setString(EntityMetadataProperties::NAMETAG, $this->nameTag); - $this->networkProperties->setString(EntityMetadataProperties::SCORE_TAG, $this->scoreTag); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + $properties->setByte(EntityMetadataProperties::ALWAYS_SHOW_NAMETAG, $this->alwaysShowNameTag ? 1 : 0); + $properties->setFloat(EntityMetadataProperties::BOUNDING_BOX_HEIGHT, $this->height); + $properties->setFloat(EntityMetadataProperties::BOUNDING_BOX_WIDTH, $this->width); + $properties->setFloat(EntityMetadataProperties::SCALE, $this->scale); + $properties->setLong(EntityMetadataProperties::LEAD_HOLDER_EID, -1); + $properties->setLong(EntityMetadataProperties::OWNER_EID, $this->ownerId ?? -1); + $properties->setLong(EntityMetadataProperties::TARGET_EID, $this->targetId ?? 0); + $properties->setString(EntityMetadataProperties::NAMETAG, $this->nameTag); + $properties->setString(EntityMetadataProperties::SCORE_TAG, $this->scoreTag); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::AFFECTED_BY_GRAVITY, true); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::CAN_CLIMB, $this->canClimb); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::CAN_SHOW_NAMETAG, $this->nameTagVisible); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::HAS_COLLISION, true); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::IMMOBILE, $this->immobile); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::INVISIBLE, $this->invisible); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::ONFIRE, $this->isOnFire()); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::WALLCLIMBING, $this->canClimbWalls); + $properties->setGenericFlag(EntityMetadataFlags::AFFECTED_BY_GRAVITY, true); + $properties->setGenericFlag(EntityMetadataFlags::CAN_CLIMB, $this->canClimb); + $properties->setGenericFlag(EntityMetadataFlags::CAN_SHOW_NAMETAG, $this->nameTagVisible); + $properties->setGenericFlag(EntityMetadataFlags::HAS_COLLISION, true); + $properties->setGenericFlag(EntityMetadataFlags::IMMOBILE, $this->immobile); + $properties->setGenericFlag(EntityMetadataFlags::INVISIBLE, $this->invisible); + $properties->setGenericFlag(EntityMetadataFlags::ONFIRE, $this->isOnFire()); + $properties->setGenericFlag(EntityMetadataFlags::WALLCLIMBING, $this->canClimbWalls); } /** diff --git a/src/entity/Living.php b/src/entity/Living.php index 2097bf0d4..0f96a5877 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -49,6 +49,7 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\FloatTag; use pocketmine\nbt\tag\ListTag; use pocketmine\nbt\tag\ShortTag; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\player\Player; @@ -766,17 +767,17 @@ abstract class Living extends Entity{ $player->getNetworkSession()->onMobArmorChange($this); } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setByte(EntityMetadataProperties::POTION_AMBIENT, $this->effectManager->hasOnlyAmbientEffects() ? 1 : 0); - $this->networkProperties->setInt(EntityMetadataProperties::POTION_COLOR, Binary::signInt($this->effectManager->getBubbleColor()->toARGB())); - $this->networkProperties->setShort(EntityMetadataProperties::AIR, $this->breathTicks); - $this->networkProperties->setShort(EntityMetadataProperties::MAX_AIR, $this->maxBreathTicks); + $properties->setByte(EntityMetadataProperties::POTION_AMBIENT, $this->effectManager->hasOnlyAmbientEffects() ? 1 : 0); + $properties->setInt(EntityMetadataProperties::POTION_COLOR, Binary::signInt($this->effectManager->getBubbleColor()->toARGB())); + $properties->setShort(EntityMetadataProperties::AIR, $this->breathTicks); + $properties->setShort(EntityMetadataProperties::MAX_AIR, $this->maxBreathTicks); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::BREATHING, $this->breathing); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::SNEAKING, $this->sneaking); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::SPRINTING, $this->sprinting); + $properties->setGenericFlag(EntityMetadataFlags::BREATHING, $this->breathing); + $properties->setGenericFlag(EntityMetadataFlags::SNEAKING, $this->sneaking); + $properties->setGenericFlag(EntityMetadataFlags::SPRINTING, $this->sprinting); } protected function onDispose() : void{ diff --git a/src/entity/Villager.php b/src/entity/Villager.php index e784d0c57..bdc0e33ae 100644 --- a/src/entity/Villager.php +++ b/src/entity/Villager.php @@ -25,6 +25,7 @@ namespace pocketmine\entity; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; @@ -84,10 +85,10 @@ class Villager extends Living implements Ageable{ return $this->baby; } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); + $properties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby); - $this->networkProperties->setInt(EntityMetadataProperties::VARIANT, $this->profession); + $properties->setInt(EntityMetadataProperties::VARIANT, $this->profession); } } diff --git a/src/entity/WaterAnimal.php b/src/entity/WaterAnimal.php index 921766711..5edae8ffd 100644 --- a/src/entity/WaterAnimal.php +++ b/src/entity/WaterAnimal.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\entity; use pocketmine\event\entity\EntityDamageEvent; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; abstract class WaterAnimal extends Living implements Ageable{ @@ -43,8 +44,8 @@ abstract class WaterAnimal extends Living implements Ageable{ $this->attack($ev); } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); + $properties->setGenericFlag(EntityMetadataFlags::BABY, $this->baby); } } diff --git a/src/entity/object/ExperienceOrb.php b/src/entity/object/ExperienceOrb.php index 65f0ad89c..a58ba1034 100644 --- a/src/entity/object/ExperienceOrb.php +++ b/src/entity/object/ExperienceOrb.php @@ -29,6 +29,7 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\ShortTag; use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\player\Player; use function sqrt; @@ -220,9 +221,9 @@ class ExperienceOrb extends Entity{ return false; } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setInt(EntityMetadataProperties::EXPERIENCE_VALUE, $this->xpValue); + $properties->setInt(EntityMetadataProperties::EXPERIENCE_VALUE, $this->xpValue); } } diff --git a/src/entity/object/FallingBlock.php b/src/entity/object/FallingBlock.php index 94e85cf38..e53070a24 100644 --- a/src/entity/object/FallingBlock.php +++ b/src/entity/object/FallingBlock.php @@ -33,6 +33,7 @@ use pocketmine\nbt\tag\ByteTag; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use function abs; use function get_class; @@ -140,9 +141,9 @@ class FallingBlock extends Entity{ return $nbt; } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setInt(EntityMetadataProperties::VARIANT, $this->block->getRuntimeId()); + $properties->setInt(EntityMetadataProperties::VARIANT, $this->block->getRuntimeId()); } } diff --git a/src/entity/object/PrimedTNT.php b/src/entity/object/PrimedTNT.php index da6019b16..b38f8a68f 100644 --- a/src/entity/object/PrimedTNT.php +++ b/src/entity/object/PrimedTNT.php @@ -29,6 +29,7 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\ExplosionPrimeEvent; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\world\Explosion; @@ -108,10 +109,10 @@ class PrimedTNT extends Entity implements Explosive{ } } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::IGNITED, true); - $this->networkProperties->setInt(EntityMetadataProperties::FUSE_LENGTH, $this->fuse); + $properties->setGenericFlag(EntityMetadataFlags::IGNITED, true); + $properties->setInt(EntityMetadataProperties::FUSE_LENGTH, $this->fuse); } } diff --git a/src/entity/projectile/Arrow.php b/src/entity/projectile/Arrow.php index bfddc295b..6609453ee 100644 --- a/src/entity/projectile/Arrow.php +++ b/src/entity/projectile/Arrow.php @@ -32,6 +32,7 @@ use pocketmine\item\VanillaItems; use pocketmine\math\RayTraceResult; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\player\Player; use pocketmine\world\sound\ArrowHitSound; @@ -193,9 +194,9 @@ class Arrow extends Projectile{ $this->flagForDespawn(); } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::CRITICAL, $this->critical); + $properties->setGenericFlag(EntityMetadataFlags::CRITICAL, $this->critical); } } diff --git a/src/entity/projectile/SplashPotion.php b/src/entity/projectile/SplashPotion.php index 168dac90a..a6f2cf0b4 100644 --- a/src/entity/projectile/SplashPotion.php +++ b/src/entity/projectile/SplashPotion.php @@ -35,6 +35,7 @@ use pocketmine\event\entity\ProjectileHitEvent; use pocketmine\item\Potion; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\protocol\types\entity\EntityLegacyIds; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\world\particle\PotionSplashParticle; @@ -172,10 +173,10 @@ class SplashPotion extends Throwable{ return Potion::getPotionEffectsById($this->getPotionId()); } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setShort(EntityMetadataProperties::POTION_AUX_VALUE, $this->potionId); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::LINGER, $this->linger); + $properties->setShort(EntityMetadataProperties::POTION_AUX_VALUE, $this->potionId); + $properties->setGenericFlag(EntityMetadataFlags::LINGER, $this->linger); } } diff --git a/src/player/Player.php b/src/player/Player.php index 58b55ca68..defd369b6 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -86,6 +86,7 @@ use pocketmine\nbt\tag\ListTag; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\AnimatePacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket; +use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties; use pocketmine\network\mcpe\protocol\types\entity\PlayerMetadataFlags; @@ -2181,13 +2182,13 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener, parent::attack($source); } - protected function syncNetworkData() : void{ - parent::syncNetworkData(); + protected function syncNetworkData(EntityMetadataCollection $properties) : void{ + parent::syncNetworkData($properties); - $this->networkProperties->setGenericFlag(EntityMetadataFlags::ACTION, $this->startAction > -1); + $properties->setGenericFlag(EntityMetadataFlags::ACTION, $this->startAction > -1); - $this->networkProperties->setPlayerFlag(PlayerMetadataFlags::SLEEP, $this->sleeping !== null); - $this->networkProperties->setBlockPos(EntityMetadataProperties::PLAYER_BED_POSITION, $this->sleeping ?? new Vector3(0, 0, 0)); + $properties->setPlayerFlag(PlayerMetadataFlags::SLEEP, $this->sleeping !== null); + $properties->setBlockPos(EntityMetadataProperties::PLAYER_BED_POSITION, $this->sleeping ?? new Vector3(0, 0, 0)); } public function broadcastAnimation(Animation $animation, ?array $targets = null) : void{