I'm making a command which is used to see someone's enderchest inventory. (Nukkit 1.1 last build after 1.2), Here is the code:
Code:
//class which extends player
public void openInventory(Inventory inventory) {
if(this.getSession().isInvsee()){
this.getSession().setInvsee(true);
}
BlockEntityChest chest = (BlockEntityChest) BlockEntity.createBlockEntity(
BlockEntity.CHEST,
this.chunk,
new CompoundTag()
.putString("id", "Chest")
.putInt("x", this.getFloorX())
.putInt("y", this.getFloorY() - 2)
.putInt("z", this.getFloorZ())
);
Block block = Block.get(Block.CHEST);
block.x = chest.x;
block.y = chest.y;
block.z = chest.z;
block.level = chest.getLevel();
block.level.sendBlocks(new Player[]{this}, new Block[]{block});
for (Item item : inventory.getContents().values()){
chest.getInventory().addItem(item);
}
this.addWindow(chest.getInventory());
}