DevNatan / inventory-framework

Minecraft Inventory API framework
MIT License
127 stars 22 forks source link

displayIf doesn't work on context update with pagination. #540

Closed ch4ika closed 1 year ago

ch4ika commented 1 year ago

Is there an existing issue for this?

πŸ› Describe the bug

grafik

The field where my mouse hovered over disappears completely at context.update, the problem is that it shouldn't be empty but the green glass from the pagination should be applied there again.

βœ”οΈ Expected behavior

No response

πŸ‘£ Steps to Reproduce

    @Override
    public void onInit(@NotNull ViewConfigBuilder config) {
        config.title("Belohnungen");
        config.layout(
                "AAAAAAAAA",
                "XOOOOOOOX",
                "XOOOOOOOX",
                "XOOOOOOOX",
                "XOOOOOOOX",
                "AAAAAAAAA"
        );
    }

    @Override
    public void onFirstRender(@NotNull RenderContext render) {
        Pagination pagination = this.pagination.get(render);
        StreakUser user = this.user.get(render);
        render.layoutSlot('X', displayPlaceholder(Material.GRAY_STAINED_GLASS_PANE));
        render.layoutSlot('A', displayPlaceholder(Material.GREEN_STAINED_GLASS_PANE));
        render.slot(6, 3, previous()).onClick((event) -> toPreviousPage(event, pagination)).displayIf(pagination::canBack).watch(this.pagination);
        render.slot(6, 7, next()).onClick((event) -> toNextPage(event, pagination)).displayIf(pagination::canAdvance).watch(this.pagination);
        render.slot(6, 5).renderWith(() -> displayInfo(user));
    }

Now execute a click Component the context.update(); might. Then the field becomes empty, even though there should be a glass there in the pagination.

πŸ’» Platform

⭐ Server Version

1.20.1

πŸ“š Library Version

3.0.5

✍️ Additional context

No response

WizWazWizard commented 1 year ago

Hate to break it to you, its been an issue an issue for 2 years..

https://github.com/DevNatan/inventory-framework/issues/245

DevNatan commented 1 year ago

@ch4ika Was working in earlier versions, something I changed made it stop working. I will investigate. Thanks!