Jump to content

Pls help create gui [1.19.2]


Natsumi

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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;

}

}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • At result, change: "id": "minecraft:iron_ingot" to "item": "minecraft:iron_ingot"
    • Thank all of you so much you are fucking psychos for doing this thank you so much :)
    • i have this custome crossbow i made  it autoloads after the first shoot is nice and all    but i don't like how when aiming it begins missaligned a little to the right then it slowly trembles a few and aligning whit the crosshair   this is coze the bow animation id vertical and made this crosbow rotate 90degrees      public UseAnim getUseAnimation(ItemStack p_40678_) {         return UseAnim.BOW;     } why i dont use UseAnim.CROSSBOW  for a crossbow  you see  the vainilla crossbow from the CrossbowItem.class uses a tag to know if its pulling to load an arrow or to shoot  private static final String TAG_CHARGED = "Charged"; i copy this methods to mi crossbow and set to UseAnim.CROSSBOW  but dont seems to do nothing     public static boolean isCharged(ItemStack p_40933_) {       CompoundTag compoundtag = p_40933_.getTag();       return compoundtag != null && compoundtag.getBoolean("Charged");    }    public static void setCharged(ItemStack p_40885_, boolean p_40886_) {       CompoundTag compoundtag = p_40885_.getOrCreateTag();       compoundtag.putBoolean("Charged", p_40886_);    } inside LivingEntity.class there is this   .getUseItemRemainingTicks()  thats used to calculate the bow pulling but seems like theres no .setUseItemRemainingTicks()   hoping to be understandable          i need to override the way the pulling animation is calculated to set it to the max from the beginning just for the sake of aesthetics             
    • So I'm able to download modpacks from curse forge get the into the minecraft mod folder but once the upload starts on the launcher it get's to the end and just won't progress does any one know what the issue might be I've uninstalled and reinstalled everything but I keep having the same problem.
    • { "type": "minecraft:crafting_shaped", "pattern": [ "i i", " R ", "i i" ], "key": { "i": { "item": "minecraft:iron_ingot" }, "R": { "item": "minecraft:redstone" } }, "result": { "id": "minecraft:iron_ingot" } } I'm having a problem where I've created a simple crafting recipe that takes in redstone dust and 4 iron ingots and returns an iron ingot (just for testing purposes). I have the file in my resouces/data/(modid)/recipes directory. However, the recipe does not work and I get no output when actually using a crafting table. Any help would be useful.
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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