Created
June 11, 2015 21:41
-
-
Save iksaku/a4c3948c41cb4a21d17d to your computer and use it in GitHub Desktop.
Way to open virtual custom inventories in MCPE :D (Work in progress...)
Special thanks to @alejandroliu and @PEMapModder for a previous research :3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @name VirtualInventories | |
* @main VirtualInventories\Loader | |
* @version 1.0.0 | |
* @api 1.12.0 | |
* @description Way to open virtual custom inventories | |
* @author iksaku | |
*/ | |
namespace VirtualInventories{ | |
use pocketmine\command\Command; | |
use pocketmine\command\CommandSender; | |
use pocketmine\command\PluginIdentifiableCommand; | |
use pocketmine\inventory\ChestInventory; | |
use pocketmine\nbt\tag\Compound; | |
use pocketmine\nbt\tag\Enum; | |
use pocketmine\nbt\tag\Int; | |
use pocketmine\nbt\tag\String; | |
use pocketmine\Player; | |
use pocketmine\plugin\PluginBase; | |
use pocketmine\tile\Chest; | |
use pocketmine\tile\Tile; | |
class Loader extends PluginBase{ | |
public function onEnable(){ | |
$this->getServer()->getCommandMap()->register("VirtualInventories", new VirtualCommand($this)); | |
$this->virtualChest(); | |
} | |
/** @var null|Chest */ | |
private $fakeChest = null; | |
/** | |
* @return Chest | |
*/ | |
private function fakeChestTile(){ | |
if($this->fakeChest === null){ | |
$this->fakeChest = new Chest($this->getServer()->getDefaultLevel()->getChunk(0 >> 4, 0>> 4), new Compound("VirtualChest", [ | |
new Enum("Items", []), | |
new String("id", Tile::CHEST), | |
new Int("x", 0), | |
new Int("y", 0), | |
new Int("z", 0) | |
])); | |
} | |
return $this->fakeChest; | |
} | |
/** @var null|ChestInventory */ | |
private $virtualChest = null; | |
/** | |
* @return ChestInventory | |
*/ | |
public function virtualChest(){ | |
if($this->virtualChest === null){ | |
$this->virtualChest = new ChestInventory($this->fakeChestTile()); | |
} | |
return $this->virtualChest; | |
} | |
} | |
class VirtualCommand extends Command implements PluginIdentifiableCommand{ | |
/** @var Loader */ | |
private $plugin; | |
/** | |
* @param Loader $plugin | |
*/ | |
public function __construct(Loader $plugin){ | |
parent::__construct("virtual", "Opens a virtual chest", null, ["v", "chest"]); | |
$this->plugin = $plugin; | |
} | |
/** | |
* @return Loader | |
*/ | |
public function getPlugin(){ | |
return $this->plugin; | |
} | |
/** | |
* @param CommandSender $sender | |
* @param string $alias | |
* @param array $args | |
* @return bool | |
*/ | |
public function execute(CommandSender $sender, $alias, array $args){ | |
if(!$sender instanceof Player){ | |
return false; | |
} | |
$sender->addWindow($this->getPlugin()->virtualChest()); | |
return true; | |
} | |
} | |
} |
can u make a trade system with virtualchest
Is this working? ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I haven't tried to update this script, but in prior versions, you needed to put a physical chest at coordinates (0,0,0) where the virtual compound is located, open it and then you would be able to acces it