Help with GUI

Started by abelcaron on

Topic category: Help with Minecraft modding (Java Edition)

Active 5 years ago
Joined May 2020
Points:
662

User statistics:

  • Modifications: 0
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 16
Help with GUI

Hello,

I want to do a custom GUI and when I run my mouse over an item or a button that show me  some informations ( text ).

Is it possible ?

Active 1 month ago
Joined May 2019
Points:
1216

User statistics:

  • Modifications: 0
  • Forum topics: 13
  • Wiki pages: 2
  • MCreator plugins: 1
  • Comments: 839
gui scale messes stuff up…
Fri, 06/05/2020 - 12:33

gui scale messes stuff up with the x and y

Active 1 month ago
Joined May 2019
Points:
1216

User statistics:

  • Modifications: 0
  • Forum topics: 13
  • Wiki pages: 2
  • MCreator plugins: 1
  • Comments: 839
@Override public void render…
Fri, 06/05/2020 - 13:54
@Override
public void render(int mouseX, int mouseY, float partialTicks) {
    this.renderBackground();
    super.render(mouseX, mouseY, partialTicks);
    this.renderHoveredToolTip(mouseX, mouseY);
    int currentXP = ((int) new Object() {
        public double getValue(BlockPos pos, String tag) {
            TileEntity tileEntity = world.getTileEntity(pos);
            if (tileEntity != null)
                return tileEntity.getTileData().getDouble(tag);
            return 0;
        }
    }.getValue(new BlockPos((int) x, (int) y, (int) z), "XP"));
    int percentage = (currentXP * 100) / 600;
    int XposT = 120;
    int YposT = 204;
    String string = (percentage + "%");
    if (mouseX == XposT && mouseY == YposT) {
        renderTooltip(string, mouseX, mouseY);
    }
}

The code Blue steve gave me

doesnt work

he said its becuase of screen offset

but i don't think so

help?

Active 1 month ago
Joined May 2019
Points:
1216

User statistics:

  • Modifications: 0
  • Forum topics: 13
  • Wiki pages: 2
  • MCreator plugins: 1
  • Comments: 839
protected void…
Fri, 06/05/2020 - 13:54
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
int k = (this.width - this.xSize) / 2; //X asis on GUI
int l = (this.height - this.ySize) / 2; //Y asis on GUI
if (mouseX > boxX && mouseX < boxX + sizeX) //Basically checking if mouse is in the correct area
{
if (mouseY > boxY && mouseY < boxY + sizeY)
{
List list = new ArrayList();
list.add("Power at lever " + powerLevel);
this.drawHoveringText(list, (int)mouseX - k, (int)mouseY - l, fontRenderer);
}
}
}

doesnt work as well

Active 1 year ago
Joined Jun 2015
Points:
1277

User statistics:

  • Modifications: 10
  • Forum topics: 32
  • Wiki pages: 0
  • MCreator plugins: 1
  • Comments: 543
Your code doesn't work…
Fri, 06/05/2020 - 14:40

Your code doesn't work because fontRenderer is not valid. It needs GuiContainer but we have just Container by default.

Active 1 month ago
Joined May 2019
Points:
1216

User statistics:

  • Modifications: 0
  • Forum topics: 13
  • Wiki pages: 2
  • MCreator plugins: 1
  • Comments: 839
as i siad it doesnt work for…
Fri, 06/05/2020 - 14:41

as i siad it doesnt work for creator guis

Active 1 month ago
Joined May 2019
Points:
1216

User statistics:

  • Modifications: 0
  • Forum topics: 13
  • Wiki pages: 2
  • MCreator plugins: 1
  • Comments: 839
i dont think there is a way…
Fri, 06/05/2020 - 14:48

i dont think there is a way to do it just with Container

Active 1 year ago
Joined Jun 2015
Points:
1277

User statistics:

  • Modifications: 10
  • Forum topics: 32
  • Wiki pages: 0
  • MCreator plugins: 1
  • Comments: 543
Yes I got it work. This…
Fri, 06/05/2020 - 15:26

Yes I got it work. This picture is an example of what I did but you can change it ofc

code

Active 4 years ago
Joined Sep 2019
Points:
986

User statistics:

  • Modifications: 1
  • Forum topics: 14
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 507
Just woke up! Love to see…
Fri, 06/05/2020 - 15:45

Just woke up! Love to see what you did! Good work