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

    • Post logs as per https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/ They may have information that will answer these questions.
    • I was left reeling when a glitch on a cryptocurrency exchange caused me to lose $166,000 worth of my hard-earned savings. It felt like my entire world had crumbled in the blink of an eye, leaving me with a sense of hopelessness. Determined not to give up, I delved into research on recovery options, unsure of what to expect. That's when I stumbled upon I was left reeling when a glitch on a cryptocurrency exchange caused me to lose $166,000 worth of my hard-earned savings. It felt like my entire world had crumbled in the blink of an eye, leaving me with a sense of hopelessness. Determined not to give up, I delved into research on recovery options, unsure of what to expect. That's when I stumbled upon DIGITAL HACK RECOVERY, a beacon of hope in my darkest hour. Despite my initial doubts, I decided to take a leap of faith and give them a shot as a final lifeline. The experts at DIGITAL HACK RECOVERY proved to be masters of their craft, guiding me through their exclusive process with precision and expertise. Utilizing cutting-edge blockchain analysis methods, they were able to track down the elusive trail of my missing funds and identify the exact point of failure. Their forensic talents were unparalleled as they tirelessly combed through the intricate web of blockchain data to locate my cryptocurrency. With each step they took, they kept me informed of their progress, never wavering in their belief that my funds could be rescued. After several painstaking weeks, DIGITAL HACK RECOVERY finally located and restored my $166,000 worth of cryptocurrency. I was awestruck that they were able to salvage what I had thought was lost forever. The whole experience restored my faith in the crypto space and proved that even in the worst situations, recovery is possible with the right experts on your side. I will be forever grateful to DIGITAL HACK RECOVERY for giving me back my life savings when I needed it most. Their tireless efforts and technical mastery turned what could have been a devastating loss into an uplifting success story. Book a time with DIGITAL HACK RECOVERY through: digital hack recovery @ techie . com &  +12018871705
    • public class ParticleReboundRecipe implements Recipe<CraftingContainer> { private List<ParticleReboundIngredient> inputs; private ParticleReboundFuel fuel; private ItemStack output; public ParticleReboundRecipe(List<ParticleReboundIngredient> inputs, ParticleReboundFuel fuel, ItemStack output) { this.inputs = inputs; this.fuel = fuel; this.output = output; } // TODO: Implement interface ... // TODO: Move to separate file if desired public record ParticleReboundIngredient(Ingredient ingredient, int count) { public static final Codec<ParticleReboundIngredient> CODEC = RecordCodecBuilder.create( builder -> builder.group( Ingredient.CODEC.fieldOf("ingredient").forGetter((i) -> i.ingredient), Codec.INT.fieldOf("count").forGetter(i -> i.count) ).apply(builder, ParticleReboundIngredient::new) ); } // TODO: Move to separate file if desired public record ParticleReboundFuel(String tag) { public static final Codec<ParticleReboundFuel> CODEC = RecordCodecBuilder.create( builder -> builder.group(Codec.STRING.fieldOf("tag").forGetter(f -> f.tag)).apply(builder, ParticleReboundFuel::new) ); public boolean isFuel(ItemStack stack) { // TODO: Check if fuel item matches the tag } } public class Serializer implements RecipeSerializer<ParticleReboundRecipe> { public static final Codec<ParticleReboundRecipe> CODEC = RecordCodecBuilder.create( builder -> builder.group( ParticleReboundIngredient.CODEC.listOf().fieldOf("inputs").forGetter(r -> r.inputs), ParticleReboundFuel.CODEC.fieldOf("fuel").forGetter(r -> r.fuel), ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output) ).apply(builder, ParticleReboundRecipe::new) ); @Override public @NotNull Codec<ParticleReboundRecipe> codec() { return CODEC; } // TODO: The rest ... } }   ?
    • I'm sure load and SaveAdditional are what you are looking for, probably. Mind sharing your BE class code? You also need to override onLoad method if you haven't
  • Topics

×
×
  • Create New...

Important Information

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