Why is fake inventory closes automatically after 3-4 seconds after open?

Yexeed

Member
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());
    }
 
Inventories work completely different on Bedrock Edition compared to Java Edition. It is not possible to create inventories windows which are not tied to a block in the world. To make this work, you would have to spawn a chest near the player and then open the inventory window.
 
Inventories work completely different on Bedrock Edition compared to Java Edition. It is not possible to create inventories windows which are not tied to a block in the world. To make this work, you would have to spawn a chest near the player and then open the inventory window.
That's what I'm doing, actually. This code works perfect on a pmmp
 
I'm figured out how its happen: its caused by garbage collection. So, is it possible to not gc a chest tile while player is viewing it?
 
OMG, fixed by copying GC function from current nukkitx master branch. Btw, IDEA says that this ArrayList isn't used and a grammar mistake in a comment. upload_2018-7-3_20-12-8.png
 
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());
    }
I have a question, why are you using a class that extends player? and how are you going to make the constructor? thx.
 
Back
Top