1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Undefined property on RemoveEntityPacket

Discussion in 'Development' started by armagadon159753, Dec 5, 2017.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Error:
    PHP:
     [19:59:22] [Server thread/CRITICAL]: ErrorException"Undefined property: pocketmine\network\mcpe\protocol\AddEntityPacket::$getEntityUniqueId(EXCEPTIONin "MysteryCrate_v3/src/MysteryCrates/DespawnText" at line 23                                

    [19:59:22] [Server thread/DEBUG]: #0 MysteryCrate_v3/src/MysteryCrates/DespawnText(23): pocketmine\error_handler(integer 8, string Undefined property: pocketmine\network\mcpe\protocol\AddEntityPacket::$getEntityUniqueId, string /home/arma/plugins/MysteryCrate_v3/src/MysteryCrates/DespawnText.php, integer 23, array Array())



    public function onRun($currentTick) {
            
    $players $this->plugin->getServer()->getOnlinePlayers();
            
    $pk = new RemoveEntityPacket();
            
    $pk->entityUniqueId $this->pk->getEntityUniqueId;
            foreach (
    $players as $pl) {
                
    $pl->directDataPacket($pk);
            }
            
    $this->plugin->getServer()->getScheduler()->cancelTask($this->getTaskId());
        }
     
  2. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    we can't see the $this->pk variable :)
     
  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Oups sorry
    PHP:
    public function __construct(Main $pluginPlayer $playerAddEntityPacket $pk){
            
    parent::__construct($plugin);
            
    $this->plugin $plugin;
            
    $this->player $player;
            
    $this->pk $pk;
        }
     
  4. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    try to var_dump($pk) and show me the result please
     
  5. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    do that on the construct function:
    PHP:
    var_dump($pk);
     
  6. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    PHP:
    [Server thread/DEBUG]: #8 /home/arma/PocketMine-MP.phar(1): require(string phar:///home/arma/PocketMine-MP.phar/src/pocketmine/PocketMine.php)                                                   object(pocketmine\network\mcpe\protocol\AddEntityPacket)#14800 (15) {
      
    ["entityUniqueId"]=>
      
    NULL
      
    ["entityRuntimeId"]=>
      
    int(18)
      [
    "type"]=>
      
    int(66)
      [
    "position"]=>
      
    string(29"Vector3(x=118.5,y=10,z=235.5)"
      
    ["motion"]=>
      
    NULL
      
    ["yaw"]=>
      
    int(0)
      [
    "pitch"]=>
      
    int(0)
      [
    "attributes"]=>
      array(
    0) {
      }
      [
    "metadata"]=>
      array(
    2) {
        [
    2]=>
        array(
    2) {
          [
    0]=>
          
    int(4)
          [
    1]=>
          
    string(44"§8[§a+§8]§7 DiamondSword "
        
    }
        [
    15]=>
        array(
    2) {
          [
    0]=>
          
    int(2)
          [
    1]=>
          
    int(0)
        }
      }
      [
    "links"]=>
      array(
    0) {
      }
      [
    "isEncoded"]=>
      
    bool(true)
      [
    "extraByte1"]=>
      
    int(0)
      [
    "extraByte2"]=>
      
    int(0)
      [
    "offset"]=>
      
    int(0)
      [
    "buffer"]=>
      
    string(182"0d00002412420000ed420000204100806b430000000000000000000000000000000000000000000202042cc2a7385bc2a7612bc2a7385dc2a73720457370616461206465204469616d616e746520456e63616e746164610f020000"
    }
     
  7. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    The error is telling you that Pocketmine can't find a property called $getEntityUniqueId in AddEntityPacket; You mean the function getEntityUniqueId(), and made the same mistake for RemoveEntityPacket in the code you posted.
     
    jasonwynn10 likes this.
  8. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I have change by
    PHP:
    $pk->entityUniqueId $this->pk->entityRuntimeId;
    I got that
    PHP:
    [20:56:58] [Server thread/CRITICAL]: Could not execute task MysteryCrates\DespawnTextTrying to get property 'entityRuntimeId' of non-object
     
  9. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    We can't help when the code you posted doesn't correspond to the errors, we can't see where that $pk comes from, and you didn't use getEntityUniqueId(). You should put the plugin on github, then you might get some help.
     
    armagadon159753 and jasonwynn10 like this.
  10. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    I will do that later but maybe this is the cause
    PHP:
    public function spawnNamedText(Chest $chestPlayer $playerString $text){
            
    $pk = new AddEntityPacket();
            
    $players $this->getServer()->getOnlinePlayers();
            
    $pk->type self::NETWORK_ID;
            
    $pk->entityRuntimeId Entity::$entityCount++;
            
    $pk->metadata = [
            
    => [4"§8[§a+§8]§7 " $text ],
            
    15 => [20],
            ];
            
    $pk->yaw 0;
            
    $pk->pitch 0;
            
    $pk->position = new \pocketmine\math\Vector3($chest->getX() + 0.5$chest->getY() + 1.5$chest->getZ() + 0.5);
            foreach (
    $players as $pl) {
                
    $pl->dataPacket($pk);
            }
            
    $this->getServer()->getScheduler()->scheduleDelayedTask(new DespawnText($this$player$pk), 15 3);
        }
     
  11. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    just send the Id number on the __construct() function since you only need that.
     
  12. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    You still haven't even posted the full code of your DespawnText Task. If you want help, please try to provide the information people need.

    Assuming you passed a reference to the packet to your DespawnText constructor, and we have to assume because you haven't shown us... then correcting the code in your first snippet to:

    PHP:
    $pk->entityUniqueId $this->pk->getEntityUniqueId();
    should have fixed the problem.

    What friscowz is trying to say is that if you pass the entityRuntimeId to your DespawnText constructor, which we unfortunately haven't seen yet (did I mention how important it is to make life easy for people who try to help you?), then you can use it to set the correct $pk->entityUniqueId for the RemoveEntityPacket().
     
    jasonwynn10 likes this.
  13. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    Yes that's what i said
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.