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

Issue with plugin

Discussion in 'Development' started by Kabluinc, Dec 23, 2016.

  1. Kabluinc

    Kabluinc Baby Zombie

    Messages:
    129
    Hi,

    This code I am using to make it possible to sit on oak wood stairs no longer works correctly after 0.16.

    PHP:
    <?php
    namespace seat;

    use 
    pocketmine\Server;


    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\entity\Entity;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\event\server\DataPacketReceiveEvent;
    use 
    pocketmine\network\protocol\AddEntityPacket;
    use 
    pocketmine\event\player\PlayerInteractEvent;
    use 
    pocketmine\network\protocol\Info as ProtocolInfo;
    use 
    pocketmine\network\protocol\RemoveEntityPacket;
    use 
    pocketmine\network\protocol\SetEntityLinkPacket;
    use 
    pocketmine\network\protocol\PlayerActionPacket;
    use 
    pocketmine\Player;
    class 
    seat extends PluginBase implements Listener{   
    public function 
    onEnable(){                   
     
    $this->getServer()->getPluginManager()->registerEvents($this$this);
    $this->count 10000;

    }
    public function 
    onPacketReceived(DataPacketReceiveEvent $event){
    $pk $event->getPacket();
    switch(
    $pk::NETWORK_ID){
    case 
    ProtocolInfo::PLAYER_ACTION_PACKET;
    $player $event->getPlayer();
    if(isset(
    $this->counter[$player->getName()])){
    if(
    $pk->action === 8){$ppk = new SetEntityLinkPacket();
    $ppk->from $this->counter[$player->getName()];
    $ppk->to 0;$ppk->type 0;
    $player->dataPacket($ppk);
    $pkc = new SetEntityLinkPacket();
    $pkc->from $this->counter[$player->getName()];
    $pkc->to $player->getId();$pkc->type 0;
    $ps=Server::getInstance()->getOnlinePlayers();
    Server::broadcastPacket($ps,$pkc);
    $pk0 = new RemoveEntityPacket();
    $pk0->eid $this->counter[$player->getName()];
    $ps=Server::getInstance()->getOnlinePlayers();
    Server::broadcastPacket($ps,$pk0);
    unset(
    $this->counter[$player->getName()]);
    }
    }
    }
    }
    public function 
    onTouch(PlayerInteractEvent $event){
    if(
    $event->getBlock()->getID() === 53){
    $player $event->getPlayer();
    $pk = new AddEntityPacket();$this->count $this->count 4;
    $pk->eid$this->count;
    $pk->type 84;$pk->x$event->getBlock()->0.6;$pk->$event->getBlock()->+1.3;$pk->$event->getBlock()->0.5;
    $pk->speedX 1;$pk->speedY 0;$pk->speedZ 0;
    $pk->yaw $player->yaw;
    $pk->pitch $player->pitch;
    $pk->metadata = [
                                
    entity::DATA_FLAGS => [
                                        
    entity::DATA_TYPE_BYTE,
                                        
    << entity::DATA_FLAG_INVISIBLE
                                
    ],
                                
    entity::DATA_NAMETAG => [
                                        
    entity::DATA_TYPE_STRING,
                                ],
                                
    entity::DATA_FLAG_ALWAYS_SHOW_NAMETAG => [
                                        
    entity::DATA_TYPE_BYTE,
                                        
    1
                                
    ],
                                
    Entity::DATA_FLAG_NO_AI => [
                                        
    Entity::DATA_TYPE_BYTE,
                                        
    1
                                
    ]
                        ];
    $ps=Server::getInstance()->getOnlinePlayers();
    Server::broadcastPacket($ps,$pk);
    $ppk = new SetEntityLinkPacket();
    $ppk->from $this->count;$ppk->to 0;
    $ppk->type 2;$player->dataPacket($ppk);
    $pkc = new SetEntityLinkPacket();$pkc->from $this->count;
    $pkc->to $player->getId();$pkc->type 2;
    $ps=Server::getInstance()->getOnlinePlayers();
    Server::broadcastPacket($ps,$pkc);
    $this->counter[$player->getName()] = $this->count;
    }
    }
    }
    When u tap a stair, it still shows up a minecart and the minecart isn't set to invisible.

    Anything I can do to fix this? Many thanks
     
  2. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    Check out the latest changes to metadata to start with
     
  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.