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

VirtualWorkbench

Discussion in 'Development' started by SkyArt4, Jan 27, 2017.

  1. SkyArt4

    SkyArt4 Silverfish

    Messages:
    16
    GitHub:
    nadaree
    I want to use the workbench GUI with command.
    However, by all means error To appear :/
    a lot code is https://forums.pmmp.io/threads/open-crafting-table-code.88 I borrowed from.
    PHP:
        public function onCommand(CommandSender $senderCommand $command$label, array $args)
        {
          
    //Messages
          
    $Mes1 "§eYou opened";
          
    $Mes2 "§a/vr §7 §8[ §aenchant§8 | §afurnace§8 | §astand§8 | §aworkbench§8 ] ";
          
    $x $sender->getX();$y $sender->getY();$z $sender->getZ();
          
    $le $sender->getLevel();

            if(
    $sender instanceof Player) {
                switch (
    $command->getName()) {
                    case 
    "vr":
                        if (isset(
    $args[0])) {
                            switch (
    strtolower($args[0])) {
                                case 
    "workbench":
                                
    $table $this->getServer()->getLevelByName($le)->getTile(new WindowInventory($sender9))->getInventory();
                                    
    $sender->sendMessage($Mes1);
                                    
    $sender->addWindow($table);
                                    break;
    Since the code after this is not necessary for the question, I will not write it...
     
  2. gistrec

    gistrec Witch

    Messages:
    68
    GitHub:
    gistrec
    I think, that you need send workbench to player.
    This code allow to create fake chest:
    PHP:
    $block Block::get(54);
    $block->floor($sender->x);
    $block->floor($sender->y)-2;
    $block->floor($sender->z);
    $block->level $sender->level;
    $sender->level->sendBlocks([$sender],[$block]);

    $nbt = new CompoundTag('', [
        new 
    ListTag('Items', []),
        new 
    StringTag('id'$id Tile::CHEST),
        new 
    IntTag('x'floor($sender->x)),
        new 
    IntTag('y'floor($sender->y) - 2),
        new 
    IntTag('z'floor($sender->z))
    ]);
    /** @var Chest $tile */
    $tile Tile::createTile('Chest'$sender->chunk$nbt);

    $customInv = new ChestInventory($tile);
    $sender->addWindow($customInv);
     
    Shelly7w7, Skullex and SkyArt4 like this.
  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.