Skip to content

Container does not get destroyed when closing it. #3

@Aex66

Description

@Aex66

What i mean is that when you open a container, and the players closes it and then the player tries to open another one you will always get this error: Error: Player already has a fake container assigned.

I even tried using PlayerManager.removeContainer() and container.destruct() in the onCloseCallback but none of them work.

this is my code:

command.register('chest', 'Open chest').overload((_, origin) => {
        const plr = origin.getEntity()
        if (!plr?.isPlayer()) return;
        const inv = ContainerMenu.create(plr, FakeContainerType.DoubleChest, true)
        inv.addItem(ItemStack.create('minecraft:diamond', 1, 2))
        inv.sendToPlayer()
        inv.onContainerClose(() => {
            inv.destruct()
            PlayerManager.removeContainer(plr.getNetworkIdentifier())
        })
    }, {})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions