Jump to content

Need help with Screen, Widget (CustomGUI) [1.16.1]


Brandon_Stark__

Recommended Posts

Hello. I am a bit new in modding, but i know java a bit. So i want to make custom gui, not container gui, achievment gui and etc.

 

In my far plans i want to make gui of map: there 'll be a frame and around 3200x3200 map which i can drag because it is too large. 

 

Well, i looked for idea in vanilla sources. I noticed that achievments gui or container gui extends from Screen and some elements like buttons extends from Widget. So i went to Screen class and... most part of variables and methods have names like field_230701_a_ or field_230703_c_ and because of it understanding the code of this class is hard.

As for forge documentation https://mcforge.readthedocs.io/en/1.15.x/ i haven't found anything about Screen class.

Link to comment
Share on other sites

You might have a better shot looking at 1.15.2 vanilla sources since many of the 1.16 variables aren't named yet. 

This is what the render method for Screen looks like in 1.15.2:

public void render(int p_render_1_, int p_render_2_, float p_render_3_) {
      for(int i = 0; i < this.buttons.size(); ++i) {
         this.buttons.get(i).render(p_render_1_, p_render_2_, p_render_3_);
      }

   }

I also find it useful to check out the github of a mod that has already implemented something similar to what you want and base your code on theirs. 

Good Luck!

Edited by AreUThreateningMe
Caps
  • Like 1
Link to comment
Share on other sites

12 minutes ago, AreUThreateningMe said:

You might have a better shot looking at 1.15.2 vanilla sources since many of the 1.16 variables aren't named yet. 

Found this in the 1.12.2 mappings for net.minecraft.client.gui.GuiScreen, assuming it's the legacy equivalent:

    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
    {
        for (int i = 0; i < this.buttonList.size(); ++i)
        {
            ((GuiButton)this.buttonList.get(i)).drawButton(this.mc, mouseX, mouseY, partialTicks);
        }

        for (int j = 0; j < this.labelList.size(); ++j)
        {
            ((GuiLabel)this.labelList.get(j)).drawLabel(this.mc, mouseX, mouseY);
        }
    }

MCP Mappings (especially for newer version of MC) are often incomplete and contain arbitrary changes between versions, so looking at older mappings is definitely a good idea.

12 minutes ago, AreUThreateningMe said:

I also find it useful to check out the github of a mod that has already implemented something similar to what you want and base your code on theirs. 

Mekanism is open source and has a 1.16 branch. Their GUI is here: https://github.com/mekanism/Mekanism/tree/1.16.x/src/main/java/mekanism/client/gui

It seems like they have to roll most of it from scratch, this class in the render package contains most of the low-level logic and event subscriptions: https://github.com/mekanism/Mekanism/blob/1.16.x/src/main/java/mekanism/client/render/MekanismRenderer.java

Good luck!

  • Like 1

Website: jdawg3636.com
Discord: discord.gg/EKeM7Jz

Link to comment
Share on other sites

Mojang deliberately obfuscates their code with the unreadable names.

When you download Forge's MDK it uses the community-made mappings from the Mod Coder Pack project (You can download the mappings directly from http://mcpbot.bspk.rs/) and applies them so that you can see the readable ones.

The mappings are specific to MC versions not to Forge versions and you can actually configure which mappings you use in the build.gradle file.

TL;DR is that it's a lot of work that has to be done every time MC gets an update but it's a separate task from updating Forge. The mappings are never truly complete and get better over time.

Edited by jdawg3636

Website: jdawg3636.com
Discord: discord.gg/EKeM7Jz

Link to comment
Share on other sites

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.