Posted July 29, 201312 yr 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
July 29, 201312 yr was renamed to buttonList yknow you can open the class GuiContainer, GuiScreen and look to see how to code is made how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
July 30, 201312 yr 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.
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.