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'm just starting to learn minecraft modding and would like to understand how i can display an empty gui by pressing the key. 

I tried to figure it out myself from the vanilla minecraft code and tutorials, but I could not understand how it all works

What is an empty gui? If it does not store any information (e.g. inventories, sharing data) a simple screen will work using Minecraft#displayGuiScreen (this is client only).

Otherwise you will need a registered container and screen, and open it with NetworkHooks#openGui (this should be done on server, in this case you send a packet when the key is pressed).

There's a key input event that you can use, or use client tick event to proceed with keybindings (check Minecraft.java).

  • Author

Thanks for the tip. How to make a gui as a standard player inventory for storing resources, but with 1 cell. What i should use? I saw tutorials and people uses tileentity, containers but which of this do I need and what function do they perform. I wanna start with simple things 

  • Author

So itemstack allow to create a bag? I want to make an extra slot for players.  Do I need to use an entity for this? 

  • Author

How can i do it? I don't quite understand what capability is and how to attach it to the player

  • Author

Thanks for the tips i made a single stack chest. But how i can fix the inventory title pos and how should i call the lang variable to change the  chest name

 forum.PNG.dd1289b617f195a60b1e9f2cb63ba371.PNG

Edited by Klarks

Well, if you use this texture for the GUI there will never be space to write "Inventory" in a human-readable character size such as it fits that little gap 😆 To change how things are rendered/placed in your GUI you need to do that in the render method of your custom screen class

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

  • Author

That's not a problem it was just a placeholder. What i should change or add here i couldn't find anything similar in the vanilla code

@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);
}
  • Author

I fixed by adding this.playerInventoryTitleY = 42;

@Override
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
    this.renderBackground(matrixStack);
    //this.playerInventoryTitleX = 10;
    this.playerInventoryTitleY = 42;
    super.render(matrixStack, mouseX, mouseY, partialTicks);
    this.renderHoveredTooltip(matrixStack, mouseX, mouseY);
}

forum.PNG

I just noticed that the titles are actually rendered in drawGuiContainerForegroundLayer() not render().

Also I believe you only need to set the value once in the constructor, or in init().

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.