com.builtbroken.mc.prefab.gui.buttons.GuiLeftRightArrowButton.java Source code

Java tutorial

Introduction

Here is the source code for com.builtbroken.mc.prefab.gui.buttons.GuiLeftRightArrowButton.java

Source

package com.builtbroken.mc.prefab.gui.buttons;

import com.builtbroken.mc.client.SharedAssets;
import com.builtbroken.mc.prefab.gui.GuiButton2;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.OpenGlHelper;
import org.lwjgl.opengl.GL11;

/**
 * @see <a href="https://github.com/BuiltBrokenModding/VoltzEngine/blob/development/license.md">License</a> for what you can and can't do with the code.
 * Created by Dark(DarkGuardsman, Robert) on 4/25/2016.
 */
public class GuiLeftRightArrowButton extends GuiButton2<GuiLeftRightArrowButton> {
    final boolean left;

    public GuiLeftRightArrowButton(int id, int x, int y, boolean left) {
        super(id, x, y, 15, 9, "");
        this.left = left;
    }

    @Override
    public void drawButton(Minecraft mc, int mouseX, int mouseY) {
        if (this.visible) {
            mc.getTextureManager().bindTexture(SharedAssets.GUI_COMPONENTS);

            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

            this.field_146123_n = mouseX >= this.x() && mouseY >= this.y() && mouseX < this.x() + this.getWidth()
                    && mouseY < this.y() + this.getHeight();

            GL11.glEnable(GL11.GL_BLEND);
            OpenGlHelper.glBlendFunc(770, 771, 1, 0);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            this.drawTexturedModalRect(this.x(), this.y(), 18 + (!left ? 18 : 0), 216 + (field_146123_n ? 9 : 0),
                    15, 9);
            this.mouseDragged(mc, mouseX, mouseY);
        }
    }
}