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

Open ChestInventory at a distance

Comments in 'Plugin Development' started by FaigerSYS, Sep 25, 2016.

  1. FaigerSYS
    Offline

    FaigerSYS New Member

    Joined:
    May 9, 2016
    Posts:
    8
    How to open ChestInventory, if it's very far from me? I've created this hack:
    PHP:
    public function showChest($player) {
        
    $player->sendPosition($this->chestPositionnullnull1);
        
    $player->addWindow($this->chestInvenrory);
    }

    public function 
    onPacket(DataPacketSendEvent $e) {
        
    $packet $e->getPacket();
        
    $name $e->getPlayer()->getName();
        if (
    $packet instanceof MovePlayerPacket) {
            
    $v $this->chestInvenrory->getViewers();
            foreach (
    $v as $p) {
                if (
    $p->getName() === $name) {
                    
    $e->setCancelled(true);
                }
            }
        }
    }
    But it works only when chunk is loaded for player. So there is two questions:
    1. How to send requested chunk to player?
    2. If I can't, is there an alternative?
    Last edited: Sep 25, 2016
  2. JonsMC
    Offline

    JonsMC Active Member

    Joined:
    Jul 26, 2016
    Posts:
    107
    Minecraft User:
    JonsMC
    why dont you use PlayerMoveEvent?
  3. FaigerSYS
    Offline

    FaigerSYS New Member

    Joined:
    May 9, 2016
    Posts:
    8
    It's needed to block sending packet from server to player. PlayerMoveEvent calls when player send move packet to sever
    Last edited: Sep 25, 2016

Share This Page

Advertisement