Jump to content

Recommended Posts

Posted

I have this screen which I like 

guard-screen.png

 

However since I am forced to use AbstractContainerScreen, it now looks like this

2023-05-01-22-14-47.png

 

Here is my Screen Class

public ArcherGuardScreen(ArcherMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
        super(pMenu, pPlayerInventory, pTitle);
        init();
    }

    @Override
    protected void init() {
        this.addRenderableWidget(new Button(this.width / 2 + 5, this.height / 6 - 12 + 24, 70, 20, Component.nullToEmpty("Stay"), (p_96278_) -> {
            ModMessages.sendToServer(new ArcherUpdateC2S(1));
            this.minecraft.setScreen(null);
        }));
        this.addRenderableWidget(new Button(this.width / 2 + 5, this.height / 6 - 12 + 60, 70, 20, Component.nullToEmpty("Move Freely"), (p_96278_) -> {
            ModMessages.sendToServer(new ArcherUpdateC2S(2));
            this.minecraft.setScreen(null);
        }));
        this.addRenderableWidget(new Button(this.width / 2 + 5, this.height / 6 - 12 + 96 , 70, 20, Component.nullToEmpty("Ignore Nearby"), (p_96278_) -> {
            ModMessages.sendToServer(new ArcherUpdateC2S(3));
            this.minecraft.setScreen(null);
        }));
        this.addRenderableWidget(new Button(this.width / 2 + 5, this.height / 6 - 12 + 132 , 70, 20, Component.nullToEmpty("Hire Guard"), (p_96278_) -> {
            ModMessages.sendToServer(new ArcherUpdateC2S(4));
            this.minecraft.setScreen(null);
        }));
        super.init();
    }

    @Override
    public boolean shouldCloseOnEsc() {
        return true;
    }

    @Override
    public boolean isPauseScreen() {
        return true;
    }

    @Override
    protected void renderBg(PoseStack pPoseStack, float pPartialTick, int pMouseX, int pMouseY) {

    }

    @Override
    public void onClose() {
        this.minecraft.setScreen(null);
    }

Please note my old Screen class was identical to this one except it did most of the backend there however since I am forced to use containers for an actual server I had to revamp the entire thing so only init() is changed everything else is the same as last class except the new method renderBg() which I am sure its causing this but I am so so bad and PoseStacks I have no idea how to set the text to where it needs to be, for now ill just mess with the Button widget values

Posted
this.width / 2 + 5

That x position the typical pattern to centre then add 5.

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted

And if you are not doing a traditional container screen, you probably want to override what AbstractContainerScreen.init() does when it calculates leftPos/topPos

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Posted
Just now, warjort said:
this.width / 2 + 5

That x position the typical pattern to centre then add 5.

got it, fixed up and looking good. Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.