Jump to content

[SOLVED][1.6.2] GuiContainer - Can't access controlList


Graphicscore

Recommended Posts

Hey I've written a GuiContainer and want to add a Button or better a Textfield but I can't access the controlList

 

In the tutorial it says :

 

@Override
        public void initGui() {
                super.initGui();
                //make buttons
                                        //id, x, y, width, height, text
                controlList.add(new GuiButton(1, 10, 52, 20, 20, "+"));
                controlList.add(new GuiButton(2, 40, 72, 20, 20, "-"));
        }

        protected void actionPerformed(GuiButton guibutton) {
                //id is the id you give your button
                switch(guibutton.id) {
                case 1:
                        i += 1;
                        break;
                case 2:
                        i -= 1;
                }
                //Packet code here
                //PacketDispatcher.sendPacketToServer(packet); //send packet
        }

 

 

But I have no  controlList what to do ?

 

My GuiContainer

 

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

public class GuiTravelMark extends GuiContainer {

    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 initGui()
    {
    	//controlList.add ....
    }
}

 

 

Thanks for help, Graphicscore

Link to comment
Share on other sites

Yup most of the times when tutorials become 'outdated' it's just because methods/fields get renamed. So like hydroflame said, take a look in the class the method/field is from when you get an error.

Author of PneumaticCraft, MineChess, Minesweeper Mod and Sokoban Mod. Visit www.minemaarten.com to take a look at them.

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.



×
×
  • Create New...

Important Information

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