Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

i created a GUI and the screen is render and working perfectly, but why THE FUCK my button is like this HAHAHA

https://imgur.com/a/ofhWSiW

public class ResearcherScreen extends ContainerScreen<ResearcherContainer> {
    private final ResourceLocation GUI = new ResourceLocation(TotisMod.MOD_ID,
            "textures/gui/researcher_gui.png");

    public ResearcherScreen(ResearcherContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
        super(screenContainer, inv, titleIn);
    }

    private Button myButton;

    @Override
    public void init() {
        super.init();
        buttons.clear();
        myButton = addButton(new Button(66,66,103,50,new TranslationTextComponent("hola"),this::actionPerformed));
    }

    public void actionPerformed(Button button)
    {
        if(button == myButton)
        {
            PlayerEntity player = Minecraft.getInstance().player;
            player.sendStatusMessage(new StringTextComponent("Button clicked"),false);
        }
    }

    @Override
    public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
        this.renderBackground(matrixStack);
        super.render(matrixStack, mouseX, mouseY, partialTicks);
        this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
        RenderSystem.color4f(1f, 1f, 1f, 1f);
        this.minecraft.getTextureManager().bindTexture(GUI);
        int i = this.guiLeft;
        int j = this.guiTop;
        this.blit(matrixStack, i, j, 0, 0, this.xSize, this.ySize);
    }
}

 

  • Author
10 hours ago, diesieben07 said:

Vanilla buttons only support a height of 20.

now is showing correctly but is not printing anything in chat(before it worked and i only changed the height to 20 as you told me)

public class ResearcherScreen extends ContainerScreen<ResearcherContainer> {
    private final ResourceLocation GUI = new ResourceLocation(TotisMod.MOD_ID,
            "textures/gui/researcher_gui.png");

    public ResearcherScreen(ResearcherContainer screenContainer, PlayerInventory inv, ITextComponent titleIn) {
        super(screenContainer, inv, titleIn);
    }

    private Button myButton;

    @Override
    public void init() {
        super.init();
        buttons.clear();
        this.addButton(new Button(66,60,103,20,new StringTextComponent("hola"),this::actionPerformed));
    }

    public void actionPerformed(Button button)
    {
        if(button == myButton)
        {
            PlayerEntity player = Minecraft.getInstance().player;
            player.sendStatusMessage(new StringTextComponent("Button clicked"),false);
        }
    }

    @Override
    public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
        this.renderBackground(matrixStack);
        super.render(matrixStack, mouseX, mouseY, partialTicks);
        this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(MatrixStack matrixStack, float partialTicks, int x, int y) {
        RenderSystem.color4f(1f, 1f, 1f, 1f);
        this.minecraft.getTextureManager().bindTexture(GUI);
        int i = this.guiLeft;
        int j = this.guiTop;
        this.blit(matrixStack, i, j, 0, 0, this.xSize, this.ySize);
    }
}

 

5 hours ago, ElTotisPro50 said:
 if(button == myButton)

You never assign anything to myButton.

You changed this:

22 hours ago, ElTotisPro50 said:
myButton = addButton

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.