Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

AddPlayerPacket and UUID

Comments in 'Plugin Development' started by CrazedMiner, Oct 30, 2015.

  1. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    I'm trying to add a player packet to a client when they join but in order to do so you need to add a UUID instance to the Packet. I've tried a ton of different things and I can't get them to work.

    If somebody can tell me how to get the UUID class to generate a UUID or some alternative way that still uses packets that'd be great.

    Code:
    PHP:
    //The required Classes
    use pocketmine\network\protocol\AddPlayerPacket;
    use 
    pocketmine\utils\UUID;
    //Skip to the functions
    public function __construct(Player $player$kitId$eid$name$descriptionVector3 $pos$skin$slim false) {
            
    $this->player $player;
            
    $this->kitId $kitId;
            
    $this->eid $eid;
            
    $this->uuid UUID::fromData($eid$skin$name);
            
    $this->username $name;
            
    $this->description $description;
            
    $this->pos $pos;
            
    $this->skin $skin;
            
    $this->slim $slim;
          
            
    $this->sendPacket();
        }
      
        public function 
    sendPacket() {
            
    $pk = new AddPlayerPacket();
            
    $pk->eid $this->eid;
            
    $pk->clientID $this->uuid;
            
    $pk->username $this->createUsername();
            
    $pk->$this->pos->x;
            
    $pk->$this->pos->y;
            
    $pk->$this->pos->z;
            
    $pk->pitch 0;
            
    $pk->yaw 270;
            
    $pk->skin $this->skin;
            
    $pk->isSlim $this->slim;
            
    $this->player->dataPacket($pk);
        }
    Error:
    Code:
    "Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'TTNPC v1-ALPHA': Argument 1 passed to pocketmine\utils\BinaryStream::putUUID() must be an instance of pocketmine\utils\UUID, null given, called in C:\Users\Admin\Desktop\PocketMine\Plugin Tests\src\pocketmine\network\protocol\AddPlayerPacket.php on line 54 and defined on ttnpc\EventListener
    InvalidArgumentException: "Argument 1 passed to pocketmine\utils\BinaryStream::putUUID() must be an instance of pocketmine\utils\UUID, null given, called in C:\Users\Admin\Desktop\PocketMine\Plugin Tests\src\pocketmine\network\protocol\AddPlayerPacket.php on line 54 and defined" (E_RECOVERABLE_ERROR) in "/src/pocketmine/utils/BinaryStream" at line 194
    
  2. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You have to set the UUID field for the packet with an instance of UUID.
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    So
    PHP:
    $pk->uuid $this->uuid;
    ?
    PEMapModder likes this.
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Have you looked at Specter by @Falk?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Specter spawns a player like he connected from a real client. Specter does not handle anything about spawning players, etc. Specter is basically a plugin that creates a new connection to the server without MCPE.
    CrazedMiner likes this.

Share This Page

Advertisement