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

AddEntityPacket & AddItemEntityPack no working on m'y plugin

Discussion in 'Development' started by armagadon159753, Nov 11, 2017.

  1. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Function:
    not: they are no error display in the console
    PHP:
    public function spawnTo(Player $player){
        
    $pk = new AddEntityPacket();
        
    $pk->type Arrow::NETWORK_ID;
        
    $pk->eid $this->getId();
        
    $pk->$this->data['x'];
        
    $pk->$this->data['y'];
        
    $pk->$this->data['z'];
        
    $pk->speedX $this->motionX;
        
    $pk->speedY $this->motionY;
        
    $pk->speedZ $this->motionZ;
        
    $pk->metadata $this->dataProperties;
        
    $player->dataPacket($pk->setChannel(Network::CHANNEL_ENTITY_SPAWNING));
        
    parent::spawnTo($player);
        }
    config:
    PHP:
    $dir $this->getDataFolder();
            @
    mkdir($dir);
            if(!
    file_exists($dir.'config.json')){
                
    file_put_contents($dir.'config.json''{"x":-40,"y":70,"z":-747}');
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You sure there are no errors? The AddEntityPacket() code might not be executing then.

    What's $this->data by the way?
     
  3. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    :(
    PHP:
    [21:19:00] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'DarkFactionCore v1': Class 'pocketmine\network\protocol\AddEntityPacket' not found on DarkFactionCore\Main
    [21:19:00] [Server thread/CRITICAL]: Error"Class 'pocketmine\network\protocol\AddEntityPacket' not found" (EXCEPTIONin "DarkFactionCore-MASTER/src/DarkFactionCore/Main" at line 98
    Class:
    PHP:
    #Packet
    use pocketmine\network\protocol\{AddEntityPacketExplodePacketRemoveEntityPacketUseItemPacket};
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The class was shifted to pocketmine/network/mcpe/protocol directory around half a year ago or so.
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    I'm assuming you're using an old plugin as a reference. Some stuff in AddEntityPacket was changed over time. Check Entity::sendSpawnPacket() for how it's currently being used.
     
    jasonwynn10 and armagadon159753 like this.
  6. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Sa
    Correct?
    PHP:
    public function sendTo(PlayerJoinEvent $event){
            
    $p $event->getPlayer();
            
    $pk = new AddEntityPacket();
            
    $pk->type 71;
            
    $pk->eid Entity::$entityCount++;
            
    $pk->metadata = array();
            
    $pk->yaw 0;
            
    $pk->pitch 0;
            
    $pk->$this->data['x'];
            
    $pk->$this->data['y'];
            
    $pk->$this->data['z'];
            
    $p->dataPacket($pk);
        }
     
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    No, click the link muqsit gave you and look at how it's properly done.
     
    Muqsit and armagadon159753 like this.
  8. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    Thank a lots
     

    Attached Files:

    jasonwynn10 and Muqsit like this.
  9. armagadon159753

    armagadon159753 Zombie

    Messages:
    217
    GitHub:
    armagadon159753
    How can l define $item
    PHP:
    public function crystal(PlayerJoinEvent $e){
            
    $p $e->getPlayer();
            
    $pk = new AddEntityPacket();
            
    $pk->type 61;
            
    $pk->entityRuntimeId Entity::$entityCount++;
            
    $pk->metadata = array();
            
    $pk->yaw 0;
            
    $pk->pitch 0;
            
    $pk->position = new \pocketmine\math\Vector3($this->data['x'] + 0.5 $this->data['y'], $this->data['z'] + 0.5);
            
    $p->dataPacket($pk);
            
    $p->getLevel()->addParticle(new FloatingTextParticle(new Vector3($this->data['x'] + 0.5 $this->data['y'] + 2$this->data['z'] + 0.5), ''$this->data['text']));
         
            
    $p $e->getPlayer();
            
    $pk = new AddItemEntityPacket();
            
    $pk->type 267;
            
    $pk->entityRuntimeId Entity::$entityCount++;
            
    $pk->item $this->item;
            
    $pk->metadata 0;
            
    $pk->motion 0;
            
    $pk->yaw 0;
            
    $pk->pitch 0;
            
    $pk->position = new \pocketmine\math\Vector3($this->data['x'] + 0.5 $this->data['y'] + 3$this->data['z'] + 0.5);
            
    $p->dataPacket($pk);
    }
    }
    [
    19:33:08] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'EnderCrystal v1'Undefined propertyarmthedev\ender_crystal\main::$item on armthedev\ender_crystal\main
    [19:33:08] [Server thread/CRITICAL]: ErrorException"Undefined property: armthdev\ender_crystal\main::$item(EXCEPTIONin "EnderCrystal-master/src/armthedev/ender_crystal/main" at line 47
     
    Last edited: Nov 13, 2017
  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.