Jump to content

Recommended Posts

Posted (edited)

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

  • Thanks 1
Posted

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
    • Maybe you need to create file in assets/<modid>/items/<itemname>.json with content like this:   { "model": { "type": "minecraft:model", "model": "modname:item/itemname" } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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