diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index d2148fc37..71682f756 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -72,7 +72,6 @@ use pocketmine\inventory\StonecutterShapelessRecipe; use pocketmine\item\Item; use pocketmine\level\format\FullChunk; use pocketmine\level\format\LevelProvider; -use pocketmine\level\generator\biome\Biome; use pocketmine\level\Level; use pocketmine\level\Location; use pocketmine\level\Position; @@ -97,6 +96,7 @@ use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\Info as ProtocolInfo; use pocketmine\network\protocol\PlayStatusPacket; +use pocketmine\network\protocol\RespawnPacket; use pocketmine\network\protocol\TextPacket; use pocketmine\network\protocol\MoveEntityPacket; use pocketmine\network\protocol\MovePlayerPacket; @@ -162,7 +162,15 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ public $craftingType = 0; //0 = 2x2 crafting, 1 = 3x3 crafting, 2 = stonecutter protected $isCrafting = false; + + /** + * @deprecated + * @var array + */ public $loginData = []; + + protected $randomClientId; + protected $lastMovement = 0; /** @var Vector3 */ protected $forceMovement = null; @@ -198,9 +206,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ private $spawnPosition = null; protected $inAirTicks = 0; - protected $lastSpeedTick = 0; - protected $speedTicks = 0; - protected $highSpeedTicks = 0; private $needACK = []; @@ -213,6 +218,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ /** @var PermissibleBase */ private $perm = null; + public function getClientId(){ + return $this->randomClientId; + } + public function isBanned(){ return $this->server->getNameBans()->isBanned(strtolower($this->getName())); } @@ -492,18 +501,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->displayName = $name; } - /** - * @return string - */ - public function getNameTag(){ - return $this->nameTag; + public function setSkin($str, $isSlim = false){ + parent::setSkin($str, $isSlim); + $this->despawnFromAll(); + if($this->spawned === true){ + $this->spawnToAll(); + } } - /** - * @param string $name - */ public function setNameTag($name){ - $this->nameTag = $name; + parent::setNameTag($name); $this->despawnFromAll(); if($this->spawned === true){ $this->spawnToAll(); @@ -615,8 +622,8 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->spawned = true; $this->sendSettings(); - $this->sendData($this); $this->sendPotionEffects($this); + $this->sendData($this); $this->inventory->sendContents($this); $this->inventory->sendArmorContents($this); @@ -926,7 +933,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk = new StartGamePacket(); $pk->seed = $this->level->getSeed(); $pk->x = $this->x; - $pk->y = $this->y + $this->getEyeHeight(); + $pk->y = $this->y; $pk->z = $this->z; $pk->spawnX = (int) $spawnPosition->x; $pk->spawnY = (int) $spawnPosition->y; @@ -1038,13 +1045,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ protected function processMovement($currentTick){ if($this->dead or !$this->spawned or !($this->newPosition instanceof Vector3)){ - $diff = ($currentTick - $this->lastSpeedTick); - if($diff >= 10){ - $this->speed = new Vector3(0, 0, 0); - }elseif($diff > 5 and $this->speedTicks < 20){ - ++$this->speedTicks; - } - return; } @@ -1127,33 +1127,16 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ if($to->distanceSquared($ev->getTo()) > 0.01){ //If plugins modify the destination $this->teleport($ev->getTo()); }else{ - $pk = new MovePlayerPacket(); - $pk->eid = $this->id; - $pk->x = $this->x; - $pk->y = $this->y; - $pk->z = $this->z; - $pk->yaw = $this->yaw; - $pk->pitch = $this->pitch; - $pk->bodyYaw = $this->yaw; - - Server::broadcastPacket($this->hasSpawned, $pk); + foreach($this->hasSpawned as $player){ + $player->addEntityMovement($this->id, $this->x, $this->y + $this->getEyeHeight(), $this->z, $this->yaw, $this->pitch, $this->yaw); + } } } } - $ticks = min(20, $currentTick - $this->lastSpeedTick + 0.5); - if($this->speedTicks > 0){ - $ticks += $this->speedTicks; - } - $this->speed = $from->subtract($to)->divide($ticks); - $this->lastSpeedTick = $currentTick; + $this->speed = $from->subtract($to); }elseif($distanceSquared == 0){ $this->speed = new Vector3(0, 0, 0); - $this->lastSpeedTick = $currentTick; - } - - if($this->speedTicks > 0){ - --$this->speedTicks; } if($revert){ @@ -1173,7 +1156,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->bodyYaw = $from->yaw; $pk->pitch = $from->pitch; $pk->yaw = $from->yaw; - $pk->teleport = true; $this->directDataPacket($pk); $this->forceMovement = new Vector3($from->x, $from->y, $from->z); }else{ @@ -1212,30 +1194,10 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->entityBaseTick(1); - if($this->forceMovement === null and $this->speed and $this->isSurvival()){ - $speed = sqrt($this->speed->x ** 2 + $this->speed->z ** 2); - if($speed > 0.45){ - $this->highSpeedTicks += $speed > 3 ? 2 : 1; - if(!$this->hasEffect(Effect::SPEED) and $this->highSpeedTicks > 40 and !$this->server->getAllowFlight()){ - if($this->kick("Flying is not enabled on this server")){ - return false; - } - }elseif($this->highSpeedTicks >= 10 and $this->highSpeedTicks % 4 === 0){ - $this->forceMovement = $this->getPosition(); - } - }elseif($this->highSpeedTicks > 0){ - if($speed < 22){ - $this->highSpeedTicks = 0; - }else{ - $this->highSpeedTicks--; - } - } - } - if($this->onGround){ $this->inAirTicks = 0; }else{ - if($this->inAirTicks > 10 and $this->isSurvival() and !$this->isSleeping()){ + if($this->inAirTicks > 10 and $this->isSurvival() and !$this->isSleeping() and $this->getDataProperty(self::DATA_NO_AI) === 0){ $expectedVelocity = (-$this->gravity) / $this->drag - ((-$this->gravity) / $this->drag) * exp(-$this->drag * ($this->inAirTicks - 5)); $diff = sqrt(abs($this->speed->y - $expectedVelocity)); @@ -1373,7 +1335,9 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->displayName = $this->username; $this->nameTag = $this->username; $this->iusername = strtolower($this->username); - $this->loginData = ["clientId" => $packet->clientId, "loginData" => $packet->loginData]; + $this->randomClientId = $packet->clientId; + $this->setSkin($packet->skin, $packet->slim); + $this->loginData = ["clientId" => $packet->clientId, "loginData" => null]; if(count($this->server->getOnlinePlayers()) > $this->server->getMaxPlayers() and $this->kick("server full")){ return; @@ -1511,6 +1475,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->eid = $this->getId(); //Always use EntityID as zero for the actual player $this->dataPacket($pk); + $pk = new RespawnPacket(); + $pk->x = $this->x; + $pk->y = $this->y; + $pk->z = $this->z; + $this->dataPacket($pk); + $pk = new SetTimePacket(); $pk->time = $this->level->getTime(); $pk->started = $this->level->stopTime == false; @@ -1541,7 +1511,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ break; case ProtocolInfo::MOVE_PLAYER_PACKET: - $newPos = new Vector3($packet->x, $packet->y, $packet->z); + $newPos = new Vector3($packet->x, $packet->y - $this->getEyeHeight(), $packet->z); $revert = false; if($this->dead === true or $this->spawned !== true){ @@ -1549,7 +1519,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $this->forceMovement = new Vector3($this->x, $this->y, $this->z); } - if($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.04 or $revert)){ + if($this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert)){ $pk = new MovePlayerPacket(); $pk->eid = $this->getId(); $pk->x = $this->forceMovement->x; @@ -1558,7 +1528,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->bodyYaw = $packet->bodyYaw; $pk->pitch = $packet->pitch; $pk->yaw = $packet->yaw; - $pk->teleport = true; $this->directDataPacket($pk); }else{ $packet->yaw %= 360; @@ -1747,7 +1716,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ } break; case ProtocolInfo::PLAYER_ACTION_PACKET: - if($this->spawned === false or $this->blocked === true or $this->dead === true){ + if($this->spawned === false or $this->blocked === true or ($this->dead === true and $packet->action !== 7)){ break; } @@ -1833,6 +1802,37 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ case 6: //get out of the bed $this->stopSleep(); break; + case 7: //Respawn + if($this->spawned === false or $this->dead === false){ + break; + } + + $this->craftingType = 0; + + $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn())); + + $this->teleport($ev->getRespawnPosition()); + + $this->extinguish(); + $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300); + $this->deadTicks = 0; + $this->noDamageTicks = 60; + + $this->setHealth(20); + $this->dead = false; + + $this->removeAllEffects(); + $this->sendData($this); + + $this->sendSettings(); + $this->inventory->sendContents($this); + $this->inventory->sendArmorContents($this); + + $this->blocked = false; + + $this->spawnToAll(); + $this->scheduleUpdate(); + break; } $this->startAction = -1; @@ -2019,37 +2019,6 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->action = $ev->getAnimationType(); Server::broadcastPacket($this->getViewers(), $pk); break; - case ProtocolInfo::RESPAWN_PACKET: - if($this->spawned === false or $this->dead === false){ - break; - } - - $this->craftingType = 0; - - $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn())); - - $this->teleport($ev->getRespawnPosition()); - - $this->extinguish(); - $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300); - $this->deadTicks = 0; - $this->noDamageTicks = 60; - - $this->setHealth(20); - $this->dead = false; - - $this->removeAllEffects(); - $this->sendData($this); - - $this->sendSettings(); - $this->inventory->sendContents($this); - $this->inventory->sendArmorContents($this); - - $this->blocked = false; - - $this->spawnToAll(); - $this->scheduleUpdate(); - break; case ProtocolInfo::SET_HEALTH_PACKET: //Not used break; case ProtocolInfo::ENTITY_EVENT_PACKET: @@ -2612,6 +2581,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ if($this->server->isHardcore()){ $this->setBanned(true); + }else{ + $pk = new RespawnPacket(); + $pos = $this->getSpawn(); + $pk->x = $pos->x; + $pk->y = $pos->y; + $pk->z = $pos->z; + $this->dataPacket($pk); } } @@ -2674,7 +2650,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{ $pk->bodyYaw = $this->yaw; $pk->pitch = $this->pitch; $pk->yaw = $this->yaw; - $pk->teleport = true; + $pk->mode = 1; $this->directDataPacket($pk); } } diff --git a/src/pocketmine/entity/Arrow.php b/src/pocketmine/entity/Arrow.php index 267312144..2d47684ae 100644 --- a/src/pocketmine/entity/Arrow.php +++ b/src/pocketmine/entity/Arrow.php @@ -42,9 +42,8 @@ class Arrow extends Projectile{ protected $isCritical; public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null, $critical = false){ - $this->shootingEntity = $shootingEntity; $this->isCritical = (bool) $critical; - parent::__construct($chunk, $nbt); + parent::__construct($chunk, $nbt, $shootingEntity); } public function onUpdate($currentTick){ @@ -82,10 +81,10 @@ class Arrow extends Projectile{ $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; - $pk->did = $this->shootingEntity !== null ? $this->shootingEntity->getId() : 1; $pk->speedX = $this->motionX; $pk->speedY = $this->motionY; $pk->speedZ = $this->motionZ; + $pk->metadata = $this->dataProperties; $player->dataPacket($pk); parent::spawnTo($player); diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index fc55a8ea2..741f88760 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -794,8 +794,10 @@ abstract class Entity extends Location implements Metadatable{ $this->lastYaw = $this->yaw; $this->lastPitch = $this->pitch; - foreach($this->hasSpawned as $player){ - $player->addEntityMovement($this->id, $this->x, $this->y + $this->getEyeHeight(), $this->z, $this->yaw, $this->pitch, $this->yaw); + if(!($this instanceof Player)){ + foreach($this->hasSpawned as $player){ + $player->addEntityMovement($this->id, $this->x, $this->y + $this->getEyeHeight(), $this->z, $this->yaw, $this->pitch, $this->yaw); + } } } @@ -1494,6 +1496,9 @@ abstract class Entity extends Location implements Metadatable{ $targets = $this->hasSpawned; if($this instanceof Player){ + if(!$this->spawned){ + return; + } $targets[] = $this; } diff --git a/src/pocketmine/entity/FallingSand.php b/src/pocketmine/entity/FallingSand.php index 74887267e..ceee1a873 100644 --- a/src/pocketmine/entity/FallingSand.php +++ b/src/pocketmine/entity/FallingSand.php @@ -38,6 +38,8 @@ use pocketmine\Player; class FallingSand extends Entity{ const NETWORK_ID = 66; + const DATA_BLOCK_INFO = 20; + public $width = 0.98; public $length = 0.98; public $height = 0.98; @@ -64,7 +66,10 @@ class FallingSand extends Entity{ if($this->blockId === 0){ $this->close(); + return; } + + $this->setDataProperty(self::DATA_BLOCK_INFO, self::DATA_TYPE_INT, ($this->getBlock() << 8) | $this->getDamage()); } public function canCollideWith(Entity $entity){ @@ -151,11 +156,12 @@ class FallingSand extends Entity{ $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; - $pk->did = -($this->getBlock() | $this->getDamage() << 0x10); + $pk->speedX = $this->motionX; + $pk->speedY = $this->motionY; + $pk->speedZ = $this->motionZ; + $pk->metadata = $this->dataProperties; $player->dataPacket($pk); - $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); - parent::spawnTo($player); } } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index b5eab057a..37966da1d 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -24,7 +24,6 @@ namespace pocketmine\entity; use pocketmine\inventory\InventoryHolder; use pocketmine\inventory\PlayerInventory; use pocketmine\item\Item as ItemItem; -use pocketmine\math\Vector3; use pocketmine\nbt\NBT; use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\Compound; @@ -53,6 +52,32 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ public $height = 1.8; public $eyeHeight = 1.62; + protected $skin; + protected $isSlim = false; + + /** + * @param string $str + * @param bool $isSlim + */ + public function setSkin($str, $isSlim = false){ + $this->skin = $str; + $this->isSlim = (bool) $isSlim; + } + + /** + * @return string + */ + public function getNameTag(){ + return $this->nameTag; + } + + /** + * @param string $name + */ + public function setNameTag($name){ + $this->nameTag = $name; + } + public function getInventory(){ return $this->inventory; } @@ -163,11 +188,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $pk = new AddPlayerPacket(); $pk->clientID = 0; - if($player->getRemoveFormat()){ - $pk->username = TextFormat::clean($this->nameTag); - }else{ - $pk->username = $this->nameTag; - } + $pk->username = $this->nameTag; $pk->eid = $this->getId(); $pk->x = $this->x; $pk->y = $this->y; @@ -177,6 +198,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $item = $this->getInventory()->getItemInHand(); $pk->item = $item->getId(); $pk->meta = $item->getDamage(); + $pk->skin = $this->skin; + $pk->slim = $this->isSlim; $pk->metadata = $this->dataProperties; $player->dataPacket($pk); diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index c23774303..dd9da5123 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -134,11 +134,12 @@ class PrimedTNT extends Entity implements Explosive{ $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; - $pk->did = 0; + $pk->speedX = $this->motionX; + $pk->speedY = $this->motionY; + $pk->speedZ = $this->motionZ; + $pk->metadata = $this->dataProperties; $player->dataPacket($pk); - $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); - parent::spawnTo($player); } } \ No newline at end of file diff --git a/src/pocketmine/entity/Projectile.php b/src/pocketmine/entity/Projectile.php index 583ca67ab..176d578f3 100644 --- a/src/pocketmine/entity/Projectile.php +++ b/src/pocketmine/entity/Projectile.php @@ -28,17 +28,30 @@ use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\EntityRegainHealthEvent; use pocketmine\event\entity\ProjectileHitEvent; +use pocketmine\level\format\FullChunk; use pocketmine\level\MovingObjectPosition; use pocketmine\math\Vector3; +use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\Short; abstract class Projectile extends Entity{ + + const DATA_SHOOTER_ID = 17; + /** @var Entity */ public $shootingEntity = null; protected $damage = 0; public $hadCollision = false; + public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null){ + $this->shootingEntity = $shootingEntity; + if($shootingEntity !== null){ + $this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId()); + } + parent::__construct($chunk, $nbt); + } + public function attack($damage, EntityDamageEvent $source){ diff --git a/src/pocketmine/entity/Snowball.php b/src/pocketmine/entity/Snowball.php index ba59a141a..dc79b0ea4 100644 --- a/src/pocketmine/entity/Snowball.php +++ b/src/pocketmine/entity/Snowball.php @@ -38,8 +38,7 @@ class Snowball extends Projectile{ protected $drag = 0.01; public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null){ - $this->shootingEntity = $shootingEntity; - parent::__construct($chunk, $nbt); + parent::__construct($chunk, $nbt, $shootingEntity); } public function onUpdate($currentTick){ @@ -68,11 +67,12 @@ class Snowball extends Projectile{ $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; - $pk->did = 0; //TODO: send motion here + $pk->speedX = $this->motionX; + $pk->speedY = $this->motionY; + $pk->speedZ = $this->motionZ; + $pk->metadata = $this->dataProperties; $player->dataPacket($pk); - $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); - parent::spawnTo($player); } } \ No newline at end of file diff --git a/src/pocketmine/entity/Villager.php b/src/pocketmine/entity/Villager.php index 194d9f9b9..356174e7b 100644 --- a/src/pocketmine/entity/Villager.php +++ b/src/pocketmine/entity/Villager.php @@ -23,7 +23,7 @@ namespace pocketmine\entity; use pocketmine\nbt\tag\Int; -use pocketmine\network\protocol\AddMobPacket; +use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; class Villager extends Creature implements NPC, Ageable{ @@ -52,19 +52,20 @@ class Villager extends Creature implements NPC, Ageable{ } public function spawnTo(Player $player){ - $pk = new AddMobPacket(); + $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = Villager::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; + $pk->speedX = $this->motionX; + $pk->speedY = $this->motionY; + $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk); - $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); - parent::spawnTo($player); } diff --git a/src/pocketmine/entity/Zombie.php b/src/pocketmine/entity/Zombie.php index 740f6d5c8..a84d759d5 100644 --- a/src/pocketmine/entity/Zombie.php +++ b/src/pocketmine/entity/Zombie.php @@ -24,7 +24,7 @@ namespace pocketmine\entity; use pocketmine\event\entity\EntityDamageByEntityEvent; use pocketmine\item\Item as ItemItem; -use pocketmine\network\protocol\AddMobPacket; +use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; class Zombie extends Monster{ @@ -39,20 +39,20 @@ class Zombie extends Monster{ } public function spawnTo(Player $player){ - - $pk = new AddMobPacket(); + $pk = new AddEntityPacket(); $pk->eid = $this->getId(); $pk->type = Zombie::NETWORK_ID; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; + $pk->speedX = $this->motionX; + $pk->speedY = $this->motionY; + $pk->speedZ = $this->motionZ; $pk->yaw = $this->yaw; $pk->pitch = $this->pitch; $pk->metadata = $this->dataProperties; $player->dataPacket($pk); - $player->addEntityMotion($this->getId(), $this->motionX, $this->motionY, $this->motionZ); - parent::spawnTo($player); } diff --git a/src/pocketmine/level/particle/FloatingTextParticle.php b/src/pocketmine/level/particle/FloatingTextParticle.php index 98cfb7147..75d3dd108 100644 --- a/src/pocketmine/level/particle/FloatingTextParticle.php +++ b/src/pocketmine/level/particle/FloatingTextParticle.php @@ -22,15 +22,9 @@ namespace pocketmine\level\particle; use pocketmine\entity\Entity; -use pocketmine\entity\Wolf; use pocketmine\math\Vector3; -use pocketmine\network\protocol\AddEntityPacket; -use pocketmine\network\protocol\AddMobPacket; use pocketmine\network\protocol\AddPlayerPacket; -use pocketmine\network\protocol\EntityEventPacket; -use pocketmine\network\protocol\RemoveEntityPacket; use pocketmine\network\protocol\RemovePlayerPacket; -use pocketmine\network\protocol\SetEntityDataPacket; class FloatingTextParticle extends Particle{ //TODO: HACK! @@ -98,6 +92,6 @@ class FloatingTextParticle extends Particle{ $p[] = $pk; } - return $pk; + return $p; } } diff --git a/src/pocketmine/level/particle/InkCloudParticle.php b/src/pocketmine/level/particle/InkCloudParticle.php deleted file mode 100644 index 0f07e0602..000000000 --- a/src/pocketmine/level/particle/InkCloudParticle.php +++ /dev/null @@ -1,73 +0,0 @@ -count = (int) $count; - } - - public function encode(){ - $p = []; - - $entityId = bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things - $pk = new AddMobPacket(); - $pk->eid = $entityId; - $pk->type = 17; - $pk->x = $this->x; - $pk->y = $this->y - 1; - $pk->z = $this->z; - $pk->pitch = 0; - $pk->yaw = 0; - $pk->metadata = [ - Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE], - Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300] - ]; - $p[] = $pk; - - for($i = 0; $i < $this->count; ++$i){ - $pk2 = new EntityEventPacket(); - $pk2->eid = $entityId; - $pk2->event = 15; - $p[] = $pk2; - } - - - $pk3 = new RemoveEntityPacket(); - $pk3->eid = $entityId; - $p[] = $pk3; - - return $p; - } -} diff --git a/src/pocketmine/level/particle/MateFailParticle.php b/src/pocketmine/level/particle/MateFailParticle.php deleted file mode 100644 index 4c1aa1dd3..000000000 --- a/src/pocketmine/level/particle/MateFailParticle.php +++ /dev/null @@ -1,73 +0,0 @@ -x, $pos->y, $pos->z); - $this->count = (int) $count; - } - - public function encode(){ - $p = []; - - $entityId = bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things - $pk = new AddMobPacket(); - $pk->eid = $entityId; - $pk->type = Wolf::NETWORK_ID; - $pk->x = $this->x; - $pk->y = $this->y - 1; - $pk->z = $this->z; - $pk->pitch = 0; - $pk->yaw = 0; - $pk->metadata = [ - Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE], - Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300] - ]; - $p[] = $pk; - - for($i = 0; $i < $this->count; ++$i){ - $pk2 = new EntityEventPacket(); - $pk2->eid = $entityId; - $pk2->event = 6; - $p[] = $pk2; - } - - - $pk3 = new RemoveEntityPacket(); - $pk3->eid = $entityId; - $p[] = $pk3; - - return $p; - } -} diff --git a/src/pocketmine/level/particle/MateParticle.php b/src/pocketmine/level/particle/MateParticle.php deleted file mode 100644 index 147b9bfec..000000000 --- a/src/pocketmine/level/particle/MateParticle.php +++ /dev/null @@ -1,73 +0,0 @@ -x, $pos->y, $pos->z); - $this->count = (int) $count; - } - - public function encode(){ - $p = []; - - $entityId = bcadd("1095216660480", mt_rand(0, 0x7fffffff)); //No conflict with other things - $pk = new AddMobPacket(); - $pk->eid = $entityId; - $pk->type = Wolf::NETWORK_ID; - $pk->x = $this->x; - $pk->y = $this->y - 1; - $pk->z = $this->z; - $pk->pitch = 0; - $pk->yaw = 0; - $pk->metadata = [ - Entity::DATA_FLAGS => [Entity::DATA_TYPE_BYTE, 1 << Entity::DATA_FLAG_INVISIBLE], - Entity::DATA_AIR => [Entity::DATA_TYPE_SHORT, 300] - ]; - $p[] = $pk; - - for($i = 0; $i < $this->count; ++$i){ - $pk2 = new EntityEventPacket(); - $pk2->eid = $entityId; - $pk2->event = 7; - $p[] = $pk2; - } - - - $pk3 = new RemoveEntityPacket(); - $pk3->eid = $entityId; - $p[] = $pk3; - - return $p; - } -} diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index f04a0b46d..0ea8758b6 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -26,7 +26,6 @@ namespace pocketmine\network; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddItemEntityPacket; -use pocketmine\network\protocol\AddMobPacket; use pocketmine\network\protocol\AddPaintingPacket; use pocketmine\network\protocol\AddPlayerPacket; use pocketmine\network\protocol\AdventureSettingsPacket; @@ -39,6 +38,8 @@ use pocketmine\network\protocol\ContainerSetDataPacket; use pocketmine\network\protocol\ContainerSetSlotPacket; use pocketmine\network\protocol\DataPacket; use pocketmine\network\protocol\DropItemPacket; +use pocketmine\network\protocol\Info; +use pocketmine\network\protocol\SetEntityLinkPacket; use pocketmine\network\protocol\TileEntityDataPacket; use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\ExplodePacket; @@ -72,6 +73,7 @@ use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\protocol\UseItemPacket; use pocketmine\Player; use pocketmine\Server; +use pocketmine\utils\MainLogger; class Network{ @@ -129,7 +131,20 @@ class Network{ public function processInterfaces(){ foreach($this->interfaces as $interface){ - $interface->process(); + try { + $interface->process(); + }catch(\Exception $e){ + $logger = $this->server->getLogger(); + if(\pocketmine\DEBUG > 1){ + if($logger instanceof MainLogger){ + $logger->logException($e); + } + } + + $interface->emergencyShutdown(); + $this->unregisterInterface($interface); + $logger->critical("[Network] Stopped interface ". get_class($interface) ." due to ". $e->getMessage()); + } } } @@ -186,10 +201,17 @@ class Network{ $len = strlen($str); $offset = 0; while($offset < $len){ - if(($packetId = $this->getPacket(ord($str{$offset++}))) !== null){ - $packetId->buffer = $str; - $packet->decode(); - $p->handleDataPacket($packet); + if(($pk = $this->getPacket(ord($str{$offset++}))) !== null){ + if($pk->pid() === Info::BATCH_PACKET){ + return; + } + $pk->setBuffer(substr($str, $offset)); + $pk->decode(); + $p->handleDataPacket($pk); + $offset += $pk->getOffset(); + if($pk->getOffset() <= 0){ + return; + } } } } @@ -241,7 +263,6 @@ class Network{ $this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class); $this->registerPacket(ProtocolInfo::SET_TIME_PACKET, SetTimePacket::class); $this->registerPacket(ProtocolInfo::START_GAME_PACKET, StartGamePacket::class); - $this->registerPacket(ProtocolInfo::ADD_MOB_PACKET, AddMobPacket::class); $this->registerPacket(ProtocolInfo::ADD_PLAYER_PACKET, AddPlayerPacket::class); $this->registerPacket(ProtocolInfo::REMOVE_PLAYER_PACKET, RemovePlayerPacket::class); $this->registerPacket(ProtocolInfo::ADD_ENTITY_PACKET, AddEntityPacket::class); @@ -265,6 +286,7 @@ class Network{ $this->registerPacket(ProtocolInfo::HURT_ARMOR_PACKET, HurtArmorPacket::class); $this->registerPacket(ProtocolInfo::SET_ENTITY_DATA_PACKET, SetEntityDataPacket::class); $this->registerPacket(ProtocolInfo::SET_ENTITY_MOTION_PACKET, SetEntityMotionPacket::class); + $this->registerPacket(ProtocolInfo::SET_ENTITY_LINK_PACKET, SetEntityLinkPacket::class); $this->registerPacket(ProtocolInfo::SET_HEALTH_PACKET, SetHealthPacket::class); $this->registerPacket(ProtocolInfo::SET_SPAWN_POSITION_PACKET, SetSpawnPositionPacket::class); $this->registerPacket(ProtocolInfo::ANIMATE_PACKET, AnimatePacket::class); diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index c5e402a8c..578f8abd7 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -22,53 +22,9 @@ namespace pocketmine\network; use pocketmine\event\player\PlayerCreationEvent; -use pocketmine\network\protocol\AddEntityPacket; -use pocketmine\network\protocol\AddItemEntityPacket; -use pocketmine\network\protocol\AddMobPacket; -use pocketmine\network\protocol\AddPaintingPacket; -use pocketmine\network\protocol\AddPlayerPacket; -use pocketmine\network\protocol\AdventureSettingsPacket; -use pocketmine\network\protocol\AnimatePacket; -use pocketmine\network\protocol\BatchPacket; -use pocketmine\network\protocol\ContainerClosePacket; -use pocketmine\network\protocol\ContainerOpenPacket; -use pocketmine\network\protocol\ContainerSetContentPacket; -use pocketmine\network\protocol\ContainerSetDataPacket; -use pocketmine\network\protocol\ContainerSetSlotPacket; use pocketmine\network\protocol\DataPacket; -use pocketmine\network\protocol\DropItemPacket; -use pocketmine\network\protocol\TileEntityDataPacket; -use pocketmine\network\protocol\EntityEventPacket; -use pocketmine\network\protocol\ExplodePacket; -use pocketmine\network\protocol\HurtArmorPacket; use pocketmine\network\protocol\Info as ProtocolInfo; -use pocketmine\network\protocol\InteractPacket; -use pocketmine\network\protocol\LevelEventPacket; -use pocketmine\network\protocol\DisconnectPacket; -use pocketmine\network\protocol\LoginPacket; -use pocketmine\network\protocol\PlayStatusPacket; -use pocketmine\network\protocol\TextPacket; -use pocketmine\network\protocol\MoveEntityPacket; -use pocketmine\network\protocol\MovePlayerPacket; -use pocketmine\network\protocol\PlayerActionPacket; -use pocketmine\network\protocol\PlayerArmorEquipmentPacket; -use pocketmine\network\protocol\PlayerEquipmentPacket; -use pocketmine\network\protocol\RemoveBlockPacket; -use pocketmine\network\protocol\RemoveEntityPacket; -use pocketmine\network\protocol\RemovePlayerPacket; -use pocketmine\network\protocol\RespawnPacket; -use pocketmine\network\protocol\SetDifficultyPacket; -use pocketmine\network\protocol\SetEntityDataPacket; -use pocketmine\network\protocol\SetEntityMotionPacket; -use pocketmine\network\protocol\SetHealthPacket; -use pocketmine\network\protocol\SetSpawnPositionPacket; -use pocketmine\network\protocol\SetTimePacket; -use pocketmine\network\protocol\StartGamePacket; -use pocketmine\network\protocol\TakeItemEntityPacket; -use pocketmine\network\protocol\TileEventPacket; use pocketmine\network\protocol\UnknownPacket; -use pocketmine\network\protocol\UpdateBlockPacket; -use pocketmine\network\protocol\UseItemPacket; use pocketmine\Player; use pocketmine\Server; use pocketmine\utils\MainLogger; @@ -269,7 +225,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ and Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){ $this->batchedPackets[$this->identifiers[$player]] .= $packet->buffer; - return; + return null; } if($pk === null){ diff --git a/src/pocketmine/network/protocol/AddEntityPacket.php b/src/pocketmine/network/protocol/AddEntityPacket.php index a4694eb2c..851f92e7a 100644 --- a/src/pocketmine/network/protocol/AddEntityPacket.php +++ b/src/pocketmine/network/protocol/AddEntityPacket.php @@ -24,6 +24,8 @@ namespace pocketmine\network\protocol; #include +use pocketmine\utils\Binary; + class AddEntityPacket extends DataPacket{ public static $pool = []; public static $next = 0; @@ -33,10 +35,13 @@ class AddEntityPacket extends DataPacket{ public $x; public $y; public $z; - public $did; public $speedX; public $speedY; public $speedZ; + public $yaw; + public $pitch; + public $metadata; + public $links = []; public function pid(){ return Info::ADD_ENTITY_PACKET; @@ -53,11 +58,17 @@ class AddEntityPacket extends DataPacket{ $this->putFloat($this->x); $this->putFloat($this->y); $this->putFloat($this->z); - $this->putLong($this->did); - if($this->did > 0){ - $this->putFloat($this->speedX); - $this->putFloat($this->speedY); - $this->putFloat($this->speedZ); + $this->putFloat($this->speedX); + $this->putFloat($this->speedY); + $this->putFloat($this->speedZ); + $this->putFloat($this->yaw); + $this->putFloat($this->pitch); + $this->put(Binary::writeMetadata($this->metadata)); + $this->putShort(count($this->links)); + foreach($this->links as $link){ + $this->putLong($link[0]); + $this->putLong($link[1]); + $this->putByte($link[2]); } } diff --git a/src/pocketmine/network/protocol/AddPlayerPacket.php b/src/pocketmine/network/protocol/AddPlayerPacket.php index 49dc53eb3..8d5414d0d 100644 --- a/src/pocketmine/network/protocol/AddPlayerPacket.php +++ b/src/pocketmine/network/protocol/AddPlayerPacket.php @@ -32,6 +32,8 @@ class AddPlayerPacket extends DataPacket{ public static $pool = []; public static $next = 0; + + public $clientID; public $username; public $eid; @@ -44,6 +46,9 @@ class AddPlayerPacket extends DataPacket{ public $meta; public $metadata; + public $slim = false; + public $skin = null; + public function pid(){ return Info::ADD_PLAYER_PACKET; } @@ -61,9 +66,12 @@ class AddPlayerPacket extends DataPacket{ $this->putFloat($this->y); $this->putFloat($this->z); $this->putFloat($this->yaw); + $this->putFloat($this->yaw); //TODO headrot $this->putFloat($this->pitch); $this->putShort($this->item); $this->putShort($this->meta); + $this->putByte($this->slim ? 1 : 0); + $this->putString($this->skin); $this->put(Binary::writeMetadata($this->metadata)); } diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index d581530f2..85fb9f3e1 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -52,6 +52,10 @@ abstract class DataPacket extends \stdClass{ $this->offset = 0; } + public function getOffset(){ + return $this->offset; + } + public function getBuffer(){ return $this->buffer; } diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index db45b7c56..ade08ef35 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -31,66 +31,65 @@ interface Info{ * Actual Minecraft: PE protocol version */ const CURRENT_PROTOCOL = 21; - + const LOGIN_PACKET = 0x82; const PLAY_STATUS_PACKET = 0x83; - + const DISCONNECT_PACKET = 0x84; - + const TEXT_PACKET = 0x85; const SET_TIME_PACKET = 0x86; - + const START_GAME_PACKET = 0x87; - - const ADD_MOB_PACKET = 0x88; - const ADD_PLAYER_PACKET = 0x89; - const REMOVE_PLAYER_PACKET = 0x8a; - - const ADD_ENTITY_PACKET = 0x8b; - const REMOVE_ENTITY_PACKET = 0x8c; - const ADD_ITEM_ENTITY_PACKET = 0x8d; - const TAKE_ITEM_ENTITY_PACKET = 0x8e; - - const MOVE_ENTITY_PACKET = 0x8f; - const MOVE_PLAYER_PACKET = 0x90; - - const REMOVE_BLOCK_PACKET = 0x91; - const UPDATE_BLOCK_PACKET = 0x92; - - const ADD_PAINTING_PACKET = 0x93; - - const EXPLODE_PACKET = 0x94; - - const LEVEL_EVENT_PACKET = 0x95; - const TILE_EVENT_PACKET = 0x96; - const ENTITY_EVENT_PACKET = 0x97; - const MOB_EFFECT_PACKET = 0x98; - - const PLAYER_EQUIPMENT_PACKET = 0x99; - const PLAYER_ARMOR_EQUIPMENT_PACKET = 0x9a; - const INTERACT_PACKET = 0x9b; - const USE_ITEM_PACKET = 0x9c; - const PLAYER_ACTION_PACKET = 0x9d; - const HURT_ARMOR_PACKET = 0x9e; - const SET_ENTITY_DATA_PACKET = 0x9f; - const SET_ENTITY_MOTION_PACKET = 0xa0; - //const SET_ENTITY_LINK_PACKET = 0xa1; - const SET_HEALTH_PACKET = 0xa2; - const SET_SPAWN_POSITION_PACKET = 0xa3; - const ANIMATE_PACKET = 0xa4; - const RESPAWN_PACKET = 0xa5; - const DROP_ITEM_PACKET = 0xa6; - const CONTAINER_OPEN_PACKET = 0xa7; - const CONTAINER_CLOSE_PACKET = 0xa8; - const CONTAINER_SET_SLOT_PACKET = 0xa9; - const CONTAINER_SET_DATA_PACKET = 0xaa; - const CONTAINER_SET_CONTENT_PACKET = 0xab; - //const CONTAINER_ACK_PACKET = 0xac; - const ADVENTURE_SETTINGS_PACKET = 0xad; - const TILE_ENTITY_DATA_PACKET = 0xae; - //const PLAYER_INPUT_PACKET = 0xaf; - const FULL_CHUNK_DATA_PACKET = 0xb0; - const SET_DIFFICULTY_PACKET = 0xb1; - const BATCH_PACKET = 0xb2; + + const ADD_PLAYER_PACKET = 0x88; + const REMOVE_PLAYER_PACKET = 0x89; + + const ADD_ENTITY_PACKET = 0x8a; + const REMOVE_ENTITY_PACKET = 0x8b; + const ADD_ITEM_ENTITY_PACKET = 0x8c; + const TAKE_ITEM_ENTITY_PACKET = 0x8d; + + const MOVE_ENTITY_PACKET = 0x8e; + const MOVE_PLAYER_PACKET = 0x8f; + + const REMOVE_BLOCK_PACKET = 0x90; + const UPDATE_BLOCK_PACKET = 0x91; + + const ADD_PAINTING_PACKET = 0x92; + + const EXPLODE_PACKET = 0x93; + + const LEVEL_EVENT_PACKET = 0x94; + const TILE_EVENT_PACKET = 0x95; + const ENTITY_EVENT_PACKET = 0x96; + const MOB_EFFECT_PACKET = 0x97; + + const PLAYER_EQUIPMENT_PACKET = 0x98; + const PLAYER_ARMOR_EQUIPMENT_PACKET = 0x99; + const INTERACT_PACKET = 0x9a; + const USE_ITEM_PACKET = 0x9b; + const PLAYER_ACTION_PACKET = 0x9c; + const HURT_ARMOR_PACKET = 0x9d; + const SET_ENTITY_DATA_PACKET = 0x9e; + const SET_ENTITY_MOTION_PACKET = 0x9f; + const SET_ENTITY_LINK_PACKET = 0xa0; + const SET_HEALTH_PACKET = 0xa1; + const SET_SPAWN_POSITION_PACKET = 0xa2; + const ANIMATE_PACKET = 0xa3; + const RESPAWN_PACKET = 0xa4; + const DROP_ITEM_PACKET = 0xa5; + const CONTAINER_OPEN_PACKET = 0xa6; + const CONTAINER_CLOSE_PACKET = 0xa7; + const CONTAINER_SET_SLOT_PACKET = 0xa8; + const CONTAINER_SET_DATA_PACKET = 0xa9; + const CONTAINER_SET_CONTENT_PACKET = 0xaa; + //const CONTAINER_ACK_PACKET = 0xab; + const ADVENTURE_SETTINGS_PACKET = 0xac; + const TILE_ENTITY_DATA_PACKET = 0xad; + //const PLAYER_INPUT_PACKET = 0xae; + const FULL_CHUNK_DATA_PACKET = 0xaf; + const SET_DIFFICULTY_PACKET = 0xb0; + const BATCH_PACKET = 0xb1; } diff --git a/src/pocketmine/network/protocol/InteractPacket.php b/src/pocketmine/network/protocol/InteractPacket.php index 9ee88cf7c..91dc3880c 100644 --- a/src/pocketmine/network/protocol/InteractPacket.php +++ b/src/pocketmine/network/protocol/InteractPacket.php @@ -38,14 +38,12 @@ class InteractPacket extends DataPacket{ public function decode(){ $this->action = $this->getByte(); - $this->eid = $this->getLong(); $this->target = $this->getLong(); } public function encode(){ $this->reset(); $this->putByte($this->action); - $this->putLong($this->eid); $this->putLong($this->target); } diff --git a/src/pocketmine/network/protocol/LoginPacket.php b/src/pocketmine/network/protocol/LoginPacket.php index 43eeef9d4..e07bc18cb 100644 --- a/src/pocketmine/network/protocol/LoginPacket.php +++ b/src/pocketmine/network/protocol/LoginPacket.php @@ -32,7 +32,9 @@ class LoginPacket extends DataPacket{ public $protocol1; public $protocol2; public $clientId; - public $loginData; + + public $slim = false; + public $skin = null; public function pid(){ return Info::LOGIN_PACKET; @@ -42,8 +44,12 @@ class LoginPacket extends DataPacket{ $this->username = $this->getString(); $this->protocol1 = $this->getInt(); $this->protocol2 = $this->getInt(); + if(Info::CURRENT_PROTOCOL != $this->protocol1){ + return; + } $this->clientId = $this->getInt(); - $this->loginData = $this->getString(); + $this->slim = $this->getByte() > 0; + $this->skin = $this->getString(); } public function encode(){ diff --git a/src/pocketmine/network/protocol/MovePlayerPacket.php b/src/pocketmine/network/protocol/MovePlayerPacket.php index c5c096371..67619de86 100644 --- a/src/pocketmine/network/protocol/MovePlayerPacket.php +++ b/src/pocketmine/network/protocol/MovePlayerPacket.php @@ -35,7 +35,7 @@ class MovePlayerPacket extends DataPacket{ public $yaw; public $pitch; public $bodyYaw; - public $teleport = false; + public $mode = 0; public function pid(){ return Info::MOVE_PLAYER_PACKET; @@ -52,10 +52,9 @@ class MovePlayerPacket extends DataPacket{ $this->y = $this->getFloat(); $this->z = $this->getFloat(); $this->yaw = $this->getFloat(); - $this->pitch = $this->getFloat(); $this->bodyYaw = $this->getFloat(); - $flags = $this->getByte(); - $this->teleport = (($flags & 0x80) > 0); + $this->pitch = $this->getFloat(); + $this->mode = $this->getByte(); } public function encode(){ @@ -65,9 +64,9 @@ class MovePlayerPacket extends DataPacket{ $this->putFloat($this->y); $this->putFloat($this->z); $this->putFloat($this->yaw); + $this->putFloat($this->bodyYaw); //TODO $this->putFloat($this->pitch); - $this->putFloat($this->bodyYaw); - $this->putByte($this->teleport == true ? 0x80 : 0x00); + $this->putByte($this->mode); } } diff --git a/src/pocketmine/network/protocol/RespawnPacket.php b/src/pocketmine/network/protocol/RespawnPacket.php index 6991b2fa0..903c7e02f 100644 --- a/src/pocketmine/network/protocol/RespawnPacket.php +++ b/src/pocketmine/network/protocol/RespawnPacket.php @@ -28,7 +28,6 @@ class RespawnPacket extends DataPacket{ public static $pool = []; public static $next = 0; - public $eid; public $x; public $y; public $z; @@ -38,7 +37,6 @@ class RespawnPacket extends DataPacket{ } public function decode(){ - $this->eid = $this->getLong(); $this->x = $this->getFloat(); $this->y = $this->getFloat(); $this->z = $this->getFloat(); @@ -46,7 +44,6 @@ class RespawnPacket extends DataPacket{ public function encode(){ $this->reset(); - $this->putLong($this->eid); $this->putFloat($this->x); $this->putFloat($this->y); $this->putFloat($this->z); diff --git a/src/pocketmine/network/protocol/AddMobPacket.php b/src/pocketmine/network/protocol/SetEntityLinkPacket.php similarity index 66% rename from src/pocketmine/network/protocol/AddMobPacket.php rename to src/pocketmine/network/protocol/SetEntityLinkPacket.php index f8d18a759..ad73f1486 100644 --- a/src/pocketmine/network/protocol/AddMobPacket.php +++ b/src/pocketmine/network/protocol/SetEntityLinkPacket.php @@ -23,26 +23,17 @@ namespace pocketmine\network\protocol; #include -#ifndef COMPILE -use pocketmine\utils\Binary; -#endif - -class AddMobPacket extends DataPacket{ +class SetEntityLinkPacket extends DataPacket{ public static $pool = []; public static $next = 0; - public $eid; + public $from; + public $to; public $type; - public $x; - public $y; - public $z; - public $pitch; - public $yaw; - public $metadata; public function pid(){ - return Info::ADD_MOB_PACKET; + return Info::SET_ENTITY_LINK_PACKET; } public function decode(){ @@ -51,14 +42,9 @@ class AddMobPacket extends DataPacket{ public function encode(){ $this->reset(); - $this->putLong($this->eid); - $this->putInt($this->type); - $this->putFloat($this->x); - $this->putFloat($this->y); - $this->putFloat($this->z); - $this->putFloat($this->yaw); - $this->putFloat($this->pitch); - $this->put(Binary::writeMetadata($this->metadata)); + $this->putLong($this->from); + $this->putLong($this->to); + $this->putByte($this->type); } } diff --git a/src/raklib b/src/raklib index 639108fb3..4d511fa64 160000 --- a/src/raklib +++ b/src/raklib @@ -1 +1 @@ -Subproject commit 639108fb3aeb48a113df3b31516af6ac4f5ba402 +Subproject commit 4d511fa646b19ae6470971828ec1384e902e5415