Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

did you println before drawign the text box, have you tried moving it to drawForegroudn ?

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

this.markName.setEnableBackgroundDrawing(false);

 

 

true ???

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

What hydroflame said.

And

this.markName.setMaxStringLength(40);
this.markName.setMaxStringLength(30);

meh.

@gotolink, lol, didnt notice that xD

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.