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

Call new packet problem

Comments in 'Plugin Development' started by BlinkSun, Apr 23, 2014.

  1. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    Why the chest window do not popup when i call that with a command ?

    public function commandHandler($cmd, $params, $issuer, $alias){
    switch($cmd){
    case "openchest":
    $player = $issuer;
    $this->openEnderchest = true;
    //console(FORMAT_GREEN."Chest Open".FORMAT_RESET);
    $player->windowCnt++;
    $player->windowCnt = $id = max(2, $player->windowCnt % 99);
    $player->windows[$id] = TILE_CHEST;
    $pk = new ContainerOpenPacket;
    $pk->windowid = $id;
    $pk->type = WINDOW_CHEST;
    $pk->slots = is_array($player->windows[$id]) ? CHEST_SLOTS << 1:CHEST_SLOTS;
    $pk->x = 0;
    $pk->y = 0;
    $pk->z = 0;
    $player->dataPacket($pk);
    break;
    }
    }
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    I think a player will only open a chest if they have requested the tile, could be wrong though.
  3. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    But if I can disable the opening of a chest, its because I can order to open it too ?
  4. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Don't know what you mean?
  5. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    bah if you code a simple handle like that, you can disable the opening of the window chest

    PHP:
        public function eventHandle($data$event) {
            switch (
    $event) {
                case 
    "player.block.touch":
                    if(
    $data["target"]->getID() == 54) return false;
                break;
            }
         }
    why i cant open a window chest without chest ?
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Because when a player taps a Chest they ask the server for the chest items, if they get the chest packet at any other time they don't use it, if they don't receive packet then they can't open the chest.
  7. BlinkSun
    Offline

    BlinkSun Active Member Plugin Developer

    Joined:
    Mar 26, 2014
    Posts:
    128
    Plugins:
    4
    Minecraft User:
    BlinkSun
    Ok this time I understand what you mean !! Well, i can send the pakect anytime but the client ll not process it because it didnt ask for it !! So im sad that i cant do that ;(

Share This Page

Advertisement