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

Hello everyone, I was creating plugins and decided to move on to creating mods and I ran into such a problem that I can’t create a gui, there used to be a guiscreen class for this, but in the new versions it was removed and I can’t create it. I ask you please help me, because I can’t do it at all, I really hope for help. Thanks to all who responded.

 

 

https://imgur.com/J5v5kDD

Edited by Natsumi

The class is now called Screen (if you're talking about the client side part of a Gui).

  • Author

I don’t know why, but if earlier I knew how to create guis, now I’m very stupid.

2 hours ago, Natsumi said:

I don’t know why, but if earlier I knew how to create guis, now I’m very stupid.

There are a lot of changes in the vanilla and Forge code, if you have code from a older version you can throw it away.

What did you already create and where did you need help?

And for me, if you're talking about Gui's do you mean a Contains with Slots for Items or only a Screen (client side only) with Buttons etc.?

25 minutes ago, Luis_ST said:

What did you already create and where did you need help?

 

  • Author

public class GuiSkill extends GuiScreen {

final ResourceLocation texture = new ResourceLocation(Unital.MOD_ID, "textures/gui/skillM.png");

int guiWidth = 175;

int guiHeight = 228;

GuiButton button1;

GuiButtonSkills arrow;

GuiTextField textBox;

final int BUTTON1 = 0, ARROW = 1;

String title = "Skills upgrade";

@Override

public void drawScreen(int mouseX, int mouseY, float partialTicks) {

drawDefaultBackground();

Minecraft.getMinecraft().renderEngine.bindTexture(texture);

int centerX = (width / 2) - guiWidth / 2;

int centerY = (height / 2) - guiHeight / 2;

//drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight);

//drawString(fontRendererObj, "Tutorial", centerX, centerY, 0x6028ff);

GlStateManager.pushMatrix();

{

GlStateManager.enableAlpha();

GlStateManager.enableBlend();

GlStateManager.color(1, 1, 1, 1);

Minecraft.getMinecraft().renderEngine.bindTexture(texture);

drawTexturedModalRect(centerX, centerY, 0, 0, guiWidth, guiHeight);

}

GlStateManager.popMatrix();

GlStateManager.pushMatrix();

{

GlStateManager.translate((width / 2) - fontRenderer.getStringWidth(title), centerY + 10, 0);

GlStateManager.scale(2, 2, 2);

fontRenderer.drawString(title, 0, 0, 0x6028ff);

}

GlStateManager.popMatrix();

//super.drawScreen(mouseX, mouseY, partialTicks);

button1.drawButton(mc, mouseX, mouseY);

arrow.drawButton(mc, mouseX, mouseY);

ItemStack icon = new ItemStack(Blocks.OBSIDIAN);

GlStateManager.pushMatrix();

{

GlStateManager.translate(centerX, centerY, 0);

GlStateManager.scale(2, 2, 2);

mc.getRenderItem().renderItemAndEffectIntoGUI(icon, 0, 0);

}

GlStateManager.popMatrix();

textBox.drawTextBox();

List<String> text = new ArrayList<String>();

text.add(I18n.format("gui.tooltip"));

text.add(I18n.format("gui.tooltip2", mc.world.provider.getDimension()));

text.add(icon.getDisplayName());

drawTooltip(text, mouseX, mouseY, centerX, centerY, 16 * 2, 16 * 2);

}

public void drawTooltip(List<String> lines, int mouseX, int mouseY, int posX, int posY, int width, int height) {

if (mouseX >= posX && mouseX <= posX + width && mouseY >= posY && mouseY <= posY + height) {

drawHoveringText(lines, mouseX, mouseY);

}

}

@Override

public void initGui() {

buttonList.clear();

buttonList.add(button1 = new GuiButton(BUTTON1, (width / 2) - 100 / 2, height - 40, 100, 20, "Close"));

buttonList.add(arrow = new GuiButtonTutorial(ARROW, 100, 100));

textBox = new GuiTextField(0, fontRenderer, 0, 0, 100, 20);

updateButtons();

super.initGui();

}

public void updateButtons() {

if (title.equals("Close")) {

button1.enabled = true;

} else {

button1.enabled = false;

}

}

public void updateTextBoxes() {

if (!textBox.getText().isEmpty()) {

if (!textBox.isFocused()) {

title = textBox.getText();

}

}

updateButtons();

}

@Override

protected void actionPerformed(GuiButton button) throws IOException {

switch (button.id) {

case BUTTON1:

mc.displayGuiScreen(null);

break;

case ARROW:

mc.displayGuiScreen(new GuiInventory(mc.player));

break;

}

updateButtons();

super.actionPerformed(button);

}

@Override

protected void keyTyped(char typedChar, int keyCode) throws IOException {

textBox.textboxKeyTyped(typedChar, keyCode);

updateTextBoxes();

super.keyTyped(typedChar, keyCode);

}

@Override

protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {

textBox.mouseClicked(mouseX, mouseY, mouseButton);

updateTextBoxes();

super.mouseClicked(mouseX, mouseY, mouseButton);

}

@Override

public boolean doesGuiPauseGame() {

return false;

}

}

Guest
This topic is now closed to further replies.

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.