Своя кнопка

Версия Minecraft
1.12.2

will0376

Токсичная личность
2,059
55
574
Вечера всем доброго. пытаюсь сделать кнопку со своей текстурой...
Что сделано: расширил guibutton и переопределил drawButton.
Пытаюсь рисовать разные текстуры на каждую кнопку - ... получается бинд последней текстуры на всё...
Java:
public void initGui(){
        this.buttonList.clear();
        this.buttonList.add(new GuiButtonSome(-1,":textures/gui/close.png",":textures/gui/close-sel.png", this.width/2-65, this.height/2+80, 24, 24,"exit"));
        this.buttonList.add(new GuiButtonSome(-2,":textures/gui/buy.png",":textures/gui/buy-sel.png",this.width/2,this.height/2,120,29,"test"));
    }

Код:
int h = 0, w = 0;
    public static ResourceLocation img = null;
    public static ResourceLocation imgSelected = null;
    public GuiButtonSome(int buttonId,String path,String selectedPath, int x, int y, int widthIn, int heightIn, String buttonText)
    {
        super(buttonId,x,y,widthIn,heightIn,buttonText);
        h = heightIn;
        w = widthIn;
        img = new ResourceLocation(Main.MODID + path);
        imgSelected = new ResourceLocation(Main.MODID + selectedPath);
    }

    public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks)
    {
        if (this.visible)
        {
            FontRenderer fontrenderer = mc.fontRenderer;
            mc.getTextureManager().bindTexture(img);
            //System.out.println(img.getPath());
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
            this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
            //int i = this.getHoverState(this.hovered);
            if (this.hovered)
                    mc.getTextureManager().bindTexture(imgSelected);

            GlStateManager.enableBlend();
            GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
            //this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
            //this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
            draw();
            this.mouseDragged(mc, mouseX, mouseY);
            int j = 14737632;
            if (packedFGColour != 0)
                j = packedFGColour;
            else if (!this.enabled)
                j = 10526880;
            else if(this.hovered){
                j = 16777120;
            this.drawCenteredString(fontrenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, j);
        }
    }
    private void draw(){
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION_TEX);
        bufferbuilder.pos(x, (y+h), 0.0D).tex(0,1).endVertex();
        bufferbuilder.pos(x + w, y + h, 0.0).tex(1, 1).endVertex();
        bufferbuilder.pos(x + w, y, 0.0).tex(1,0).endVertex();
        bufferbuilder.pos(x, y, 0).tex(0,0).endVertex();
        tessellator.draw();
    }
Чет я не то делаю...
 
Сверху