From 31ef7721b13a169a791081189fc6cda307bbb57f Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Wed, 12 Aug 2015 14:59:30 +0200 Subject: [PATCH] Removed network channels, bumped protocol --- src/pocketmine/Player.php | 88 +++++++------- src/pocketmine/Server.php | 13 +- .../command/defaults/DifficultyCommand.php | 2 +- src/pocketmine/entity/Arrow.php | 2 +- src/pocketmine/entity/Effect.php | 4 +- src/pocketmine/entity/Entity.php | 8 +- src/pocketmine/entity/FallingSand.php | 2 +- src/pocketmine/entity/Human.php | 4 +- src/pocketmine/entity/Item.php | 2 +- src/pocketmine/entity/Living.php | 4 +- src/pocketmine/entity/PrimedTNT.php | 2 +- src/pocketmine/entity/Snowball.php | 2 +- src/pocketmine/entity/Squid.php | 4 +- src/pocketmine/entity/Villager.php | 2 +- src/pocketmine/entity/Zombie.php | 2 +- src/pocketmine/inventory/BaseInventory.php | 4 +- src/pocketmine/inventory/ChestInventory.php | 4 +- .../inventory/ContainerInventory.php | 4 +- .../inventory/DoubleChestInventory.php | 4 +- src/pocketmine/inventory/PlayerInventory.php | 12 +- src/pocketmine/level/Explosion.php | 2 +- src/pocketmine/level/Level.php | 18 +-- src/pocketmine/nbt/NBT.php | 2 +- src/pocketmine/network/Network.php | 9 ++ .../network/protocol/DataPacket.php | 3 + src/pocketmine/network/protocol/Info.php | 111 +++++++++--------- src/pocketmine/tile/Furnace.php | 4 +- src/pocketmine/tile/Spawnable.php | 2 +- 28 files changed, 166 insertions(+), 154 deletions(-) diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 0ca53f43a..91d8b56fe 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -621,7 +621,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new SetTimePacket(); $pk->time = $this->level->getTime(); $pk->started = $this->level->stopTime == false; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } } @@ -670,7 +670,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->chunkZ = $z; $pk->order = $ordering; $pk->data = $payload; - $this->batchDataPacket($pk->setChannel($this->spawned ? Network::CHANNEL_WORLD_CHUNKS : Network::CHANNEL_PRIORITY)); + $this->batchDataPacket($pk); } if($this->spawned){ @@ -735,7 +735,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new SetTimePacket(); $pk->time = $this->level->getTime(); $pk->started = $this->level->stopTime == false; - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); $pos = $this->level->getSafeSpawn($this); @@ -747,11 +747,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->x = $pos->x; $pk->y = $pos->y; $pk->z = $pos->z; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_CHUNKS)); + $this->dataPacket($pk); $pk = new PlayStatusPacket(); $pk->status = PlayStatusPacket::PLAYER_SPAWN; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_CHUNKS)); + $this->dataPacket($pk); $this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, new TranslationContainer(TextFormat::YELLOW . "%multiplayer.player.joined", [ @@ -787,7 +787,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->x = $pos->x; $pk->y = $pos->y; $pk->z = $pos->z; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } } @@ -1014,7 +1014,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->x = (int) $this->spawnPosition->x; $pk->y = (int) $this->spawnPosition->y; $pk->z = (int) $this->spawnPosition->z; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } public function stopSleep(){ @@ -1031,7 +1031,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new AnimatePacket(); $pk->eid = 0; $pk->action = 3; //Wake up - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } } @@ -1112,20 +1112,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->generator = 1; //0 old, 1 infinite, 2 flat $pk->gamemode = $this->gamemode & 0x01; $pk->eid = 0; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); $this->sendSettings(); if($this->gamemode === Player::SPECTATOR){ $pk = new ContainerSetContentPacket(); $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); }else{ $pk = new ContainerSetContentPacket(); $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; foreach(Item::getCreativeItems() as $item){ $pk->slots[] = clone $item; } - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } $this->inventory->sendContents($this); @@ -1197,7 +1197,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new AdventureSettingsPacket(); $pk->flags = $flags; - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); } public function isSurvival(){ @@ -1289,12 +1289,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new TakeItemEntityPacket(); $pk->eid = $this->getId(); $pk->target = $entity->getId(); - Server::broadcastPacket($entity->getViewers(), $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + Server::broadcastPacket($entity->getViewers(), $pk); $pk = new TakeItemEntityPacket(); $pk->eid = 0; $pk->target = $entity->getId(); - $this->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $this->dataPacket($pk); $this->inventory->addItem(clone $item); $entity->kill(); @@ -1324,12 +1324,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new TakeItemEntityPacket(); $pk->eid = $this->getId(); $pk->target = $entity->getId(); - Server::broadcastPacket($entity->getViewers(), $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + Server::broadcastPacket($entity->getViewers(), $pk); $pk = new TakeItemEntityPacket(); $pk->eid = 0; $pk->target = $entity->getId(); - $this->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $this->dataPacket($pk); $this->inventory->addItem(clone $item); $entity->kill(); @@ -1469,7 +1469,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->level->addEntityMotion($this->chunk->getX(), $this->chunk->getZ(), $this->getId(), $this->motionX, $this->motionY, $this->motionZ); $pk = new SetEntityMotionPacket(); $pk->entities[] = [0, $mot->x, $mot->y, $mot->z]; - $this->dataPacket($pk->setChannel(Network::CHANNEL_MOVEMENT)); + $this->dataPacket($pk); } if($this->motionY > 0){ @@ -1696,7 +1696,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new PlayStatusPacket(); $pk->status = PlayStatusPacket::LOGIN_SUCCESS; - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); if($this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){ $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level); @@ -1715,26 +1715,26 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->generator = 1; //0 old, 1 infinite, 2 flat $pk->gamemode = $this->gamemode & 0x01; $pk->eid = 0; //Always use EntityID as zero for the actual player - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); $pk = new SetTimePacket(); $pk->time = $this->level->getTime(); $pk->started = $this->level->stopTime == false; - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); $pk = new SetSpawnPositionPacket(); $pk->x = (int) $spawnPosition->x; $pk->y = (int) $spawnPosition->y; $pk->z = (int) $spawnPosition->z; - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); $pk = new SetHealthPacket(); $pk->health = $this->getHealth(); - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); $pk = new SetDifficultyPacket(); $pk->difficulty = $this->server->getDifficulty(); - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logIn", [ TextFormat::AQUA . $this->username . TextFormat::WHITE, @@ -1754,12 +1754,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($this->gamemode === Player::SPECTATOR){ $pk = new ContainerSetContentPacket(); $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); }else{ $pk = new ContainerSetContentPacket(); $pk->windowid = ContainerSetContentPacket::SPECIAL_CREATIVE; $pk->slots = Item::getCreativeItems(); - $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->dataPacket($pk); } $this->forceMovement = $this->teleportPosition = $this->getPosition(); @@ -1819,13 +1819,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new PlayStatusPacket(); $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT; - $this->directDataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->directDataPacket($pk); }else{ $message = "disconnectionScreen.outdatedServer"; $pk = new PlayStatusPacket(); $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER; - $this->directDataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->directDataPacket($pk); } $this->close("", $message, false); @@ -2181,7 +2181,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = EntityEventPacket::USE_ITEM; - $pk->setChannel(Network::CHANNEL_WORLD_EVENTS); + $pk; $this->dataPacket($pk); Server::broadcastPacket($this->getViewers(), $pk); @@ -2459,7 +2459,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new AnimatePacket(); $pk->eid = $this->getId(); $pk->action = $ev->getAnimationType(); - Server::broadcastPacket($this->getViewers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($this->getViewers(), $pk); break; case ProtocolInfo::SET_HEALTH_PACKET: //Not used break; @@ -2513,7 +2513,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = EntityEventPacket::USE_ITEM; - $pk->setChannel(Network::CHANNEL_WORLD_EVENTS); + $pk; $this->dataPacket($pk); Server::broadcastPacket($this->getViewers(), $pk); @@ -2964,7 +2964,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new TextPacket(); $pk->type = TextPacket::TYPE_RAW; $pk->message = $m; - $this->dataPacket($pk->setChannel(Network::CHANNEL_TEXT)); + $this->dataPacket($pk); } } } @@ -2982,7 +2982,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->type = TextPacket::TYPE_RAW; $pk->message = $this->server->getLanguage()->translateString($message, $parameters); } - $this->dataPacket($pk->setChannel(Network::CHANNEL_TEXT)); + $this->dataPacket($pk); } public function sendPopup($message, $subtitle = ""){ @@ -2990,14 +2990,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->type = TextPacket::TYPE_POPUP; $pk->source = $message; $pk->message = $subtitle; - $this->dataPacket($pk->setChannel(Network::CHANNEL_TEXT)); + $this->dataPacket($pk); } public function sendTip($message){ $pk = new TextPacket(); $pk->type = TextPacket::TYPE_TIP; $pk->message = $message; - $this->dataPacket($pk->setChannel(Network::CHANNEL_TEXT)); + $this->dataPacket($pk); } /** @@ -3014,7 +3014,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($notify and strlen((string) $reason) > 0){ $pk = new DisconnectPacket; $pk->message = $reason; - $this->directDataPacket($pk->setChannel(Network::CHANNEL_PRIORITY)); + $this->directDataPacket($pk); } $this->connected = false; @@ -3273,7 +3273,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->x = $pos->x; $pk->y = $pos->y; $pk->z = $pos->z; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } public function setHealth($amount){ @@ -3281,7 +3281,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if($this->spawned === true){ $pk = new SetHealthPacket(); $pk->health = $this->getHealth(); - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } } @@ -3308,11 +3308,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk = new EntityEventPacket(); $pk->eid = 0; $pk->event = EntityEventPacket::HURT_ANIMATION; - $this->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $this->dataPacket($pk); } } - public function sendPosition(Vector3 $pos, $yaw = null, $pitch = null, $mode = 0, $channel = Network::CHANNEL_PRIORITY, array $targets = null){ + public function sendPosition(Vector3 $pos, $yaw = null, $pitch = null, $mode = 0, array $targets = null){ $yaw = $yaw === null ? $this->yaw : $yaw; $pitch = $pitch === null ? $this->pitch : $pitch; @@ -3327,10 +3327,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $pk->mode = $mode; if($targets !== null){ - Server::broadcastPacket($targets, $pk->setChannel($channel)); + Server::broadcastPacket($targets, $pk); }else{ $pk->eid = 0; - $this->dataPacket($pk->setChannel($channel)); + $this->dataPacket($pk); } } @@ -3382,7 +3382,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } } - $this->sendPosition($this, null, null, 1, Network::CHANNEL_WORLD_CHUNKS); + $this->sendPosition($this, null, null, 1); $this->spawnToAll(); $this->forceMovement = $this->teleportPosition; $this->teleportPosition = null; @@ -3442,7 +3442,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } $this->forceMovement = new Vector3($this->x, $this->y, $this->z); - $this->sendPosition($this, $this->yaw, $this->pitch, 1, Network::CHANNEL_WORLD_EVENTS); + $this->sendPosition($this, $this->yaw, $this->pitch, 1); $this->resetFallDistance(); @@ -3567,7 +3567,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $batch = new BatchPacket(); $batch->payload = zlib_encode(Binary::writeInt(strlen($pk->getBuffer())) . $pk->getBuffer(), ZLIB_ENCODING_DEFLATE, Server::getInstance()->networkCompressionLevel); - $batch->setChannel(Network::CHANNEL_WORLD_CHUNKS); + $batch; $batch->encode(); $batch->isEncoded = true; return $batch; diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index e588f559d..261219566 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -1858,9 +1858,8 @@ class Server{ Timings::$playerNetworkTimer->stopTiming(); } - public function broadcastPacketsCallback($data, array $identifiers, $channel = 0){ + public function broadcastPacketsCallback($data, array $identifiers){ $pk = new BatchPacket(); - $pk->setChannel($channel); $pk->payload = $data; $pk->encode(); $pk->isEncoded = true; @@ -2259,7 +2258,7 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_REMOVE; $pk->entries[] = [$player->getUniqueId()]; - Server::broadcastPacket($this->playerList, $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + Server::broadcastPacket($this->playerList, $pk); } } @@ -2267,14 +2266,14 @@ class Server{ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_ADD; $pk->entries[] = [$uuid, $entityId, $name, $isSlim, $skinData]; - Server::broadcastPacket($players === null ? $this->playerList : $players, $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + Server::broadcastPacket($players === null ? $this->playerList : $players, $pk); } public function removePlayerListData(UUID $uuid, array $players = null){ $pk = new PlayerListPacket(); $pk->type = PlayerListPacket::TYPE_REMOVE; $pk->entries[] = [$uuid]; - Server::broadcastPacket($players === null ? $this->playerList : $players, $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + Server::broadcastPacket($players === null ? $this->playerList : $players, $pk); } public function sendFullPlayerListData(Player $p){ @@ -2284,7 +2283,7 @@ class Server{ $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->isSkinSlim(), $player->getSkinData()]; } - $p->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $p->dataPacket($pk); } public function sendRecipeList(Player $p){ @@ -2303,7 +2302,7 @@ class Server{ $pk->addFurnaceRecipe($recipe); } - $p->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $p->dataPacket($pk); } private function checkTickUpdates($currentTick, $tickTime){ diff --git a/src/pocketmine/command/defaults/DifficultyCommand.php b/src/pocketmine/command/defaults/DifficultyCommand.php index 88b0e85d4..c553037f7 100644 --- a/src/pocketmine/command/defaults/DifficultyCommand.php +++ b/src/pocketmine/command/defaults/DifficultyCommand.php @@ -62,7 +62,7 @@ class DifficultyCommand extends VanillaCommand{ $pk = new SetDifficultyPacket(); $pk->difficulty = $sender->getServer()->getDifficulty(); - Server::broadcastPacket($sender->getServer()->getOnlinePlayers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($sender->getServer()->getOnlinePlayers(), $pk); Command::broadcastCommandMessage($sender, new TranslationContainer("commands.difficulty.success", [$difficulty])); }else{ diff --git a/src/pocketmine/entity/Arrow.php b/src/pocketmine/entity/Arrow.php index c48187285..dd473637d 100644 --- a/src/pocketmine/entity/Arrow.php +++ b/src/pocketmine/entity/Arrow.php @@ -86,7 +86,7 @@ class Arrow extends Projectile{ $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Effect.php b/src/pocketmine/entity/Effect.php index e8196676b..b10dc0d30 100644 --- a/src/pocketmine/entity/Effect.php +++ b/src/pocketmine/entity/Effect.php @@ -249,7 +249,7 @@ class Effect{ $pk->eventId = MobEffectPacket::EVENT_ADD; } - $entity->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $entity->dataPacket($pk); } if($this->id === Effect::INVISIBILITY){ @@ -265,7 +265,7 @@ class Effect{ $pk->eventId = MobEffectPacket::EVENT_REMOVE; $pk->effectId = $this->getId(); - $entity->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $entity->dataPacket($pk); } if($this->id === Effect::INVISIBILITY){ diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index f3a96ddb3..96ea8d498 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -551,7 +551,7 @@ abstract class Entity extends Location implements Metadatable{ $pk->duration = $effect->getDuration(); $pk->eventId = MobEffectPacket::EVENT_ADD; - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); } } @@ -572,9 +572,9 @@ abstract class Entity extends Location implements Metadatable{ $pk->metadata = $data === null ? $this->dataProperties : $data; if(!is_array($player)){ - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); }else{ - Server::broadcastPacket($player, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($player, $pk); } } @@ -585,7 +585,7 @@ abstract class Entity extends Location implements Metadatable{ if(isset($this->hasSpawned[$player->getLoaderId()])){ $pk = new RemoveEntityPacket(); $pk->eid = $this->getId(); - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); unset($this->hasSpawned[$player->getLoaderId()]); } } diff --git a/src/pocketmine/entity/FallingSand.php b/src/pocketmine/entity/FallingSand.php index 2192499bf..645741586 100644 --- a/src/pocketmine/entity/FallingSand.php +++ b/src/pocketmine/entity/FallingSand.php @@ -170,7 +170,7 @@ class FallingSand extends Entity{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 483145f0c..34e15f785 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -227,7 +227,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $pk->pitch = $this->pitch; $pk->item = $this->getInventory()->getItemInHand(); $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); $this->inventory->sendArmorContents($player); @@ -243,7 +243,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $pk = new RemovePlayerPacket(); $pk->eid = $this->getId(); $pk->clientId = $this->getUniqueId(); - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); unset($this->hasSpawned[$player->getLoaderId()]); } } diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 729a3f833..686a6ed4a 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -234,7 +234,7 @@ class Item extends Entity{ $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->item = $this->getItem(); - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); $this->sendData($player); diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index e569ddee1..99c5514ef 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -69,7 +69,7 @@ abstract class Living extends Entity implements Damageable{ $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = EntityEventPacket::RESPAWN; - Server::broadcastPacket($this->hasSpawned, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($this->hasSpawned, $pk); } } @@ -127,7 +127,7 @@ abstract class Living extends Entity implements Damageable{ $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = $this->getHealth() <= 0 ? EntityEventPacket::DEATH_ANIMATION : EntityEventPacket::HURT_ANIMATION; //Ouch! - Server::broadcastPacket($this->hasSpawned, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($this->hasSpawned, $pk); $this->attackTime = 10; //0.5 seconds cooldown } diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index 07e7a2b76..3eb546d9e 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -144,7 +144,7 @@ class PrimedTNT extends Entity implements Explosive{ $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Snowball.php b/src/pocketmine/entity/Snowball.php index 825d681f6..b35d590af 100644 --- a/src/pocketmine/entity/Snowball.php +++ b/src/pocketmine/entity/Snowball.php @@ -72,7 +72,7 @@ class Snowball extends Projectile{ $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Squid.php b/src/pocketmine/entity/Squid.php index d55bac496..4fb76dae0 100644 --- a/src/pocketmine/entity/Squid.php +++ b/src/pocketmine/entity/Squid.php @@ -68,7 +68,7 @@ class Squid extends WaterAnimal implements Ageable{ $pk = new EntityEventPacket(); $pk->eid = $this->getId(); $pk->event = EntityEventPacket::SQUID_INK_CLOUD; - Server::broadcastPacket($this->hasSpawned, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($this->hasSpawned, $pk); } } @@ -160,7 +160,7 @@ class Squid extends WaterAnimal implements Ageable{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Villager.php b/src/pocketmine/entity/Villager.php index a34e3b969..3aa458911 100644 --- a/src/pocketmine/entity/Villager.php +++ b/src/pocketmine/entity/Villager.php @@ -65,7 +65,7 @@ class Villager extends Creature implements NPC, Ageable{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Zombie.php b/src/pocketmine/entity/Zombie.php index 300347818..1332b0edb 100644 --- a/src/pocketmine/entity/Zombie.php +++ b/src/pocketmine/entity/Zombie.php @@ -52,7 +52,7 @@ class Zombie extends Monster{ $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); parent::spawnTo($player); } diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 7fd8ea585..12cd43882 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -435,7 +435,7 @@ abstract class BaseInventory implements Inventory{ continue; } $pk->windowid = $id; - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); } } @@ -458,7 +458,7 @@ abstract class BaseInventory implements Inventory{ continue; } $pk->windowid = $id; - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); } } diff --git a/src/pocketmine/inventory/ChestInventory.php b/src/pocketmine/inventory/ChestInventory.php index fbcc48666..bfa764d43 100644 --- a/src/pocketmine/inventory/ChestInventory.php +++ b/src/pocketmine/inventory/ChestInventory.php @@ -51,7 +51,7 @@ class ChestInventory extends ContainerInventory{ $pk->case1 = 1; $pk->case2 = 2; if(($level = $this->getHolder()->getLevel()) instanceof Level){ - $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk); } } } @@ -65,7 +65,7 @@ class ChestInventory extends ContainerInventory{ $pk->case1 = 1; $pk->case2 = 0; if(($level = $this->getHolder()->getLevel()) instanceof Level){ - $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $level->addChunkPacket($this->getHolder()->getX() >> 4, $this->getHolder()->getZ() >> 4, $pk); } } parent::onClose($who); diff --git a/src/pocketmine/inventory/ContainerInventory.php b/src/pocketmine/inventory/ContainerInventory.php index c27dfcdda..72054d006 100644 --- a/src/pocketmine/inventory/ContainerInventory.php +++ b/src/pocketmine/inventory/ContainerInventory.php @@ -43,7 +43,7 @@ abstract class ContainerInventory extends BaseInventory{ $pk->x = $pk->y = $pk->z = 0; } - $who->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $who->dataPacket($pk); $this->sendContents($who); } @@ -51,7 +51,7 @@ abstract class ContainerInventory extends BaseInventory{ public function onClose(Player $who){ $pk = new ContainerClosePacket(); $pk->windowid = $who->getWindowId($this); - $who->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $who->dataPacket($pk); parent::onClose($who); } } \ No newline at end of file diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index 1fb1f1b7e..9cfd9ad93 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -106,7 +106,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ $pk->case1 = 1; $pk->case2 = 2; if(($level = $this->right->getHolder()->getLevel()) instanceof Level){ - $level->addChunkPacket($this->right->getHolder()->getX() >> 4, $this->right->getHolder()->getZ() >> 4, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $level->addChunkPacket($this->right->getHolder()->getX() >> 4, $this->right->getHolder()->getZ() >> 4, $pk); } } } @@ -120,7 +120,7 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ $pk->case1 = 1; $pk->case2 = 0; if(($level = $this->right->getHolder()->getLevel()) instanceof Level){ - $level->addChunkPacket($this->right->getHolder()->getX() >> 4, $this->right->getHolder()->getZ() >> 4, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $level->addChunkPacket($this->right->getHolder()->getX() >> 4, $this->right->getHolder()->getZ() >> 4, $pk); } } parent::onClose($who); diff --git a/src/pocketmine/inventory/PlayerInventory.php b/src/pocketmine/inventory/PlayerInventory.php index 8f1a3cfdb..db3cac450 100644 --- a/src/pocketmine/inventory/PlayerInventory.php +++ b/src/pocketmine/inventory/PlayerInventory.php @@ -133,12 +133,12 @@ class PlayerInventory extends BaseInventory{ $pk->selectedSlot = $this->getHeldItemIndex(); if(!is_array($target)){ - $target->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $target->dataPacket($pk); if($target === $this->getHolder()){ $this->sendSlot($this->getHeldItemSlot(), $target); } }else{ - Server::broadcastPacket($target, $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + Server::broadcastPacket($target, $pk); foreach($target as $player){ if($player === $this->getHolder()){ $this->sendSlot($this->getHeldItemSlot(), $player); @@ -310,7 +310,7 @@ class PlayerInventory extends BaseInventory{ $pk->eid = $this->getHolder()->getId(); $pk->slots = $armor; $pk->encode(); - $pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING); + $pk; $pk->isEncoded = true; foreach($target as $player){ @@ -369,7 +369,7 @@ class PlayerInventory extends BaseInventory{ $pk2->item = $this->getItem($index); $player->dataPacket($pk2); }else{ - $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING)); + $player->dataPacket($pk); } } } @@ -383,7 +383,7 @@ class PlayerInventory extends BaseInventory{ } $pk = new ContainerSetContentPacket(); - $pk->setChannel(Network::CHANNEL_WORLD_EVENTS); + $pk; $pk->slots = []; for($i = 0; $i < $this->getSize(); ++$i){ //Do not send armor by error here $pk->slots[$i] = $this->getItem($i); @@ -416,7 +416,7 @@ class PlayerInventory extends BaseInventory{ } $pk = new ContainerSetSlotPacket(); - $pk->setChannel(Network::CHANNEL_WORLD_EVENTS); + $pk; $pk->slot = $index; $pk->item = clone $this->getItem($index); diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 120130a02..8f6270cd5 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -233,7 +233,7 @@ class Explosion{ $pk->z = $this->source->z; $pk->radius = $this->size; $pk->records = $send; - $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk->setChannel(Network::CHANNEL_BLOCKS)); + $this->level->addChunkPacket($source->x >> 4, $source->z >> 4, $pk); return true; } diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index e08ace66b..173d367bb 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -466,9 +466,9 @@ class Level implements ChunkManager, Metadatable{ }else{ if($pk !== null){ if(!is_array($pk)){ - Server::broadcastPacket($players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($players, $pk); }else{ - $this->server->batchPackets($players, $pk, false, Network::CHANNEL_WORLD_EVENTS); + $this->server->batchPackets($players, $pk, false); } } } @@ -490,9 +490,9 @@ class Level implements ChunkManager, Metadatable{ }else{ if($pk !== null){ if(!is_array($pk)){ - Server::broadcastPacket($players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($players, $pk); }else{ - $this->server->batchPackets($players, $pk, false, Network::CHANNEL_WORLD_EVENTS); + $this->server->batchPackets($players, $pk, false); } } } @@ -658,7 +658,7 @@ class Level implements ChunkManager, Metadatable{ $pk->time = (int) $this->time; $pk->started = $this->stopTime == false; - Server::broadcastPacket($this->players, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($this->players, $pk); } /** @@ -751,7 +751,7 @@ class Level implements ChunkManager, Metadatable{ Level::getXZ($index, $chunkX, $chunkZ); $pk = new MoveEntityPacket(); $pk->entities = $entry; - $this->addChunkPacket($chunkX, $chunkZ, $pk->setChannel(Network::CHANNEL_MOVEMENT)); + $this->addChunkPacket($chunkX, $chunkZ, $pk); } $this->moveToSend = []; @@ -759,7 +759,7 @@ class Level implements ChunkManager, Metadatable{ Level::getXZ($index, $chunkX, $chunkZ); $pk = new SetEntityMotionPacket(); $pk->entities = $entry; - $this->addChunkPacket($chunkX, $chunkZ, $pk->setChannel(Network::CHANNEL_MOVEMENT)); + $this->addChunkPacket($chunkX, $chunkZ, $pk); } $this->motionToSend = []; @@ -812,7 +812,7 @@ class Level implements ChunkManager, Metadatable{ $pk->z = $z + 0.5; $pk->data = ($data << 8) | $id; - Server::broadcastPacket($targets === null ? $this->getChunkPlayers($x >> 4, $z >> 4) : $targets, $pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + Server::broadcastPacket($targets === null ? $this->getChunkPlayers($x >> 4, $z >> 4) : $targets, $pk); } /** @@ -859,7 +859,7 @@ class Level implements ChunkManager, Metadatable{ } - Server::broadcastPacket($target, $pk->setChannel(Network::CHANNEL_BLOCKS)); + Server::broadcastPacket($target, $pk); } public function clearCache($full = false){ diff --git a/src/pocketmine/nbt/NBT.php b/src/pocketmine/nbt/NBT.php index 178b6a84d..ef7197349 100644 --- a/src/pocketmine/nbt/NBT.php +++ b/src/pocketmine/nbt/NBT.php @@ -639,7 +639,7 @@ class NBT{ } } - private static function fromArrayGuesser($key, $value){ + public static function fromArrayGuesser($key, $value){ if(is_int($value)){ return new Int($key, $value); }elseif(is_float($value)){ diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 111cc6f85..8540d56b7 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -84,14 +84,23 @@ class Network{ public static $BATCH_THRESHOLD = 512; + /** @deprecated */ const CHANNEL_NONE = 0; + /** @deprecated */ const CHANNEL_PRIORITY = 1; //Priority channel, only to be used when it matters + /** @deprecated */ const CHANNEL_WORLD_CHUNKS = 2; //Chunk sending + /** @deprecated */ const CHANNEL_MOVEMENT = 3; //Movement sending + /** @deprecated */ const CHANNEL_BLOCKS = 4; //Block updates or explosions + /** @deprecated */ const CHANNEL_WORLD_EVENTS = 5; //Entity, level or tile entity events + /** @deprecated */ const CHANNEL_ENTITY_SPAWNING = 6; //Entity spawn/despawn channel + /** @deprecated */ const CHANNEL_TEXT = 7; //Chat and other text stuff + /** @deprecated */ const CHANNEL_END = 31; /** @var \SplFixedArray */ diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index a42b4525f..b71aa84a3 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -52,6 +52,9 @@ abstract class DataPacket extends BinaryStream{ $this->offset = 0; } + /** + * @deprecated This adds extra overhead on the network, so its usage is now discouraged. It was a test for the viability of this. + */ public function setChannel($channel){ $this->channel = (int) $channel; return $this; diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index 81a97b487..e22c2dc1d 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -30,62 +30,62 @@ interface Info{ /** * Actual Minecraft: PE protocol version */ - const CURRENT_PROTOCOL = 33; + const CURRENT_PROTOCOL = 34; - const LOGIN_PACKET = 0x87; - const PLAY_STATUS_PACKET = 0x88; - const DISCONNECT_PACKET = 0x89; - const BATCH_PACKET = 0x8a; - const TEXT_PACKET = 0x8b; - const SET_TIME_PACKET = 0x8c; - const START_GAME_PACKET = 0x8d; - const ADD_PLAYER_PACKET = 0x8e; - const REMOVE_PLAYER_PACKET = 0x8f; - const ADD_ENTITY_PACKET = 0x90; - const REMOVE_ENTITY_PACKET = 0x91; - const ADD_ITEM_ENTITY_PACKET = 0x92; - const TAKE_ITEM_ENTITY_PACKET = 0x93; - const MOVE_ENTITY_PACKET = 0x94; - const MOVE_PLAYER_PACKET = 0x95; - const REMOVE_BLOCK_PACKET = 0x96; - const UPDATE_BLOCK_PACKET = 0x97; - const ADD_PAINTING_PACKET = 0x98; - const EXPLODE_PACKET = 0x99; - const LEVEL_EVENT_PACKET = 0x9a; - const TILE_EVENT_PACKET = 0x9b; - const ENTITY_EVENT_PACKET = 0x9c; - const MOB_EFFECT_PACKET = 0x9d; - const UPDATE_ATTRIBUTES_PACKET = 0x9e; - const MOB_EQUIPMENT_PACKET = 0x9f; - const MOB_ARMOR_EQUIPMENT_PACKET = 0xa0; - const INTERACT_PACKET = 0xa1; - const USE_ITEM_PACKET = 0xa2; - const PLAYER_ACTION_PACKET = 0xa3; - const HURT_ARMOR_PACKET = 0xa4; - const SET_ENTITY_DATA_PACKET = 0xa5; - const SET_ENTITY_MOTION_PACKET = 0xa6; - const SET_ENTITY_LINK_PACKET = 0xa7; - const SET_HEALTH_PACKET = 0xa8; - const SET_SPAWN_POSITION_PACKET = 0xa9; - const ANIMATE_PACKET = 0xaa; - const RESPAWN_PACKET = 0xab; - const DROP_ITEM_PACKET = 0xac; - const CONTAINER_OPEN_PACKET = 0xad; - const CONTAINER_CLOSE_PACKET = 0xae; - const CONTAINER_SET_SLOT_PACKET = 0xaf; - const CONTAINER_SET_DATA_PACKET = 0xb0; - const CONTAINER_SET_CONTENT_PACKET = 0xb1; - const CRAFTING_DATA_PACKET = 0xb2; - const CRAFTING_EVENT_PACKET = 0xb3; - const ADVENTURE_SETTINGS_PACKET = 0xb4; - const TILE_ENTITY_DATA_PACKET = 0xb5; - //const PLAYER_INPUT_PACKET = 0xb6; - const FULL_CHUNK_DATA_PACKET = 0xb7; - const SET_DIFFICULTY_PACKET = 0xb8; - //const CHANGE_DIMENSION_PACKET = 0xb9; - //const SET_PLAYER_GAMETYPE_PACKET = 0xba; - const PLAYER_LIST_PACKET = 0xbb; - //const TELEMETRY_EVENT_PACKET = 0xbc; + const LOGIN_PACKET = 0x8f; + const PLAY_STATUS_PACKET = 0x90; + const DISCONNECT_PACKET = 0x91; + const BATCH_PACKET = 0x92; + const TEXT_PACKET = 0x93; + const SET_TIME_PACKET = 0x94; + const START_GAME_PACKET = 0x95; + const ADD_PLAYER_PACKET = 0x96; + const REMOVE_PLAYER_PACKET = 0x97; + const ADD_ENTITY_PACKET = 0x98; + const REMOVE_ENTITY_PACKET = 0x99; + const ADD_ITEM_ENTITY_PACKET = 0x9a; + const TAKE_ITEM_ENTITY_PACKET = 0x9b; + const MOVE_ENTITY_PACKET = 0x9c; + const MOVE_PLAYER_PACKET = 0x9d; + const REMOVE_BLOCK_PACKET = 0x9e; + const UPDATE_BLOCK_PACKET = 0x9f; + const ADD_PAINTING_PACKET = 0xa0; + const EXPLODE_PACKET = 0xa1; + const LEVEL_EVENT_PACKET = 0xa2; + const TILE_EVENT_PACKET = 0xa3; + const ENTITY_EVENT_PACKET = 0xa4; + const MOB_EFFECT_PACKET = 0xa5; + const UPDATE_ATTRIBUTES_PACKET = 0xa6; + const MOB_EQUIPMENT_PACKET = 0xa7; + const MOB_ARMOR_EQUIPMENT_PACKET = 0xa8; + const INTERACT_PACKET = 0xa9; + const USE_ITEM_PACKET = 0xaa; + const PLAYER_ACTION_PACKET = 0xab; + const HURT_ARMOR_PACKET = 0xac; + const SET_ENTITY_DATA_PACKET = 0xad; + const SET_ENTITY_MOTION_PACKET = 0xae; + const SET_ENTITY_LINK_PACKET = 0xaf; + const SET_HEALTH_PACKET = 0xb0; + const SET_SPAWN_POSITION_PACKET = 0xb1; + const ANIMATE_PACKET = 0xb2; + const RESPAWN_PACKET = 0xb3; + const DROP_ITEM_PACKET = 0xb4; + const CONTAINER_OPEN_PACKET = 0xb5; + const CONTAINER_CLOSE_PACKET = 0xb6; + const CONTAINER_SET_SLOT_PACKET = 0xb7; + const CONTAINER_SET_DATA_PACKET = 0xb8; + const CONTAINER_SET_CONTENT_PACKET = 0xb9; + const CRAFTING_DATA_PACKET = 0xba; + const CRAFTING_EVENT_PACKET = 0xbb; + const ADVENTURE_SETTINGS_PACKET = 0xbc; + const TILE_ENTITY_DATA_PACKET = 0xbd; + //const PLAYER_INPUT_PACKET = 0xbe; + const FULL_CHUNK_DATA_PACKET = 0xbf; + const SET_DIFFICULTY_PACKET = 0xc0; + //const CHANGE_DIMENSION_PACKET = 0xc1; + //const SET_PLAYER_GAMETYPE_PACKET = 0xc2; + const PLAYER_LIST_PACKET = 0xc3; + //const TELEMETRY_EVENT_PACKET = 0xc4; } @@ -98,3 +98,4 @@ interface Info{ + diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index 0c4e82e65..e24a0bb86 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -269,13 +269,13 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ $pk->windowid = $windowId; $pk->property = 0; //Smelting $pk->value = floor($this->namedtag["CookTime"]); - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); $pk = new ContainerSetDataPacket(); $pk->windowid = $windowId; $pk->property = 1; //Fire icon $pk->value = $this->namedtag["BurnTicks"]; - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); } } diff --git a/src/pocketmine/tile/Spawnable.php b/src/pocketmine/tile/Spawnable.php index 8e41d9f5d..37828e0c3 100644 --- a/src/pocketmine/tile/Spawnable.php +++ b/src/pocketmine/tile/Spawnable.php @@ -42,7 +42,7 @@ abstract class Spawnable extends Tile{ $pk->y = $this->y; $pk->z = $this->z; $pk->namedtag = $nbt->write(); - $player->dataPacket($pk->setChannel(Network::CHANNEL_WORLD_EVENTS)); + $player->dataPacket($pk); return true; }