Jump to content

[SOLVED][1.6.2] Draw GuiTextField on GuiContainer


Graphicscore
 Share

Recommended Posts

Hello, It's me again  ::)

 

I try to draw a textbox on a Gui and I had a look at the gui of the anvil but it seems like it's not working because I can't see the textField , I get no errors , nothing happens.

 

My GuiContainer

 

package org.setcore.fasttravel;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

import org.lwjgl.opengl.GL11;

public class GuiTravelMark extends GuiContainer {
private GuiTextField markName;
    private static final ResourceLocation textureLocation = new ResourceLocation("fasttravelmod:textures/guitravelmark/travelblockgui.png");

public GuiTravelMark (InventoryPlayer inventoryPlayer,
                    TileEntityTravel tileEntity) {
            //the container is instanciated and passed to the superclass for handling
            super(new ContainerTravelMark(inventoryPlayer, tileEntity));
    }

    @Override
    protected void drawGuiContainerForegroundLayer(int param1, int param2) {
            //draw text and stuff here
            //the parameters for drawString are: string, x, y, color
            fontRenderer.drawString("Travel Mark", 8, 6, 4210752);
            //draws "Inventory" or your regional equivalent
            fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2,
                    int par3) {
            //draw your Gui here, only thing you need to change is the path
            
            this.mc.renderEngine.func_110577_a(textureLocation);
            int x = (width - xSize) / 2;
            int y = (height - ySize) / 2;
            this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    }
    
    @Override
    public void drawScreen(int par1, int par2, float par3)
    {
        super.drawScreen(par1, par2, par3);
        this.markName.drawTextBox();
    }
    
    public void initGui()
    {
    	super.initGui();
    	 int i = (this.width - this.xSize) / 2;
         int j = (this.height - this.ySize) / 2;
    	this.markName = new GuiTextField(this.fontRenderer,  i + 62, j + 24, 103, 12);
    	this.markName.setTextColor(-1);
    	this.markName.setDisabledTextColour(-1);
        this.markName.setEnableBackgroundDrawing(false);
        this.markName.setMaxStringLength(40);
        this.markName.setMaxStringLength(30);
    	//buttonList.add(new GuiButton(0,200,100,100,20,"test"));
    }

}

 

 

Thanks, Graphicscore

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

 Share



×
×
  • Create New...

Important Information

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