Jump to content

1.12.2 FadeGui Not working!


FireIsH0t

Recommended Posts

package net.arsenalnetwork.arsenalmod.client.gui;

import net.arsenalnetwork.arsenalmod.ArsenalMod;
import net.arsenalnetwork.arsenalmod.util.ArsenalUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;

public class ArsenalFadeGui extends GuiScreen {

    private float fade = 0.0F;
    private int timer = 60;

    public void drawScreen(int x, int y, float ticks)
    {
        if(timer >= 0)
        {
            timer--;
            if (this.fade < 1.0F) {
                this.fade += 0.03F;
            }
        } else {
            this.mc.displayGuiScreen(new ArsenalMainMenu());
        }
        ArsenalUtils.drawBackground(0,0,new ResourceLocation(ArsenalMod.MODID, "textures/gui/fade/FadeBackground.png"),this.width,this.height);
        drawTexturedModalRect(this.width / 2 - 125, this.height / 2 - 75, 250.0D, 150.0D, "arsenal:textures/gui/fade/ArsenalLogo.png");

        super.drawScreen(x, y, y);
    }

    public void drawTexturedModalRect(double x, double y, double width, double height, String location)
    {
        GL11.glPushMatrix();
        GL11.glEnable(3042);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, this.fade);
        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(location));
        final Tessellator tessellator = Tessellator.getInstance();
        GlStateManager.enableBlend();
        final BufferBuilder buffer = tessellator.getBuffer();
        buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
        buffer.pos(x, y + height, 0.0).tex(0.0, 1.0).color(255, 255, 255, 255).endVertex();
        buffer.pos(x + width, y + height, 0.0).tex(1.0, 1.0).color(255, 255, 255, 255).endVertex();
        buffer.pos(x + width, y, 0.0).tex(1.0, 0.0).color(255, 255, 255, 255).endVertex();
        buffer.pos(x, y, 0.0).tex(0.0, 0.0).color(255, 255, 255, 255).endVertex();
        tessellator.draw();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glPopMatrix();
    }

}

 

Hello, I am trying to get my fade gui to work but it isnt. What is this fade gui? When your client loads up before it goes to the main menu gui it shows a image of the logo and then fades to the main menu

Link to comment
Share on other sites

29 minutes ago, FireIsH0t said:

public void drawScreen(int x, int y, float ticks)

Uh, the naming of the last parameter is wrong. It's partialTicks, not ticks. There is a huge difference. 

 

if(timer >= 0)
        {
            timer--;
            if (this.fade < 1.0F) {
                this.fade += 0.03F;
            }
        } else {
            this.mc.displayGuiScreen(new ArsenalMainMenu());
        }

You can't do this in the drawScreen method because it happens each frame, not each tick. If you want your animation to stay consistent with the framerate you need to use GuiScreen#updateScreen to update your counters, that happens each tick, not each frame.

 

29 minutes ago, FireIsH0t said:

super.drawScreen(x, y, y);

Why are you passing y as partialTicks?

 

29 minutes ago, FireIsH0t said:

ArsenalUtils.drawBackground(0,0,new ResourceLocation(ArsenalMod.MODID, "textures/gui/fade/FadeBackground.png"),this.width,this.height);

All resources must be lower-case(as far as I am aware anyway, feel free to correct me). Same with the line directly after.

 

29 minutes ago, FireIsH0t said:

ArsenalUtils.drawBackground

And what does this method do? Or rather what is the code of this method?

 

29 minutes ago, FireIsH0t said:

GL11.glPushMatrix();

There is no need to push/pop matrix here as you are not changing the matrix at all.

 

29 minutes ago, FireIsH0t said:

GL11.glEnable(3042);

Do you have any idea what this does? What does 3042 magic number mean? Please don't just blindly copy deobfuscated code and call it good, actually understand what's going on. Also don't use GL11, use GlStateManager. And if you are enabling blend you need to specify the blend function too since you don't know what it was specified to beforehand(3042 is GL_BLEND in case you were wondering)

 

29 minutes ago, FireIsH0t said:

GlStateManager.enableBlend();

You just enabled it. 3 lines above in fact. Oh and while I am at it if you are changing the GL state take care to restore it after you are done your drawing. Don't just leak GL state. 

 

Apart from all these glaring issues I immediately see - yeah, what @diesieben07 said. You need to clarify your issue a bit more and show a bit more code.

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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